This repository was archived by the owner on Jul 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
68 lines (55 loc) · 1.52 KB
/
Dockerfile
File metadata and controls
68 lines (55 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Use Python 3.13 slim image
FROM python:3.13-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install uv
RUN pip install --no-cache-dir uv
# Create a non-root user and group for security
RUN groupadd -r appuser && useradd -r -g appuser -s /sbin/nologin -c "Docker image user" appuser
WORKDIR /app
# Copy project files
COPY pyproject.toml uv.lock ./
# Install dependencies using uv
RUN uv pip install --no-cache-dir --system \
fastapi \
uvicorn[standard] \
gunicorn \
sqlmodel \
psycopg2-binary \
pydantic-settings \
alembic \
minio \
"python-jose[cryptography]" \
"passlib[bcrypt]" \
python-multipart \
"celery[redis]" \
redis \
flower \
python-dotenv \
email-validator \
sqlalchemy \
requests \
geoalchemy2 \
"shapely>=2.1.1" \
posthog \
moviepy
# Copy the application code
COPY . .
# Make celery scripts executable
RUN chmod +x celery_worker.py celery_beat.py
# Change ownership of the app directory to the non-root user
RUN chown -R appuser:appuser /app
# Switch to the non-root user
USER appuser
# Expose the port the app runs on
EXPOSE 8000
# Default command to run the application with Gunicorn
CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "app.main:app", "-w", "4", "-b", "0.0.0.0:8000"]