Skip to content

Commit

Permalink
docker: merge frontend and nginx containers
Browse files Browse the repository at this point in the history
  • Loading branch information
PoustouFlan committed Aug 17, 2024
1 parent e54f129 commit 3a24d2d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 105 deletions.
20 changes: 6 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,13 @@ services:
frontend:
build:
context: ./frontend
ports:
- "80"
networks:
- web

nginx:
image: nginx:alpine
container_name: crypto-drink-frontend-1
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/conf.d:/etc/nginx/conf.d
- ./nginx/letsencrypt:/etc/letsencrypt
ports:
- "80:80"
- "443:443"
- ./frontend/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./frontend/nginx/conf.d:/etc/nginx/conf.d
# ports:
# - "80"
depends_on:
- frontend
- backend
networks:
- web
Expand All @@ -63,6 +54,7 @@ services:

networks:
web:
external: true

volumes:
postgres_data:
Expand Down
1 change: 0 additions & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ FROM nginx:alpine

# Copy built files from the previous stage
COPY --from=build /app/dist /usr/share/nginx/html
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf

# Expose port 80 to the outside world
EXPOSE 80
Expand Down
37 changes: 37 additions & 0 deletions frontend/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
server {
listen 80;
server_name crypto-drink.com;

return 301 https://www.crypto-drink.com$request_uri;
}

server {
listen 80;
server_name www.crypto-drink.com;

# location / {
# proxy_pass http://frontend:80;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# }
location / {
root /usr/share/nginx/html;
try_files $uri /index.html;
}


location /.well-known/acme-challenge/ {
allow all;
}

location /api/ {
proxy_pass http://backend:8080/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

25 changes: 0 additions & 25 deletions frontend/nginx/default.conf

This file was deleted.

File renamed without changes.
65 changes: 0 additions & 65 deletions nginx/conf.d/crypto-drink.conf

This file was deleted.

0 comments on commit 3a24d2d

Please sign in to comment.