Skip to content

Commit e8af951

Browse files
authored
Merge pull request #219 from 0xPolygonID/DEVOPS-1
DEVOPS-1 Fix variables missing with ECR
2 parents 054142c + 5bc4805 commit e8af951

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

.github/workflows/deployment_new_aws_account.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
role-session-name: GithubActionsSession
3434

3535
- name: Login to Amazon ECR
36+
id: login-ecr
3637
uses: aws-actions/amazon-ecr-login@v1
3738

3839
- name: Install dependencies
@@ -48,12 +49,17 @@ jobs:
4849
- name: Build
4950
run: npm run build
5051

52+
- name: Set ECR registry
53+
run: echo "ECR_REGISTRY=${{ steps.login-ecr.outputs.registry }}" >> $GITHUB_ENV
54+
5155
- name: Build, tag, and push image to Amazon ECR
5256
id: build-image
5357
env:
54-
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
58+
ECR_REGISTRY: ${{ env.ECR_REGISTRY }}
5559
IMAGE_TAG: ${{ github.sha }}
5660
run: |
61+
echo "Using ECR_REGISTRY=$ECR_REGISTRY"
62+
echo "Using IMAGE_TAG=$IMAGE_TAG"
5763
docker build --cache-from $ECR_REGISTRY/$ECR_REPOSITORY:latest -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
5864
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
5965
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT

Dockerfile

+23-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
1-
#Serve the app with NGINX
2-
FROM nginx:alpine
1+
# Use a specific version of nginx for better reproducibility
2+
FROM nginx:1.25.3-alpine
33

4-
# Copy the build files from the build folder to /usr/share/nginx/html
5-
COPY build /usr/share/nginx/html
4+
# Add a non-root user for security
5+
RUN adduser -D -H -u 1001 nginxuser && \
6+
chown -R nginxuser:nginxuser /usr/share/nginx/html && \
7+
chown -R nginxuser:nginxuser /var/cache/nginx && \
8+
touch /var/run/nginx.pid && \
9+
chown -R nginxuser:nginxuser /var/run/nginx.pid
610

7-
#Replace default nginx.conf with custom configuration
8-
COPY nginx.conf /etc/nginx/conf.d/default.conf
11+
# Copy files with specific ownership
12+
COPY --chown=nginxuser:nginxuser build /usr/share/nginx/html
13+
COPY --chown=nginxuser:nginxuser nginx.conf /etc/nginx/conf.d/default.conf
914

10-
# Expose the desired port (default is 80 for NGINX)
15+
# Set working directory
16+
WORKDIR /usr/share/nginx/html
17+
18+
# Switch to non-root user
19+
USER nginxuser
20+
21+
# Expose port
1122
EXPOSE 80
1223

13-
# Start NGINX
24+
# Use exec form of CMD for better signal handling
1425
CMD ["nginx", "-g", "daemon off;"]
26+
27+
# Add healthcheck
28+
HEALTHCHECK --interval=30s --timeout=3s \
29+
CMD wget --quiet --tries=1 --spider http://localhost:80/ || exit 1

0 commit comments

Comments
 (0)