Enhance network resilience features in HMAC File Server 3.2

This commit is contained in:
2025-07-20 15:21:27 +00:00
parent 3c8a96c14e
commit f8e4d8fcba
11 changed files with 162 additions and 16 deletions

View File

@ -11,16 +11,32 @@ RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o hmac-file-server ./cmd/server/
# Stage 2: Runtime
FROM alpine:latest
RUN apk --no-cache add ca-certificates
RUN apk --no-cache add ca-certificates tzdata iputils
# Create non-root user for security
RUN adduser -D -s /bin/sh -u 1011 appuser
RUN mkdir -p /opt/hmac-file-server/data/uploads \
&& mkdir -p /opt/hmac-file-server/data/duplicates \
&& mkdir -p /opt/hmac-file-server/data/temp \
&& mkdir -p /opt/hmac-file-server/data/logs
&& mkdir -p /opt/hmac-file-server/data/logs \
&& chown -R appuser:appuser /opt/hmac-file-server \
&& chmod 750 /opt/hmac-file-server/data/uploads \
&& chmod 750 /opt/hmac-file-server/data/duplicates \
&& chmod 750 /opt/hmac-file-server/data/temp \
&& chmod 750 /opt/hmac-file-server/data/logs
WORKDIR /opt/hmac-file-server
COPY --from=builder /build/hmac-file-server .
RUN chown appuser:appuser hmac-file-server && chmod +x hmac-file-server
# Switch to non-root user
USER appuser
# Health check for network resilience
HEALTHCHECK --interval=30s --timeout=15s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
EXPOSE 8080