From e6d04f986f293e738a543ba4619cacd87d2f9e3b Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Fri, 12 Dec 2025 06:05:56 +0500 Subject: [PATCH] dev env --- .build/dev/nginx.Dockerfile | 5 ++++ .build/dev/nginx.conf | 30 +++++++++++++++++++ .build/dev/node.Dockerfile | 5 ++++ .build/dev/python.Dockerfile | 7 +++++ compose.yml | 56 ++++++++++++++++++++++++++++++++++++ 5 files changed, 103 insertions(+) create mode 100644 .build/dev/nginx.Dockerfile create mode 100644 .build/dev/nginx.conf create mode 100644 .build/dev/node.Dockerfile create mode 100644 .build/dev/python.Dockerfile create mode 100644 compose.yml diff --git a/.build/dev/nginx.Dockerfile b/.build/dev/nginx.Dockerfile new file mode 100644 index 0000000..0303679 --- /dev/null +++ b/.build/dev/nginx.Dockerfile @@ -0,0 +1,5 @@ +FROM nginx + +COPY .build/dev/nginx.conf /etc/nginx/conf.d/default.conf + +WORKDIR /etc/nginx diff --git a/.build/dev/nginx.conf b/.build/dev/nginx.conf new file mode 100644 index 0000000..4a47885 --- /dev/null +++ b/.build/dev/nginx.conf @@ -0,0 +1,30 @@ +server { + listen 80; + + server_name _; + access_log /dev/stdout; + error_log /dev/stdout info; + + location /api/ { + proxy_pass http://backend:8000/api/; + } + + location /ws/ { + proxy_pass http://backend:8000/ws/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + + location / { + # In development, proxy to Vite dev server + proxy_pass http://frontend:3000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + 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; + } +} diff --git a/.build/dev/node.Dockerfile b/.build/dev/node.Dockerfile new file mode 100644 index 0000000..4e42054 --- /dev/null +++ b/.build/dev/node.Dockerfile @@ -0,0 +1,5 @@ +FROM node:24-bookworm-slim + +WORKDIR /var/www/html/public + +CMD npm run dev -- --host 0.0.0.0 diff --git a/.build/dev/python.Dockerfile b/.build/dev/python.Dockerfile new file mode 100644 index 0000000..74798ca --- /dev/null +++ b/.build/dev/python.Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.4-slim-buster + +WORKDIR /var/www/html/ + +COPY requirements.txt . + +RUN pip install -r requirements.txt diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..757be5a --- /dev/null +++ b/compose.yml @@ -0,0 +1,56 @@ +services: + python: + build: + context: . + dockerfile: .build/dev/python.Dockerfile + hostname: backend + restart: always + command: uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 + volumes: + - ./:/var/www/html + env_file: + - .env + depends_on: + - postgres + + node: + build: + context: . + dockerfile: .build/dev/node.Dockerfile + hostname: frontend + restart: always + volumes: + - ./:/var/www/html + env_file: + - .env + + nginx: + build: + context: . + dockerfile: .build/dev/nginx.Dockerfile + hostname: nginx + restart: always + ports: + - "8000:80" + volumes: + - ./:/var/www/html + depends_on: + - python + - node + + postgres: + image: postgis/postgis:15-3.3 + hostname: database + restart: always + environment: + POSTGRES_USER: mapmaker + POSTGRES_PASSWORD: mapmaker + POSTGRES_DB: mapmaker + volumes: + - postgres_data:/var/lib/postgresql/data + ports: + - "5432:5432" + +volumes: + postgres_data: + driver: local