Skip to content

Commit 6aebc82

Browse files
Update Docker workflow to target main branch and refine container run command
1 parent 1796427 commit 6aebc82

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

.github/workflows/docker-image-pr.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Docker Image CI
22

33
on:
44
push:
5-
branches: [ "develop" ]
5+
branches: [ "main" ]
66
pull_request:
7-
branches: [ "develop" ]
7+
branches: [ "main" ]
88

99
jobs:
1010
build:
@@ -34,16 +34,14 @@ jobs:
3434

3535
- name: Run the application container
3636
run: |
37-
docker run --name grandnode2-container -d -p 8080:8080 --user root --link mongodb-container:mongo grandnode2:pr-latest
37+
docker run --name grandnode2-container -d -p 8080:8080 --link mongodb-container:mongo grandnode2:pr-latest
3838
3939
- name: Wait for the application to be ready
4040
run: |
4141
echo "Waiting for the application to start..."
4242
for i in {1..10}; do
4343
curl -s http://localhost:8080 && echo "Application is up!" && break
4444
echo "Retrying in 3 seconds..."
45-
echo "Container logs:"
46-
docker logs grandnode2-container --tail 20
4745
sleep 3
4846
done
4947
@@ -72,7 +70,7 @@ jobs:
7270
run: |
7371
echo "Waiting for the application to start..."
7472
for i in {1..10}; do
75-
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -L http://localhost:8080 || echo "error")
73+
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080 || echo "error")
7674
if [ "$RESPONSE" = "200" ]; then
7775
echo "Application is up with HTTP 200 response!"
7876
exit 0
@@ -81,21 +79,12 @@ jobs:
8179
else
8280
echo "Received HTTP response code: $RESPONSE. Retrying in 3 seconds..."
8381
fi
84-
echo "Container logs:"
85-
docker logs grandnode2-container --tail 30
8682
sleep 3
8783
done
8884
echo "Application did not start successfully. Final response code: $RESPONSE"
8985
exit 1
90-
91-
- name: Show container logs
92-
run: |
93-
echo "=== Full container logs ==="
94-
docker logs grandnode2-container
95-
echo "=== Container status ==="
96-
docker inspect grandnode2-container --format='{{.State.Status}} - Exit: {{.State.ExitCode}}'
9786
9887
- name: Stop and remove the container
9988
run: |
10089
docker stop grandnode2-container
101-
docker rm grandnode2-container
90+
docker rm grandnode2-container

Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
2828

2929
EXPOSE 8080
3030
WORKDIR /app
31-
COPY --from=build-env /app/build/release .
31+
COPY --from=build-env --chown=app:app /app/build/release .
3232

33-
# Switch to the built-in non-root user
34-
RUN chown -R app:app /app
3533
USER app
3634

3735
ENTRYPOINT ["dotnet", "Grand.Web.dll"]

0 commit comments

Comments
 (0)