refactor: project architecture refactor, container splitting
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
FROM python:3.12-slim AS python-base
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PYTHONPATH=/app/backend
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN useradd -u 10001 -m appuser
|
||||
|
||||
COPY backend/requirements.txt backend/requirements.txt
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
pip install --no-cache-dir -r backend/requirements.txt
|
||||
|
||||
COPY backend ./backend
|
||||
COPY locales ./locales
|
||||
COPY data ./data
|
||||
RUN mkdir -p /app/logs /app/data && chown -R appuser:appuser /app/logs /app/data
|
||||
|
||||
USER appuser
|
||||
|
||||
|
||||
FROM python-base AS backend
|
||||
|
||||
LABEL org.opencontainers.image.source="https://github.com/3252a8/remnawave-minishop" \
|
||||
org.opencontainers.image.title="remnawave-minishop-backend" \
|
||||
org.opencontainers.image.description="Remnawave Minishop backend (Telegram bot API, web app, webhooks)." \
|
||||
org.opencontainers.image.licenses="MIT"
|
||||
|
||||
EXPOSE 8080 8081
|
||||
CMD ["python", "backend/main_backend.py"]
|
||||
|
||||
|
||||
FROM python-base AS worker
|
||||
|
||||
LABEL org.opencontainers.image.source="https://github.com/3252a8/remnawave-minishop" \
|
||||
org.opencontainers.image.title="remnawave-minishop-worker" \
|
||||
org.opencontainers.image.description="Remnawave Minishop background worker (scheduled jobs, async tasks)." \
|
||||
org.opencontainers.image.licenses="MIT"
|
||||
|
||||
CMD ["python", "backend/main_worker.py"]
|
||||
|
||||
|
||||
FROM node:22-slim AS frontend-builder
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
COPY frontend/package.json frontend/package-lock.json* ./
|
||||
RUN --mount=type=cache,target=/root/.npm \
|
||||
if [ -f package-lock.json ]; then npm ci; else npm install; fi
|
||||
|
||||
COPY frontend ./
|
||||
COPY backend/bot/app/web/templates ../backend/bot/app/web/templates
|
||||
|
||||
RUN npm run build:webapp
|
||||
|
||||
|
||||
FROM nginx:1.27-alpine AS frontend
|
||||
|
||||
LABEL org.opencontainers.image.source="https://github.com/3252a8/remnawave-minishop" \
|
||||
org.opencontainers.image.title="remnawave-minishop-frontend" \
|
||||
org.opencontainers.image.description="Remnawave Minishop frontend (nginx serving the subscription Mini App)." \
|
||||
org.opencontainers.image.licenses="MIT"
|
||||
|
||||
COPY deploy/docker/frontend/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY deploy/docker/frontend/00-startup-banner.sh /docker-entrypoint.d/00-startup-banner.sh
|
||||
COPY backend/bot/app/web/templates/subscription_webapp.html /usr/share/nginx/html/index.html
|
||||
COPY --from=frontend-builder /app/backend/bot/app/web/templates/subscription_webapp.css /usr/share/nginx/html/subscription_webapp.css
|
||||
COPY --from=frontend-builder /app/backend/bot/app/web/templates/subscription_webapp.js /usr/share/nginx/html/subscription_webapp.js
|
||||
COPY --from=frontend-builder /app/backend/bot/app/web/templates/subscription_webapp.min.*.js /usr/share/nginx/html/
|
||||
|
||||
RUN sed -i \
|
||||
-e '/WEBAPP_I18N_SCRIPT/d' \
|
||||
-e '/WEBAPP_CONFIG_SCRIPT/d' \
|
||||
-e '/WEBAPP_JS_SCRIPT/c\ <script src="/subscription_webapp.js" type="module"></script>' \
|
||||
-e '/WEBAPP_DEV_MOCK_START/d' \
|
||||
-e '/WEBAPP_DEV_MOCK_END/d' \
|
||||
-e '/subscription_webapp.js" defer/d' \
|
||||
/usr/share/nginx/html/index.html \
|
||||
&& chmod +x /docker-entrypoint.d/00-startup-banner.sh
|
||||
|
||||
EXPOSE 80
|
||||
@@ -0,0 +1,11 @@
|
||||
{$PUBLIC_HOST:localhost} {
|
||||
encode zstd gzip
|
||||
|
||||
@webhooks path /tg/webhook /webhook/*
|
||||
reverse_proxy @webhooks backend:8080
|
||||
|
||||
@backend_health path /health /healthz
|
||||
reverse_proxy @backend_health backend:8080
|
||||
|
||||
reverse_proxy frontend:80
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
PUBLISHED="${FRONTEND_PUBLIC:-127.0.0.1:${FRONTEND_PORT:-8082}->80}"
|
||||
|
||||
cat <<EOF
|
||||
|
||||
~ ~ ~ r e m n a w a v e ~ ~ ~
|
||||
|
||||
███╗ ███╗██╗███╗ ██╗██╗███████╗██╗ ██╗ ██████╗ ██████╗
|
||||
████╗ ████║██║████╗ ██║██║██╔════╝██║ ██║██╔═══██╗██╔══██╗
|
||||
██╔████╔██║██║██╔██╗ ██║██║███████╗███████║██║ ██║██████╔╝
|
||||
██║╚██╔╝██║██║██║╚██╗██║██║╚════██║██╔══██║██║ ██║██╔═══╝
|
||||
██║ ╚═╝ ██║██║██║ ╚████║██║███████║██║ ██║╚██████╔╝██║
|
||||
╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝
|
||||
|
||||
container :: FRONTEND
|
||||
image tag :: ${IMAGE_TAG:-local}
|
||||
listen :: :80
|
||||
published :: ${PUBLISHED}
|
||||
upstream :: backend:8081
|
||||
healthcheck :: /health
|
||||
https://github.com/3252a8/remnawave-minishop
|
||||
|
||||
EOF
|
||||
@@ -0,0 +1,57 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location = /health {
|
||||
access_log off;
|
||||
return 200 "ok\n";
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://backend:8081;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location /auth/ {
|
||||
proxy_pass http://backend:8081;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location = /webapp-logo {
|
||||
proxy_pass http://backend:8081;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location ~ ^/(webapp-logo|webapp-uploaded-logo|webapp-favicon|webapp-emoji|webapp-theme-css|webapp-theme-assets)/ {
|
||||
proxy_pass http://backend:8081;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|webp)$ {
|
||||
expires 30d;
|
||||
add_header Cache-Control "public";
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri /index.html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user