Skip to content

Commit

Permalink
[PRMDR-464] (WIP) Remove hardcoded port number from nginx.conf and do…
Browse files Browse the repository at this point in the history
…cker related files
  • Loading branch information
joefong-nhs committed Dec 11, 2023
1 parent c2ea149 commit 7fd4287
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ REACT_APP_DOC_STORE_API_ENDPOINT=%DOC_STORE_API_ENDPOINT%
REACT_APP_AWS_REGION=%AWS_REGION%
REACT_APP_OIDC_PROVIDER_ID=%OIDC_PROVIDER_ID%
REACT_APP_ENVIRONMENT=%BUILD_ENV% # 'local'
REACT_APP_IMAGE_VERSION="%IMAGE_VERSION%"
REACT_APP_IMAGE_VERSION="%IMAGE_VERSION%"
CONTAINER_PORT=xx # Port number within the container. Needed for building the docker image
HOST_PORT=xxxx # Port number that the localhost listen to. Only need this if we run docker-compose
4 changes: 2 additions & 2 deletions app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ WORKDIR /usr/share/nginx/html
RUN rm -rf ./*
COPY --from=builder /app/build .
WORKDIR /etc/nginx
COPY --from=builder ./app/docker/nginx.conf .
EXPOSE 80
COPY --from=builder ./app/docker/nginx.conf ./nginx.conf.template
RUN cat nginx.conf.template | envsubst > ./nginx.conf
ENTRYPOINT ["nginx", "-g", "daemon off;"]
2 changes: 1 addition & 1 deletion app/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ services:
build:
context: .
ports:
- 8080:80
- "${HOST_PORT}:${CONTAINER_PORT}"
env_file:
- .env
2 changes: 1 addition & 1 deletion app/docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ events {
}
http {
server {
listen 80;
listen $CONTAINER_PORT;
add_header Strict-Transport-Security "max-age=63072000" always;
location / {
root /usr/share/nginx/html;
Expand Down

0 comments on commit 7fd4287

Please sign in to comment.