39 lines
660 B
Docker
39 lines
660 B
Docker
# Build stage
|
|
FROM docker.io/golang:1.23-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install dependencies
|
|
RUN apk add --no-cache git
|
|
|
|
# Copy go.mod and go.sum
|
|
COPY go.mod go.sum ./
|
|
|
|
# Download dependencies
|
|
RUN go mod download
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o faas-server ./cmd/server
|
|
|
|
# Final stage
|
|
FROM docker.io/alpine:latest
|
|
|
|
RUN apk --no-cache add ca-certificates
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy the binary
|
|
COPY --from=builder /app/faas-server .
|
|
|
|
# Copy migrations
|
|
COPY --from=builder /app/migrations ./migrations
|
|
|
|
# Expose port
|
|
EXPOSE 8082 9091
|
|
|
|
# Run the application
|
|
CMD ["./faas-server"]
|