Added local compose for dev environment

This commit is contained in:
Viswamedha Nalabotu 2026-01-18 14:28:21 +00:00
parent 4665c0a203
commit 72440946f6
4 changed files with 124 additions and 0 deletions

View file

@ -0,0 +1,23 @@
FROM python:3.12-bookworm
RUN apt-get update && apt-get install --no-install-recommends -y \
build-essential \
libpq-dev \
wait-for-it \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
ENV VIRTUAL_ENV=/venv \
PATH=/venv/bin:$PATH
RUN python -m venv /venv
WORKDIR /app
COPY requirements/django.txt .
RUN pip install --no-cache-dir --requirement django.txt
COPY ./compose/dev/django/start /start
RUN sed -i 's/\r$//g' /start && chmod +x /start
CMD ["/start"]

27
compose/dev/django/start Normal file
View file

@ -0,0 +1,27 @@
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
DB_HOST="${POSTGRES_HOST}"
DB_PORT="${POSTGRES_PORT}"
echo "Waiting for database at ${DB_HOST}:${DB_PORT}..."
wait-for-it ${DB_HOST}:${DB_PORT} --timeout=30 --strict || {
echo "Timed out waiting for database" >&2
exit 1
}
echo "Database is available, continuing startup..."
python manage.py makemigrations
python manage.py migrate --noinput
for fixture in /app/data/*.json; do
echo "Loading fixture: $fixture"
python manage.py loaddata "$fixture"
done
python manage.py collectstatic --noinput
exec daphne -b 0.0.0.0 -p 8000 config.asgi:application

View file

@ -0,0 +1,59 @@
services:
fyp-django:
container_name: fyp-django-dev
build:
context: ../../
dockerfile: compose/dev/django/Dockerfile
env_file:
- ../../.env
volumes:
- ../../:/app
ports:
- '0.0.0.0:8000:8000'
depends_on:
fyp-postgres-dev:
condition: service_healthy
fyp-node-dev:
condition: service_started
fyp-node-dev:
container_name: fyp-node-dev
build:
context: ../../
dockerfile: compose/dev/node/Dockerfile
environment:
NODE_ENV: development
CHOKIDAR_USEPOLLING: 'true'
stdin_open: true
volumes:
- ../../src:/app/src:delegated
- ../../index.html:/app/index.html:delegated
- ../../vite.config.ts:/app/vite.config.ts:delegated
- ../../tsconfig.json:/app/tsconfig.json:delegated
- ../../build:/app/build:delegated
- ../../package.json:/app/package.json:delegated
- ../../package-lock.json:/app/package-lock.json:delegated
- /app/node_modules
ports:
- '0.0.0.0:5173:5173'
fyp-postgres-dev:
container_name: fyp-postgres-dev
image: postgres:15-alpine
env_file:
- ../../.env
environment:
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- '0.0.0.0:5432:5432'
healthcheck:
test: ['CMD-SHELL', "pg_isready -h 127.0.0.1 -p 5432 -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 5s
timeout: 3s
retries: 5
volumes:
postgres_data:

View file

@ -0,0 +1,15 @@
FROM node:22-bullseye
WORKDIR /app
COPY package*.json ./
RUN npm ci && npm cache clean --force
COPY src ./src
COPY index.html .
COPY vite.config.* .
COPY tsconfig.* .
EXPOSE 5173
CMD ["npm", "run", "devwatch"]