Project-Image-Uploader/docker/dev/frontend/Dockerfile
matthias.lotz dd71dcab44 feat: ENV-Struktur massiv vereinfacht (Phase 6)
- Von 16 .env Dateien auf 2 zentrale reduziert
  * docker/dev/.env - Development Secrets
  * docker/prod/.env - Production Secrets

- Alle ENV-Variablen jetzt in docker-compose.yml environment sections
- .env COPY aus allen Dockerfiles entfernt (wurden durch volume mounts überschrieben)
- Frontend env.sh umgeschrieben: Liest ENV-Variablen statt .env Datei
- CLIENT_URL komplett entfernt (wurde nirgendwo verwendet)

- Fix: management.js nutzt platform_name statt name (DB-Schema korrekt)

ENV-Handling jetzt deutlich einfacher und wartbarer!
Von 4 Frontend ENV-Variablen auf 3 reduziert (API_URL, PUBLIC_HOST, INTERNAL_HOST)
2025-11-30 13:19:24 +01:00

50 lines
1.6 KiB
Docker

FROM node:18-bullseye
# Install nginx and bash
RUN apt-get update \
&& apt-get install -y --no-install-recommends nginx procps bash ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user for dev
RUN useradd -m appuser || true
WORKDIR /app
# Copy package files first to leverage Docker cache for npm install
COPY frontend/package*.json ./
# Copy environment shell script (generates env-config.js from ENV at runtime)
COPY docker/dev/frontend/config/env.sh ./env.sh
# Note: ENV variables are set via docker-compose.yml, not from .env file
# Make env.sh executable
RUN chmod +x ./env.sh
# Copy nginx configuration for development
COPY docker/dev/frontend/nginx.conf /etc/nginx/conf.d/default.conf
# Make /app owned by the non-root user, then run npm as that user so
# node_modules are created with the correct owner and we avoid an expensive
# recursive chown later.
RUN chown appuser:appuser /app || true
USER appuser
# Install dependencies as non-root (faster overall because we avoid chown -R)
# Use npm ci without legacy peer deps to get a clean, reproducible install
RUN npm ci --no-audit --no-fund
# Switch back to root to add the start script and adjust nginx paths
USER root
COPY docker/dev/frontend/start.sh /start.sh
RUN chmod +x /start.sh
# Ensure nginx log/lib dirs are writable by the app user (small set)
RUN chown -R appuser:appuser /var/lib/nginx /var/log/nginx || true
# Remove default Debian nginx site so our dev config becomes the active default
RUN rm -f /etc/nginx/sites-enabled/default || true
USER appuser
EXPOSE 80 3000
CMD ["/start.sh"]