BloodyInside commited on
Commit
78127da
·
1 Parent(s): 7515752
Files changed (1) hide show
  1. Dockerfile +26 -15
Dockerfile CHANGED
@@ -6,6 +6,27 @@ FROM python:${PYTHON_VERSION}
6
  ENV PYTHONDONTWRITEBYTECODE 1
7
  ENV PYTHONUNBUFFERED 1
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  # Install dependencies
10
  RUN apt-get update && apt-get install -y \
11
  libpq-dev \
@@ -31,10 +52,13 @@ RUN CHROMEDRIVER_VERSION=$(curl -sS chromedriver.storage.googleapis.com/LATEST_R
31
  && wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip \
32
  && unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/
33
 
34
- RUN useradd -m -u 1000 user
 
35
  USER user
36
  ENV PATH="/home/user/.local/bin:$PATH"
37
 
 
 
38
  # Install Python dependencies
39
  COPY --chown=user requirements.txt /tmp/requirements.txt
40
  RUN pip install --no-cache-dir --upgrade pip \
@@ -44,20 +68,7 @@ RUN pip install --no-cache-dir --upgrade pip \
44
  COPY --chown=user . /code
45
  WORKDIR /code
46
 
47
- # Use secrets during build
48
- RUN --mount=type=secret,id=HOST,required=true \
49
- --mount=type=secret,id=DJANGO_SECRET,required=true \
50
- --mount=type=secret,id=SECURE_TOKEN,required=true \
51
- --mount=type=secret,id=WORKER_TOKEN,required=true \
52
- --mount=type=secret,id=CLOUDFLARE_TURNSTILE_SECRET,required=true \
53
- --mount=type=secret,id=REDIS_URL,required=true \
54
- bash -c 'export HOST=$(cat /run/secrets/HOST) && \
55
- export DJANGO_SECRET=$(cat /run/secrets/DJANGO_SECRET) && \
56
- export SECURE_TOKEN=$(cat /run/secrets/SECURE_TOKEN) && \
57
- export WORKER_TOKEN=$(cat /run/secrets/WORKER_TOKEN) && \
58
- export CLOUDFLARE_TURNSTILE_SECRET=$(cat /run/secrets/CLOUDFLARE_TURNSTILE_SECRET) && \
59
- export REDIS_URL=$(cat /run/secrets/REDIS_URL) && \
60
- python manage.py makemigrations && \
61
  python manage.py migrate --database=default && \
62
  python manage.py migrate --database=cache && \
63
  python manage.py migrate --database=DB1 && \
 
6
  ENV PYTHONDONTWRITEBYTECODE 1
7
  ENV PYTHONUNBUFFERED 1
8
 
9
+ RUN useradd -m -u 1000 user
10
+
11
+ RUN --mount=type=secret,id=HOST,required=true \
12
+ --mount=type=secret,id=DJANGO_SECRET,required=true \
13
+ --mount=type=secret,id=SECURE_TOKEN,required=true \
14
+ --mount=type=secret,id=WORKER_TOKEN,required=true \
15
+ --mount=type=secret,id=CLOUDFLARE_TURNSTILE_SECRET,required=true \
16
+ --mount=type=secret,id=REDIS_URL,required=true
17
+
18
+ # Create a script to export secrets as environment variables
19
+ RUN echo 'export HOST=$(cat /run/secrets/HOST)' >> /etc/profile.d/secrets.sh && \
20
+ echo 'export DJANGO_SECRET=$(cat /run/secrets/DJANGO_SECRET)' >> /etc/profile.d/secrets.sh && \
21
+ echo 'export SECURE_TOKEN=$(cat /run/secrets/SECURE_TOKEN)' >> /etc/profile.d/secrets.sh && \
22
+ echo 'export WORKER_TOKEN=$(cat /run/secrets/WORKER_TOKEN)' >> /etc/profile.d/secrets.sh && \
23
+ echo 'export CLOUDFLARE_TURNSTILE_SECRET=$(cat /run/secrets/CLOUDFLARE_TURNSTILE_SECRET)' >> /etc/profile.d/secrets.sh && \
24
+ echo 'export REDIS_URL=$(cat /run/secrets/REDIS_URL)' >> /etc/profile.d/secrets.sh
25
+
26
+ RUN chown user:user /etc/profile.d/secrets.sh
27
+
28
+
29
+
30
  # Install dependencies
31
  RUN apt-get update && apt-get install -y \
32
  libpq-dev \
 
52
  && wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip \
53
  && unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/
54
 
55
+
56
+
57
  USER user
58
  ENV PATH="/home/user/.local/bin:$PATH"
59
 
60
+ RUN . /etc/profile.d/secrets.sh
61
+
62
  # Install Python dependencies
63
  COPY --chown=user requirements.txt /tmp/requirements.txt
64
  RUN pip install --no-cache-dir --upgrade pip \
 
68
  COPY --chown=user . /code
69
  WORKDIR /code
70
 
71
+ RUN bash -c 'python manage.py makemigrations && \
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  python manage.py migrate --database=default && \
73
  python manage.py migrate --database=cache && \
74
  python manage.py migrate --database=DB1 && \