-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
36 lines (27 loc) · 1.04 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
# Use the latest Amazon Linux image
FROM amazonlinux:latest
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Accept build-time environment variable to differentiate between dev and prod
ARG ENVIRONMENT=prod
# Update the package list and install necessary packages
RUN dnf -y update && \
dnf -y install python3 python3-pip git iputils && \
dnf clean all
# Install pip packages
RUN pip3 install django boto3 django-storages psycopg2-binary gunicorn django-markdownx django-markdownify
# Create a non-root user
RUN adduser klaatubaradanikto
# Switch to the non-root user
USER klaatubaradanikto
# Set the working directory
WORKDIR /home/klaatubaradanikto
# Copy project into Docker container
COPY techronomicon /home/klaatubaradanikto
# Use a conditional statement to run different commands based on the environment
CMD if [ "$ENVIRONMENT" = "dev" ]; then \
python3 manage.py runserver 0.0.0.0:8000; \
else \
gunicorn --bind 0.0.0.0:8000 --timeout 600 techronomicon.wsgi:application; \
fi