Skip to content

Commit

Permalink
Adding port customization at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
rkorytkowski committed Jan 13, 2021
1 parent eaa9580 commit 5a37b29
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Expand Up @@ -34,6 +34,8 @@ CMD ["bash", "-c", "./start.sh"]
# Stage-2 Production Environment
FROM nginx:1.19-alpine

ENV PORT=${PORT:-4000}

# Add bash
RUN apk add --no-cache bash

Expand All @@ -44,10 +46,10 @@ RUN chmod +x start-prod.sh
COPY --from=build /app/dist/ /usr/share/nginx/html/

# Copy nginx configuration
ADD ngnix /etc/nginx/conf.d/
ADD ngnix /etc/nginx/templates/

# Make port 4000 available to the world outside the container
EXPOSE 4000
# Make port available to the world outside the container
EXPOSE ${PORT}

# Start the server
CMD ["bash", "-c", "/start-prod.sh"]
2 changes: 0 additions & 2 deletions docker-compose.override.yml
Expand Up @@ -15,5 +15,3 @@ services:
restart: on-failure
volumes:
- .:/app:z
environment:
- PORT=${PORT-4000}
1 change: 1 addition & 0 deletions docker-compose.yml
Expand Up @@ -13,3 +13,4 @@ services:
environment:
- API_URL=${API_URL-http://127.0.0.1:8000}
- NODE_ENV=${NODE_ENV-development}
- PORT=4000
2 changes: 1 addition & 1 deletion ngnix/default.conf → ngnix/default.conf.template
@@ -1,5 +1,5 @@
server {
listen 4000;
listen ${PORT};
server_name localhost;
location / {
root /usr/share/nginx/html;
Expand Down

0 comments on commit 5a37b29

Please sign in to comment.