forked from Kamva-Academy/Kamva-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.prod
40 lines (28 loc) · 985 Bytes
/
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
# Pull official base image
FROM python:3.11
# Set work directory
WORKDIR /usr/src/app
# Upgrade pip
RUN pip install --upgrade pip
# Copy requirements file
COPY requirements.txt /usr/src/requirements.txt
# Install dependencies
RUN pip install -r /usr/src/requirements.txt
# Copy entrypoint script
COPY ./entrypoint.prod.sh /usr/src/app/entrypoint.prod.sh
# Copy project files
COPY . /usr/src/app/
# Create a non-root user and set permissions
RUN adduser --disabled-password --gecos "" sepid && \
chown -R sepid:sepid /usr/src/app
# Create necessary directories and set permissions
RUN mkdir -p /usr/src/app/logging /usr/src/app/staticfiles /usr/src/app/media && \
chown -R sepid:sepid /usr/src/app/logging /usr/src/app/staticfiles /usr/src/app/media
# Make the entrypoint script executable
RUN chmod +x /usr/src/app/entrypoint.prod.sh
# Switch to non-root user
USER sepid
# Set entrypoint
ENTRYPOINT ["/usr/src/app/entrypoint.prod.sh"]
# Expose port 8000
EXPOSE 8000