-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.prod
45 lines (33 loc) · 1.42 KB
/
Dockerfile.prod
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
FROM python:3.12.0a4-alpine3.16
# Set environment variables
ENV PYTHONUNBUFFERED 1
# Create a directory for the application
RUN mkdir /backend
WORKDIR /backend
COPY ["./requirements/requirements-prod.txt", "/tmp/"]
# Install build dependencies
# postgresql-dev installs the PostgreSQL development libraries, which are needed by the psycopg2 package, a PostgreSQL adapter for Python.
# gcc, musl-dev, libc-dev are used to compile and build native extensions for python packages.
# jpeg-dev, zlib-dev are required to install python packages that have C extensions.
RUN apk update \
&& apk add postgresql-dev \
gcc \
musl-dev \
libc-dev \
jpeg-dev \
zlib-dev \
&& pip install --no-cache-dir --extra-index-url https://alpine-wheels.github.io/index -r /tmp/requirements-prod.txt
# Collect static files
# Django uses the collectstatic management command to gather all of the static files from all of the installed apps and any other static files that are located in the STATIC_ROOT directory specified in the settings file, and copy them to a single directory that can be served by a web server.
# RUN python manage.py collectstatic --noinput
# Expose the port 8000
EXPOSE 8000
# Copy code
COPY ./todo_project /backend/todo_project
# Copy the shell script
COPY ./startup.bash /backend
COPY ./wait_for_db.py /backend
# Make the shell script executable
RUN chmod +x /backend/startup.bash
# Run
CMD ["/backend/startup.bash"]