Spaces:
Running
Running
BloodyInside
commited on
Commit
•
7d7916a
1
Parent(s):
bf47469
erp
Browse files- Dockerfile +17 -27
Dockerfile
CHANGED
@@ -6,26 +6,6 @@ FROM python:${PYTHON_VERSION}
|
|
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 |
-
bash -c "printf 'HOST=\"%s\"\n' \"$(cat /run/secrets/HOST)\" >> /etc/profile.d/secrets.sh && \
|
18 |
-
printf 'DJANGO_SECRET=\"%s\"\n' \"$(cat /run/secrets/DJANGO_SECRET)\" >> /etc/profile.d/secrets.sh && \
|
19 |
-
printf 'SECURE_TOKEN=\"%s\"\n' \"$(cat /run/secrets/SECURE_TOKEN)\" >> /etc/profile.d/secrets.sh && \
|
20 |
-
printf 'WORKER_TOKEN=\"%s\"\n' \"$(cat /run/secrets/WORKER_TOKEN)\" >> /etc/profile.d/secrets.sh && \
|
21 |
-
printf 'CLOUDFLARE_TURNSTILE_SECRET=\"%s\"\n' \"$(cat /run/secrets/CLOUDFLARE_TURNSTILE_SECRET)\" >> /etc/profile.d/secrets.sh && \
|
22 |
-
printf 'REDIS_URL=\"%s\"\n' \"$(cat /run/secrets/REDIS_URL)\" >> /etc/profile.d/secrets.sh"
|
23 |
-
|
24 |
-
|
25 |
-
RUN chown user:user /etc/profile.d/secrets.sh
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
# Install dependencies
|
30 |
RUN apt-get update && apt-get install -y \
|
31 |
libpq-dev \
|
@@ -51,13 +31,10 @@ RUN CHROMEDRIVER_VERSION=$(curl -sS chromedriver.storage.googleapis.com/LATEST_R
|
|
51 |
&& wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip \
|
52 |
&& unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/
|
53 |
|
54 |
-
|
55 |
-
|
56 |
USER user
|
57 |
ENV PATH="/home/user/.local/bin:$PATH"
|
58 |
|
59 |
-
RUN . /etc/profile.d/secrets.sh
|
60 |
-
|
61 |
# Install Python dependencies
|
62 |
COPY --chown=user requirements.txt /tmp/requirements.txt
|
63 |
RUN pip install --no-cache-dir --upgrade pip \
|
@@ -67,13 +44,26 @@ RUN pip install --no-cache-dir --upgrade pip \
|
|
67 |
COPY --chown=user . /code
|
68 |
WORKDIR /code
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
RUN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
python manage.py makemigrations && \
|
74 |
python manage.py migrate --database=default && \
|
75 |
python manage.py migrate --database=cache && \
|
76 |
python manage.py migrate --database=DB1 && \
|
77 |
python manage.py migrate --database=DB2'
|
|
|
|
|
78 |
|
79 |
CMD ["daphne", "-b", "0.0.0.0", "-p", "7860", "core.asgi:application"]
|
|
|
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 |
&& 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 |
COPY --chown=user . /code
|
45 |
WORKDIR /code
|
46 |
|
47 |
+
USER root
|
48 |
+
# Use secrets during build
|
49 |
+
RUN --mount=type=secret,id=HOST,required=true \
|
50 |
+
--mount=type=secret,id=DJANGO_SECRET,required=true \
|
51 |
+
--mount=type=secret,id=SECURE_TOKEN,required=true \
|
52 |
+
--mount=type=secret,id=WORKER_TOKEN,required=true \
|
53 |
+
--mount=type=secret,id=CLOUDFLARE_TURNSTILE_SECRET,required=true \
|
54 |
+
--mount=type=secret,id=REDIS_URL,required=true \
|
55 |
+
bash -c 'export HOST=$(cat /run/secrets/HOST) && \
|
56 |
+
export DJANGO_SECRET=$(cat /run/secrets/DJANGO_SECRET) && \
|
57 |
+
export SECURE_TOKEN=$(cat /run/secrets/SECURE_TOKEN) && \
|
58 |
+
export WORKER_TOKEN=$(cat /run/secrets/WORKER_TOKEN) && \
|
59 |
+
export CLOUDFLARE_TURNSTILE_SECRET=$(cat /run/secrets/CLOUDFLARE_TURNSTILE_SECRET) && \
|
60 |
+
export REDIS_URL=$(cat /run/secrets/REDIS_URL) && \
|
61 |
python manage.py makemigrations && \
|
62 |
python manage.py migrate --database=default && \
|
63 |
python manage.py migrate --database=cache && \
|
64 |
python manage.py migrate --database=DB1 && \
|
65 |
python manage.py migrate --database=DB2'
|
66 |
+
RUN chown -R user:user /code
|
67 |
+
USER user
|
68 |
|
69 |
CMD ["daphne", "-b", "0.0.0.0", "-p", "7860", "core.asgi:application"]
|