feat: build webapp when docker build
This commit is contained in:
@@ -26,6 +26,10 @@ Dockerfile
|
|||||||
.dockerignore
|
.dockerignore
|
||||||
tmp/
|
tmp/
|
||||||
|
|
||||||
|
# WebApp build artifacts (regenerated inside Docker)
|
||||||
|
bot/app/web/templates/subscription_webapp.css
|
||||||
|
bot/app/web/templates/subscription_webapp.min.*.js
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
**/__pycache__/
|
**/__pycache__/
|
||||||
**/*.py[cod]
|
**/*.py[cod]
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ scratch_*.py
|
|||||||
node_modules/
|
node_modules/
|
||||||
.git/
|
.git/
|
||||||
|
|
||||||
|
# WebApp build artifacts (regenerated by `npm run build:webapp` / Docker build)
|
||||||
|
bot/app/web/templates/subscription_webapp.css
|
||||||
|
bot/app/web/templates/subscription_webapp.min.*.js
|
||||||
|
|
||||||
# Игнорировать кэш Python
|
# Игнорировать кэш Python
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|
||||||
|
|||||||
+25
-2
@@ -1,4 +1,4 @@
|
|||||||
FROM python:3.12-slim AS builder
|
FROM python:3.12-slim AS python-builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -7,16 +7,39 @@ COPY requirements.txt .
|
|||||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||||
pip install --no-cache-dir -r requirements.txt
|
pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
|
||||||
|
FROM node:22-slim AS webapp-builder
|
||||||
|
|
||||||
|
WORKDIR /webapp
|
||||||
|
|
||||||
|
COPY package.json package-lock.json* ./
|
||||||
|
RUN --mount=type=cache,target=/root/.npm \
|
||||||
|
if [ -f package-lock.json ]; then npm ci; else npm install; fi
|
||||||
|
|
||||||
|
COPY bot/app/web/templates ./bot/app/web/templates
|
||||||
|
COPY scripts/build_subscription_webapp_js.mjs ./scripts/build_subscription_webapp_js.mjs
|
||||||
|
|
||||||
|
RUN npm run build:webapp
|
||||||
|
|
||||||
|
|
||||||
FROM python:3.12-slim
|
FROM python:3.12-slim
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN useradd -u 10001 -m appuser
|
RUN useradd -u 10001 -m appuser
|
||||||
|
|
||||||
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
|
COPY --from=python-builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Replace template assets with freshly built ones
|
||||||
|
RUN rm -f bot/app/web/templates/subscription_webapp.css \
|
||||||
|
bot/app/web/templates/subscription_webapp.min.*.js
|
||||||
|
COPY --from=webapp-builder /webapp/bot/app/web/templates/subscription_webapp.css \
|
||||||
|
bot/app/web/templates/subscription_webapp.css
|
||||||
|
COPY --from=webapp-builder /webapp/bot/app/web/templates/subscription_webapp.min.*.js \
|
||||||
|
bot/app/web/templates/
|
||||||
|
|
||||||
RUN rm -rf /root/.cache
|
RUN rm -rf /root/.cache
|
||||||
|
|
||||||
RUN mkdir -p /app/logs /app/data && chown -R appuser:appuser /app/logs /app/data
|
RUN mkdir -p /app/logs /app/data && chown -R appuser:appuser /app/logs /app/data
|
||||||
|
|||||||
Reference in New Issue
Block a user