Include .gitignore, go.mod/go.sum, initial Go source, init.sql, and Docker‑Compose configuration for the MSSQL and backend services.
35 lines
644 B
Docker
35 lines
644 B
Docker
# Use the official Go image as the base image
|
|
FROM golang:1.22-alpine AS builder
|
|
|
|
# Set the working directory inside the container
|
|
WORKDIR /app
|
|
|
|
# Cache Go modules
|
|
COPY go.mod ./
|
|
RUN apk add --no-cache git
|
|
RUN go mod download
|
|
|
|
# Copy the source code
|
|
COPY . .
|
|
|
|
# Build the Go binary
|
|
RUN go build -o main .
|
|
|
|
# ---- Runtime image ----
|
|
FROM alpine:3.19
|
|
|
|
# Install ca-certificates (if needed)
|
|
RUN apk add --no-cache ca-certificates
|
|
|
|
# Set workdir
|
|
WORKDIR /app
|
|
|
|
# Copy the binary from the builder stage
|
|
COPY --from=builder /app/main .
|
|
|
|
# Expose the application port (default for the Go server)
|
|
EXPOSE 8080
|
|
|
|
# Command to run the binary
|
|
CMD ["./main"]
|