-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
47 lines (34 loc) · 1.18 KB
/
Dockerfile
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
# Use Python 3.12 slim base image
FROM python:3.12-slim
# Set basic environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
DJANGO_SETTINGS_MODULE=elektrum.settings \
SECURE_SSL_REDIRECT=False
WORKDIR /app
# Install system dependencies first - these rarely change
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libpq5 \
&& rm -rf /var/lib/apt/lists/*
# Install poetry - this rarely changes
RUN pip install poetry \
&& poetry config virtualenvs.create false
# Copy just the dependency files first
COPY pyproject.toml poetry.lock ./
# Install Python dependencies - this only reruns if dependencies change
RUN poetry install --only main
RUN mkdir -p /app/application/staticfiles
# Copy application code - this changes frequently
COPY application application/
COPY docker/entrypoint.sh /entrypoint.sh
# Make entrypoint script executable
RUN chmod +x /entrypoint.sh
# Set working directory to application folder
WORKDIR /app/application
# Expose port 8080
EXPOSE 8080
# Use entrypoint script
ENTRYPOINT ["/entrypoint.sh"]
# Start Gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--workers", "3", "elektrum.wsgi:application"]