Files
honeyDueAPI/Dockerfile
Trey t dd3a624ce2 Fix Dockerfile COPY syntax and add template placeholder
- Remove shell redirect syntax from COPY (not supported in Docker)
- Add .gitkeep to templates/emails to ensure directory exists

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 20:12:04 -06:00

67 lines
1.7 KiB
Docker

# Build stage
FROM golang:1.23-alpine AS builder
# Install build dependencies
RUN apk add --no-cache git ca-certificates tzdata
# 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 the API binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /app/api ./cmd/api
# Build the worker binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /app/worker ./cmd/worker
# Build the admin binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /app/admin ./cmd/admin
# Final stage - Production API (default target for Dokku)
FROM alpine:3.19
# Install runtime dependencies
RUN apk add --no-cache ca-certificates tzdata curl
# Create non-root user
RUN addgroup -g 1000 app && adduser -u 1000 -G app -s /bin/sh -D app
# Set working directory
WORKDIR /app
# Copy all binaries from builder
COPY --from=builder /app/api /app/api
COPY --from=builder /app/worker /app/worker
COPY --from=builder /app/admin /app/admin
# Copy templates directory
COPY --from=builder /app/templates /app/templates
# Copy migrations and seeds for production use
COPY --from=builder /app/migrations /app/migrations
COPY --from=builder /app/seeds /app/seeds
# Create uploads directory
RUN mkdir -p /app/uploads && chown -R app:app /app
# Switch to non-root user
USER app
# Expose port (Dokku will set PORT env var to 5000)
EXPOSE 5000
# Health check using curl (more reliable)
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD curl -f http://localhost:${PORT:-5000}/api/health/ || exit 1
# Run the API (default command)
CMD ["/app/api"]