Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Git
.git
.gitignore
.github

# Documentation
README.md
CONTRIBUTING.md
SECURITY.md
LICENSE
screenshots/

# Build and environment
*.log
*.pyc
__pycache__/
*.py[cod]
*$py.class
.Python
build/
dist/
*.egg-info/
.eggs/
*.egg

# Virtual environments
.env
.venv
env/
venv/
ENV/

# IDE and editor files
.vscode/
.idea/
*.swp
*.swo
.DS_Store

# Testing and coverage
.tox/
.coverage
.coverage.*
.cache/
.pytest_cache/
htmlcov/
coverage.xml
nosetests.xml

# Terraform (infrastructure code not needed in app container)
terraform/

# Database (will be created at runtime)
db.sqlite3
*.sqlite3

# BOM files (not needed for runtime)
bom.json
bom.vex.json

# Storage JSON files (generated at runtime)
storage/*.json
41 changes: 22 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
FROM alpine:latest
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
FROM python:3.11-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

RUN apk add --no-cache python3 && \
python3 -m venv $VIRTUAL_ENV && \
python3 -m ensurepip && \
pip3 install --upgrade pip setuptools && \
if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi

COPY . /app
WORKDIR /app

# install psycopg2 dependencies
RUN apk update \
&& apk add postgresql-dev gcc python3-dev musl-dev postgresql-libs zlib-dev jpeg-dev harfbuzz-dev postgresql zlib jpeg
# Install system dependencies in a single layer
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libpq5 \
&& rm -rf /var/lib/apt/lists/*

# Copy only requirements first for better layer caching
COPY requirements.txt .

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY . .

RUN pip install psycopg2 Pillow
RUN pip3 install -r requirements.txt
RUN python manage.py makemigrations
RUN python manage.py migrate
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
# Run migrations at container startup, not build time
# Note: For production with multiple replicas, use a separate migration job
CMD ["sh", "-c", "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"]
Loading