File size: 1,118 Bytes
ce884e7
 
 
 
 
 
 
 
 
0824581
455f76e
ce884e7
 
 
 
 
 
 
0824581
ce884e7
0824581
 
 
 
 
 
 
 
 
 
 
ce884e7
0824581
 
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
# Use the official Python 3.11 image from the Docker Hub
FROM python:3.11

# Set the working directory in the container
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Make port 8000 available to the world outside this container
EXPOSE 8000

# Set environment variables (non-sensitive)
ENV DJANGO_SETTINGS_MODULE=quizsite.settings
ENV STATIC_BACKEND=whitenoise.storage.CompressedManifestStaticFilesStorage
ENV DEBUG=False

# Create a script to read secrets and run the application
RUN echo '#!/bin/bash\n\
export DBHOST=$(cat /run/secrets/DBHOST)\n\
export DBNAME=$(cat /run/secrets/DBNAME)\n\
export DBUSER=$(cat /run/secrets/DBUSER)\n\
export DBPASS=$(cat /run/secrets/DBPASS)\n\
export DBSSL=$(cat /run/secrets/DBSSL)\n\
export SECRET_KEY=$(cat /run/secrets/SECRET_KEY)\n\
export OPENAI_API_KEY=$(cat /run/secrets/OPENAI_API_KEY)\n\
python3 src/manage.py runserver 0.0.0.0:8000\n'\
> /app/run.sh && chmod +x /app/run.sh

# Run the script
CMD ["/app/run.sh"]