-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
43 lines (29 loc) · 1.06 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
# This Dockerfile is configured for general deployment.
#------- [Base] -------#
# Use the lightweight Python 3.8-slim base image
FROM python:3.8-slim
# Install system dependencies and clean up in a single RUN command
RUN apt-get update && \
#TODO: add postgresql libpq-dev later if needed
apt-get install -y gcc postgresql libpq-dev && \
rm -rf /var/lib/apt/lists/* && \
# Set up the Python virtual environment
python -m venv /opt/venv && \
chmod +x /opt/venv/bin/activate
ENV PATH="/opt/venv/bin:$PATH"
# Copy the requirements.txt file and install Python packages
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the application files
COPY . .
# Run collect static
RUN python manage.py collectstatic --noinput
# ------- [Non-Railway Specific] -------
# Expose the default Gunicorn port
EXPOSE 8000
# Copy the entrypoint script
COPY entrypoint.sh .
# Give the execution permissions to the entrypoint script
RUN chmod +x ./entrypoint.sh
# Run the entrypoint script when the container starts
CMD ["./entrypoint.sh"]