Teddy Xinyuan Chen commited on
Commit
65866d3
·
1 Parent(s): 0824581

Revert "2024-10-08T22-01-58Z"

Browse files

This reverts commit 0824581e63f3bb73d8f8ab167378e6252e30544f.

Files changed (1) hide show
  1. Dockerfile +21 -15
Dockerfile CHANGED
@@ -7,7 +7,9 @@ WORKDIR /app
7
  # Copy the current directory contents into the container at /app
8
  COPY . /app
9
 
10
- # Install any needed packages specified in requirements.txt
 
 
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
  # Make port 8000 available to the world outside this container
@@ -16,19 +18,23 @@ EXPOSE 8000
16
  # Set environment variables (non-sensitive)
17
  ENV DJANGO_SETTINGS_MODULE=quizsite.settings
18
  ENV STATIC_BACKEND=whitenoise.storage.CompressedManifestStaticFilesStorage
19
- ENV DEBUG=False
20
 
21
- # Create a script to read secrets and run the application
22
- RUN echo '#!/bin/bash\n\
23
- export DBHOST=$(cat /run/secrets/DBHOST)\n\
24
- export DBNAME=$(cat /run/secrets/DBNAME)\n\
25
- export DBUSER=$(cat /run/secrets/DBUSER)\n\
26
- export DBPASS=$(cat /run/secrets/DBPASS)\n\
27
- export DBSSL=$(cat /run/secrets/DBSSL)\n\
28
- export SECRET_KEY=$(cat /run/secrets/SECRET_KEY)\n\
29
- export OPENAI_API_KEY=$(cat /run/secrets/OPENAI_API_KEY)\n\
30
- python3 src/manage.py runserver 0.0.0.0:8000\n'\
31
- > /app/run.sh && chmod +x /app/run.sh
 
 
 
 
32
 
33
- # Run the script
34
- CMD ["/app/run.sh"]
 
7
  # Copy the current directory contents into the container at /app
8
  COPY . /app
9
 
10
+ # Install any needed packages specified in requirements-dev.txt
11
+ # RUN pip install --no-cache-dir -r requirements-dev.txt
12
+ # my frozen requirements.txt
13
  RUN pip install --no-cache-dir -r requirements.txt
14
 
15
  # Make port 8000 available to the world outside this container
 
18
  # Set environment variables (non-sensitive)
19
  ENV DJANGO_SETTINGS_MODULE=quizsite.settings
20
  ENV STATIC_BACKEND=whitenoise.storage.CompressedManifestStaticFilesStorage
21
+ ENV DEBUG=True
22
 
23
+ # Set environment variables (sensitive) using Hugging Face secrets management
24
+ RUN --mount=type=secret,id=DBHOST,mode=0444,required=true \
25
+ --mount=type=secret,id=DBNAME,mode=0444,required=true \
26
+ --mount=type=secret,id=DBUSER,mode=0444,required=true \
27
+ --mount=type=secret,id=DBPASS,mode=0444,required=true \
28
+ --mount=type=secret,id=DBSSL,mode=0444,required=true \
29
+ --mount=type=secret,id=SECRET_KEY,mode=0444,required=true \
30
+ --mount=type=secret,id=OPENAI_API_KEY,mode=0444,required=true \
31
+ export DBHOST=$(cat /run/secrets/DBHOST) && \
32
+ export DBNAME=$(cat /run/secrets/DBNAME) && \
33
+ export DBUSER=$(cat /run/secrets/DBUSER) && \
34
+ export DBPASS=$(cat /run/secrets/DBPASS) && \
35
+ export DBSSL=$(cat /run/secrets/DBSSL) && \
36
+ export SECRET_KEY=$(cat /run/secrets/SECRET_KEY) && \
37
+ export OPENAI_API_KEY=$(cat /run/secrets/OPENAI_API_KEY)
38
 
39
+ # Run the Django application
40
+ CMD ["python3", "src/manage.py", "runserver", "0.0.0.0:8000"]