- Add development and production configuration templates - Include Docker build files for containerized deployment - Add Nginx configuration with SSL/TLS setup - Include environment configuration examples - Add SSL certificate setup and management - Configure application schemas and validation - Support for both local and production deployment scenarios Provides flexible deployment options from development to production with proper security, monitoring, and configuration management.
61 lines
1.4 KiB
Docker
61 lines
1.4 KiB
Docker
# Simple Dockerfile for homelab use
|
|
FROM golang:1.25-alpine AS builder
|
|
|
|
# Install dependencies
|
|
RUN apk add --no-cache git make
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy go mod files
|
|
COPY go.mod go.sum ./
|
|
|
|
# Download dependencies
|
|
RUN go mod download
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build Go binaries
|
|
RUN make build
|
|
|
|
# Final stage
|
|
FROM alpine:3.19
|
|
|
|
# Install runtime dependencies
|
|
RUN apk add --no-cache ca-certificates redis openssl
|
|
|
|
# Create app user
|
|
RUN addgroup -g 1001 -S appgroup && \
|
|
adduser -u 1001 -S appuser -G appgroup
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy binaries from builder
|
|
COPY --from=builder /app/bin/ /usr/local/bin/
|
|
|
|
# Copy configs and templates
|
|
COPY --from=builder /app/configs/ /app/configs/
|
|
COPY --from=builder /app/nginx/ /app/nginx/
|
|
|
|
# Create necessary directories
|
|
RUN mkdir -p /app/data/experiments /app/logs /app/ssl
|
|
|
|
# Generate SSL certificates for container use
|
|
RUN openssl req -x509 -newkey rsa:2048 -keyout /app/ssl/key.pem -out /app/ssl/cert.pem -days 365 -nodes \
|
|
-subj "/C=US/ST=Homelab/L=Local/O=ML/OU=Experiments/CN=localhost" && \
|
|
chmod 644 /app/ssl/cert.pem /app/ssl/key.pem
|
|
|
|
# Switch to app user
|
|
USER appuser
|
|
|
|
# Expose ports
|
|
EXPOSE 9101
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
|
CMD curl -k -f https://localhost:9101/health || exit 1
|
|
|
|
# Default command
|
|
CMD ["/usr/local/bin/api-server", "-config", "/app/configs/config.yaml"]
|