chore: update
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
FROM golang:1.24-alpine AS builder
|
||||
WORKDIR /app
|
||||
|
||||
# Installer les dépendances système
|
||||
RUN apk add --no-cache git ca-certificates tzdata gcc musl-dev
|
||||
|
||||
# Copier go mod files
|
||||
COPY backend/gestion/go.mod backend/gestion/go.sum ./
|
||||
|
||||
# Configurer Go et télécharger les dépendances
|
||||
ENV GOPROXY=https://proxy.golang.org,direct
|
||||
ENV GOSUMDB=sum.golang.org
|
||||
ENV CGO_ENABLED=0
|
||||
|
||||
# Télécharger les dépendances
|
||||
RUN go mod download
|
||||
|
||||
# Copier tout le code source
|
||||
COPY backend/gestion/ .
|
||||
|
||||
# Build le binaire
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
-ldflags="-w -s -X main.Version=1.0.0 -X main.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
||||
-o /app/server .
|
||||
|
||||
# =========================================================
|
||||
# Stage 2: Runtime
|
||||
# =========================================================
|
||||
FROM alpine:latest AS runtime
|
||||
|
||||
# Installer les dépendances runtime
|
||||
RUN apk --no-cache add ca-certificates tzdata wget
|
||||
|
||||
# Créer l'utilisateur avec UID/GID fixes
|
||||
RUN addgroup -g 101 app && adduser -u 101 -S app -G app
|
||||
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copier le binaire et les fichiers nécessaires
|
||||
COPY --from=builder /app/server .
|
||||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||
|
||||
# Copier l'entrypoint
|
||||
COPY docker/backend/entrypoint.sh .
|
||||
RUN chmod +x entrypoint.sh
|
||||
|
||||
RUN mkdir -p /app/uploads/images /app/uploads/videos && \
|
||||
chown -R app:app /app
|
||||
|
||||
# Passer à l'utilisateur non-root
|
||||
USER app
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["./entrypoint.sh"]
|
||||
|
||||
# =========================================================
|
||||
# Stage 3: WAF (Nginx + ModSecurity)
|
||||
# =========================================================
|
||||
FROM owasp/modsecurity-crs:nginx-alpine AS waf
|
||||
|
||||
# Toutes les opérations privilégiées en root
|
||||
USER root
|
||||
|
||||
RUN mkdir -p /var/log/modsec /etc/nginx/certs && \
|
||||
chown -R nginx:nginx /var/log/modsec /etc/nginx/certs /usr/share/nginx/html
|
||||
|
||||
COPY docker/backend/nginx.conf /etc/nginx/conf.d/app.conf
|
||||
COPY docker/backend/custom-rules.conf /etc/nginx/modsec/custom-rules.conf
|
||||
RUN echo "Include /etc/nginx/modsec/custom-rules.conf" > /etc/nginx/modsec/custom-includes.conf && \
|
||||
rm -f /etc/nginx/templates/conf.d/default.conf.template || true
|
||||
|
||||
USER nginx
|
||||
EXPOSE 80 443
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
Reference in New Issue
Block a user