BloodyInside commited on
Commit
aae91f6
·
1 Parent(s): 7d7916a
Files changed (1) hide show
  1. Dockerfile +60 -3
Dockerfile CHANGED
@@ -52,7 +52,65 @@ RUN --mount=type=secret,id=HOST,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) && \
@@ -63,7 +121,6 @@ RUN --mount=type=secret,id=HOST,required=true \
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"]
 
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) && \# syntax=docker/dockerfile:1.3
56
+ ARG PYTHON_VERSION=3.12-slim-bullseye
57
+
58
+ FROM python:${PYTHON_VERSION}
59
+
60
+ ENV PYTHONDONTWRITEBYTECODE 1
61
+ ENV PYTHONUNBUFFERED 1
62
+
63
+ # Install dependencies
64
+ RUN apt-get update && apt-get install -y \
65
+ libpq-dev \
66
+ gcc \
67
+ g++ \
68
+ wget \
69
+ unzip \
70
+ xvfb \
71
+ libxi6 \
72
+ libgconf-2-4 \
73
+ gnupg \
74
+ curl \
75
+ && rm -rf /var/lib/apt/lists/*
76
+
77
+ # Install Chrome
78
+ RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
79
+ && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
80
+ && apt-get update \
81
+ && apt-get install -y google-chrome-stable
82
+
83
+ # Install ChromeDriver
84
+ RUN CHROMEDRIVER_VERSION=$(curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE) \
85
+ && wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip \
86
+ && unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/
87
+
88
+ RUN useradd -m -u 1000 user
89
+ USER user
90
+ ENV PATH="/home/user/.local/bin:$PATH"
91
+
92
+ # Install Python dependencies
93
+ COPY --chown=user requirements.txt /tmp/requirements.txt
94
+ RUN pip install --no-cache-dir --upgrade pip \
95
+ && pip install --no-cache-dir -r /tmp/requirements.txt
96
+
97
+ # Copy application code
98
+ COPY --chown=user . /code
99
+ WORKDIR /code
100
+
101
+ USER root
102
+ # Use secrets during build
103
+ RUN --mount=type=secret,id=HOST,required=true \
104
+ --mount=type=secret,id=DJANGO_SECRET,required=true \
105
+ --mount=type=secret,id=SECURE_TOKEN,required=true \
106
+ --mount=type=secret,id=WORKER_TOKEN,required=true \
107
+ --mount=type=secret,id=CLOUDFLARE_TURNSTILE_SECRET,required=true \
108
+ --mount=type=secret,id=REDIS_URL,required=true
109
+ RUN chown -R user:user /run/secrets
110
+
111
+ USER user
112
+
113
+ RUN bash -c 'export HOST=$(cat /run/secrets/HOST) && \
114
  export DJANGO_SECRET=$(cat /run/secrets/DJANGO_SECRET) && \
115
  export SECURE_TOKEN=$(cat /run/secrets/SECURE_TOKEN) && \
116
  export WORKER_TOKEN=$(cat /run/secrets/WORKER_TOKEN) && \
 
121
  python manage.py migrate --database=cache && \
122
  python manage.py migrate --database=DB1 && \
123
  python manage.py migrate --database=DB2'
124
+
 
125
 
126
  CMD ["daphne", "-b", "0.0.0.0", "-p", "7860", "core.asgi:application"]