refactor: Update Docker configurations for improved environment variable handling
Some checks failed
Deploy to Production, build images and push to Gitea Registry / build_and_push (pull_request) Failing after 22s

- Changed the frontend Dockerfile to use process.env for environment variables instead of direct interpolation.
- Updated the production Docker Compose file to set environment variables directly instead of using build args.
- Switched the backend Dockerfile base image from `python:3.11-slim` to `python:alpine` for a smaller image size and increased worker count from 4 to 8 for better performance.
This commit is contained in:
mohamad 2025-06-01 15:41:42 +02:00
parent 99d6c5ffaa
commit a51b18e8f5
3 changed files with 8 additions and 9 deletions

View File

@ -1,5 +1,5 @@
# Multi-stage build for production
FROM python:3.11-slim as base
FROM python:alpine as base
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
@ -58,7 +58,6 @@ EXPOSE 8000
CMD ["uvicorn", "app.main:app", \
"--host", "0.0.0.0", \
"--port", "8000", \
"--workers", "4", \
"--worker-class", "uvicorn.workers.UvicornWorker", \
"--workers", "8", \
"--access-log", \
"--log-level", "info"]

View File

@ -66,7 +66,7 @@ services:
context: ./fe
dockerfile: Dockerfile.prod
target: production
args:
environment:
- VITE_API_URL=${VITE_API_URL}
- VITE_SENTRY_DSN=${VITE_SENTRY_DSN}
ports:

View File

@ -53,9 +53,9 @@ RUN echo '{ \n "rewrites": [ \n { "source": "**", "destination": "/index.htm
RUN echo '#!/bin/sh\n\
cat > /app/env-config.js << EOL\n\
window.ENV = {\n\
VITE_API_URL: "${VITE_API_URL}",\n\
VITE_SENTRY_DSN: "${VITE_SENTRY_DSN}",\n\
VITE_ROUTER_MODE: "${VITE_ROUTER_MODE}"\n\
VITE_API_URL: process.env.VITE_API_URL,\n\
VITE_SENTRY_DSN: process.env.VITE_SENTRY_DSN,\n\
VITE_ROUTER_MODE: process.env.VITE_ROUTER_MODE\n\
};\n\
EOL\n\
serve -s . -l 3000' > /app/start.sh && chmod +x /app/start.sh