From 4bf75fdfe4052683399e3e14f7fabf8fdd7a5249 Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Sun, 2 Aug 2026 05:10:30 +0500 Subject: [PATCH] update compose for monorepo --- .build/dev/Dockerfile | 13 +++++++++++++ .build/prod/api.Dockerfile | 13 ------------- .build/prod/compose.yml | 13 ------------- .build/prod/entrypoint.sh | 14 -------------- .build/prod/nginx.Dockerfile | 11 ----------- .build/prod/nginx.conf | 26 ------------------------- compose.yml | 34 +++++++++++++++++++++++++++++++++ docker-compose.yml | 37 ------------------------------------ 8 files changed, 47 insertions(+), 114 deletions(-) create mode 100644 .build/dev/Dockerfile delete mode 100644 .build/prod/api.Dockerfile delete mode 100644 .build/prod/compose.yml delete mode 100755 .build/prod/entrypoint.sh delete mode 100644 .build/prod/nginx.Dockerfile delete mode 100644 .build/prod/nginx.conf create mode 100644 compose.yml delete mode 100644 docker-compose.yml diff --git a/.build/dev/Dockerfile b/.build/dev/Dockerfile new file mode 100644 index 0000000..18aff48 --- /dev/null +++ b/.build/dev/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.12-slim + +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 + +WORKDIR /app + +# Source is bind-mounted at runtime; (re)install deps on start so +# requirements.txt changes are picked up without a rebuild, then run the +# Django autoreloading dev server. +CMD pip install --no-cache-dir -r requirements.txt \ + && python manage.py migrate \ + && python manage.py runserver 0.0.0.0:5000 diff --git a/.build/prod/api.Dockerfile b/.build/prod/api.Dockerfile deleted file mode 100644 index ac3db7c..0000000 --- a/.build/prod/api.Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM python:3.11.4-slim-buster - -WORKDIR /var/www/html/ - -COPY . . - -RUN pip install -r requirements.txt - -RUN python3 manage.py collectstatic - -VOLUME /var/www/html/staticfiles/ - -CMD gunicorn apibase.wsgi:application --bind 0.0.0.0:5000 --workers=4 diff --git a/.build/prod/compose.yml b/.build/prod/compose.yml deleted file mode 100644 index 2cbb482..0000000 --- a/.build/prod/compose.yml +++ /dev/null @@ -1,13 +0,0 @@ -services: - api: - build: - context: ../../ - dockerfile: .build/prod/api.Dockerfile - hostname: sarlink-portal-api - image: git.shihaam.dev/sarlink/sarlink-portal-api/api - nginx: - build: - context: . - dockerfile: ./nginx.Dockerfile - hostname: sarlink-portal-api-nginx - image: git.shihaam.dev/sarlink/sarlink-portal-api/nginx diff --git a/.build/prod/entrypoint.sh b/.build/prod/entrypoint.sh deleted file mode 100755 index 278a322..0000000 --- a/.build/prod/entrypoint.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -if [ "$DATABASE" = "postgres" ] -then - echo "Waiting for postgres..." - - while ! nc -z $POSTGRES_HOST $POSTGRES_PORT; do - sleep 0.1 - done - - echo "PostgreSQL started" -fi - -exec "$@" \ No newline at end of file diff --git a/.build/prod/nginx.Dockerfile b/.build/prod/nginx.Dockerfile deleted file mode 100644 index 52e6e98..0000000 --- a/.build/prod/nginx.Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM nginx - -# Install basic tools -RUN apt update \ - && apt install curl nano iputils-ping zip unzip -y --no-install-recommends \ - && apt auto-remove -y \ - && apt clean -y - -COPY nginx.conf /etc/nginx/conf.d/default.conf - -WORKDIR /etc/nginx diff --git a/.build/prod/nginx.conf b/.build/prod/nginx.conf deleted file mode 100644 index 4419ce1..0000000 --- a/.build/prod/nginx.conf +++ /dev/null @@ -1,26 +0,0 @@ -server { - listen 80; - - server_name _; - access_log /dev/stdout; - error_log /dev/stdout info; - - # Serve static files - location /static/ { - alias /var/www/html/staticfiles/; - } - location /media/ { - alias /var/www/html/media/; - } - - - # Forward requests to Gunicorn - location / { - proxy_pass http://portal-api: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; - client_max_body_size 6M; - } -} diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..99f9d2e --- /dev/null +++ b/compose.yml @@ -0,0 +1,34 @@ +services: + backend: + build: + context: .build/dev + hostname: backend + volumes: + - ./:/app + ports: + - 5000:5000 + env_file: + - .env + depends_on: + database: + condition: service_healthy + + database: + image: postgres:16 + hostname: database + environment: + POSTGRES_DB: ${POSTGRES_DATABASE:-sarlink} + POSTGRES_USER: ${POSTGRES_USER:-sarlink} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme} + volumes: + - pgdata:/var/lib/postgresql/data + ports: + - 5432:5432 + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER:-sarlink}"] + interval: 5s + timeout: 3s + retries: 10 + +volumes: + pgdata: diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index dcf61c5..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,37 +0,0 @@ -services: - api: - build: - context: . - restart: always - command: gunicorn apibase.wsgi:application --bind 0.0.0.0:5000 --workers=2 - volumes: - - /home//docker/council-api/staticfiles:/home/app/api/staticfiles - ports: - - 5000:5000 - env_file: - - ./.env - depends_on: - - db - - redis - - db: - image: postgres:15 - restart: always - volumes: - - ./postgres_data:/var/lib/postgresql/data/ - env_file: - - ./.env - environment: - - POSTGRES_USER=${POSTGRES_USER} - - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} - - POSTGRES_DB=${POSTGRES_DATABASE} - ports: - - 5232:5432 - - redis: - image: "redis:alpine" - restart: always - expose: - - "6379" - -