26 lines
429 B
Docker
26 lines
429 B
Docker
|
# Build stage
|
||
|
FROM golang:1.23-alpine AS builder
|
||
|
WORKDIR /app
|
||
|
|
||
|
# Copy and download dependencies
|
||
|
# COPY go.mod go.sum ./
|
||
|
COPY go.mod ./
|
||
|
RUN go mod download
|
||
|
|
||
|
# Copy the source code
|
||
|
COPY . .
|
||
|
|
||
|
# Build the application
|
||
|
RUN go build -o main .
|
||
|
|
||
|
# Runtime stage
|
||
|
FROM alpine:latest
|
||
|
WORKDIR /root/
|
||
|
COPY --from=builder /app/main .
|
||
|
|
||
|
# Expose the port the service will run on
|
||
|
EXPOSE 8080
|
||
|
|
||
|
# Command to run the executable
|
||
|
ENTRYPOINT ["./main"]
|