backend-service/Dockerfile
ats-tech25 4f872b8350 chore(docker): Add Docker and development configuration files
- Add Dockerfile for multi-stage build process
- Add .dockerignore to optimize Docker build context
- Add docker-compose.yml for local development and deployment
- Remove existing Makefile and replace with Docker-based workflow
- Update .gitignore to exclude .env file
- Update .env.example with consistent configuration
- Remove sensitive .env file from version control
- Prepare project for containerized development and deployment
Streamlines project setup, improves development workflow, and enhances deployment flexibility with containerization.
2025-11-07 20:54:18 +00:00

49 lines
1.1 KiB
Docker

# Build stage
FROM golang:1.25.1-alpine AS builder
# Install build 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 the server binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o server cmd/server/main.go
# Build the CLI binary (optional, for migrations)
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o cli cmd/cli/main.go
# Runtime stage
FROM alpine:latest
# Install ca-certificates for HTTPS requests
RUN apk --no-cache add ca-certificates tzdata
WORKDIR /root/
# Copy binaries from builder
COPY --from=builder /app/server .
COPY --from=builder /app/cli .
# Copy templates if they exist
COPY --from=builder /app/internal/templates ./internal/templates
# Expose port (adjust if needed)
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
# Run the server
CMD ["./server"]