-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
43 lines (32 loc) · 1.31 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
# Use the official Python image from the Docker Hub
FROM python:3.10
# Set the working directory in the container
WORKDIR /app
# Copy the requirements file into the container
COPY requirements.txt /app/
# Install the dependencies
RUN pip install -r requirements.txt
# Copy the entire project into the container
COPY . /app/
# Set environment variables
ENV EMAIL_HOST=${EMAIL_HOST}
ENV EMAIL_HOST_USER=${EMAIL_HOST_USER}
ENV EMAIL_HOST_PASSWORD=${EMAIL_HOST_PASSWORD}
ENV DJANGO_SECRET_KEY=${DJANGO_SECRET_KEY}
# Set environment variables for Django settings and superuser creation
ENV DJANGO_SETTINGS_MODULE=alumni.settings
ENV DJANGO_SUPERUSER_FIRST_NAME="Oleg"
ENV DJANGO_SUPERUSER_LAST_NAME="Milashkin"
ENV DJANGO_SUPERUSER_EMAIL="[email protected]"
ENV DJANGO_SUPERUSER_PASSWORD="admin"
# Collect static files
RUN python alumni/manage.py collectstatic --noinput
# Make migrations and migrate the database
RUN python alumni/manage.py makemigrations --noinput && \
python alumni/manage.py migrate --noinput
# Create superuser
RUN python alumni/manage.py createsuperuser --noinput --email $DJANGO_SUPERUSER_EMAIL --first_name $DJANGO_SUPERUSER_FIRST_NAME --last_name $DJANGO_SUPERUSER_LAST_NAME
# Expose the port the app runs on
EXPOSE 8000
# Run the app
CMD ["python", "alumni/manage.py", "runserver", "0.0.0.0:8000"]