Skip to content

Commit 3ed4c66

Browse files
committed
add Dockerfile
1 parent aeb92cf commit 3ed4c66

2 files changed

Lines changed: 122 additions & 0 deletions

File tree

backend/.dockerignore

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
env/
8+
venv/
9+
.venv/
10+
pip-log.txt
11+
pip-delete-this-directory.txt
12+
.pytest_cache/
13+
.coverage
14+
htmlcov/
15+
dist/
16+
build/
17+
*.egg-info/
18+
19+
# IDEs
20+
.vscode/
21+
.idea/
22+
*.swp
23+
*.swo
24+
*~
25+
26+
# OS
27+
.DS_Store
28+
Thumbs.db
29+
30+
# Git
31+
.git/
32+
.gitignore
33+
.gitattributes
34+
35+
# Docker
36+
Dockerfile
37+
docker-compose.yml
38+
.dockerignore
39+
40+
# Documentation
41+
docs/
42+
*.md
43+
!README.md
44+
45+
# Tests
46+
tests/
47+
.pytest_cache/
48+
49+
# Data
50+
data/
51+
storage/
52+
*.db
53+
*.sqlite
54+
55+
# Config (will be mounted)
56+
config/
57+
.env
58+
.env.*
59+
60+
# CI/CD
61+
.github/
62+
.gitlab-ci.yml

backend/Dockerfile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
FROM python:3.13-slim as builder
2+
3+
ENV PYTHONUNBUFFERED=1 \
4+
PYTHONDONTWRITEBYTECODE=1 \
5+
PIP_NO_CACHE_DIR=1 \
6+
PIP_DISABLE_PIP_VERSION_CHECK=1 \
7+
POETRY_VERSION=1.8.2 \
8+
POETRY_HOME="/opt/poetry" \
9+
POETRY_NO_INTERACTION=1 \
10+
POETRY_VIRTUALENVS_IN_PROJECT=true \
11+
POETRY_VIRTUALENVS_CREATE=true
12+
13+
RUN apt-get update && apt-get install -y --no-install-recommends \
14+
build-essential \
15+
curl \
16+
&& rm -rf /var/lib/apt/lists/*
17+
18+
RUN curl -sSL https://install.python-poetry.org | python3 - \
19+
&& ln -s /opt/poetry/bin/poetry /usr/local/bin/poetry
20+
21+
WORKDIR /app
22+
23+
COPY pyproject.toml poetry.lock ./
24+
25+
RUN poetry install --no-dev --no-root --no-interaction --no-ansi
26+
27+
FROM python:3.13-slim as runtime
28+
29+
ENV PYTHONUNBUFFERED=1 \
30+
PYTHONDONTWRITEBYTECODE=1 \
31+
PATH="/app/.venv/bin:$PATH" \
32+
ENCRYPTED_NOTES_CONFIG_DIR="/data/config" \
33+
ENCRYPTED_NOTES_STORAGE_DIR="/data/storage"
34+
35+
RUN apt-get update && apt-get install -y --no-install-recommends \
36+
libpq5 \
37+
&& rm -rf /var/lib/apt/lists/*
38+
39+
RUN groupadd -r appuser && useradd -r -g appuser appuser
40+
41+
WORKDIR /app
42+
43+
COPY --from=builder /app/.venv /app/.venv
44+
45+
COPY encrypted_notes ./encrypted_notes
46+
COPY pyproject.toml poetry.lock README.md ./
47+
48+
RUN mkdir -p /data/config /data/storage && \
49+
chown -R appuser:appuser /app /data
50+
51+
USER appuser
52+
53+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
54+
CMD python -c "import requests; requests.get('http://localhost:8000/health', timeout=5)" || exit 1
55+
56+
# Expose port
57+
EXPOSE 8000
58+
59+
# Default command - Run API server
60+
CMD ["python", "-m", "encrypted_notes.api"]

0 commit comments

Comments
 (0)