Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
Updated Dockerfiles and docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
HarbourHeading committed Aug 3, 2024
1 parent 0afd5e9 commit cc5708f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
1 change: 1 addition & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM python:3.10-alpine

WORKDIR /backend

RUN pip3 install --upgrade pip
COPY requirements.txt .
RUN pip3 install -r requirements.txt

Expand Down
43 changes: 24 additions & 19 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
services:
server:
nginx:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: nginx
ports:
- "80:80"
depends_on:
- backend
networks:
- app-network

backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: backend
ports:
expose:
- "5000:5000"
labels:
- "database=mongodb"
Expand All @@ -15,32 +27,25 @@ services:
- DATABASE_ROOT_USERNAME=$DATABASE_ROOT_USERNAME
- DATABASE_ROOT_PASSWORD=$DATABASE_ROOT_PASSWORD
- DATABASE_NAME=$DATABASE_NAME
depends_on:
- mongodb

client:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: frontend
ports:
- "80:80"
depends_on:
- server
networks:
- app-network

mongodb:
database:
image: mongo:latest
container_name: database
ports:
- "27017:27017"
env_file: .env
environment:
- MONGO_INITDB_ROOT_USERNAME=$DATABASE_ROOT_USERNAME
- MONGO_INITDB_ROOT_PASSWORD=$DATABASE_ROOT_PASSWORD
- MONGO_INITDB_DATABASE=$DATABASE_NAME
ports:
- "27017:27017"
volumes:
- ./data/db:/data/db
- ./data/docker-entrypoint-initdb.d/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
networks:
- app-network

volumes:
db:
networks:
app-network:
driver: bridge
2 changes: 1 addition & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN npm run build

FROM nginx:1.25.2-alpine-slim

COPY --from=builder dist /usr/share/nginx/html
COPY --from=builder frontend/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80
Expand Down
7 changes: 2 additions & 5 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
server {
listen 80;

server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}

location /api {
location /api/ {
proxy_pass http://backend:5000;
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;
}

}
}

0 comments on commit cc5708f

Please sign in to comment.