FROM nginx:alpine

# Zeitzone setzen
ENV TZ=Europe/Berlin
RUN apk add --no-cache tzdata \
    && ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime \
    && echo "Europe/Berlin" > /etc/timezone

# SSL-Verzeichnis erstellen
RUN mkdir -p /etc/nginx/ssl

# Default config entfernen
RUN rm -f /etc/nginx/conf.d/default.conf

# Nginx-Konfiguration kopieren
COPY nginx.conf /etc/nginx/nginx.conf

# SSL-Zertifikate kopieren
COPY ssl/fullchain.pem /etc/nginx/ssl/
COPY ssl/privkey.pem /etc/nginx/ssl/
COPY ssl/dhparam.pem /etc/nginx/ssl/

# Berechtigungen setzen
RUN chmod 600 /etc/nginx/ssl/privkey.pem
RUN chmod 644 /etc/nginx/ssl/dhparam.pem

EXPOSE 80 443

CMD ["nginx", "-g", "daemon off;"]