30 lines
610 B
Docker
30 lines
610 B
Docker
FROM golang:alpine as builder
|
|
|
|
WORKDIR /go
|
|
|
|
# Install dependencies
|
|
RUN apk add -U --no-cache ca-certificates && update-ca-certificates && go install github.com/swaggo/swag/cmd/swag@latest
|
|
|
|
# Cache dependencies
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
# Copy source code
|
|
COPY . ./
|
|
|
|
# Build the application
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags "-w -s" -o /app ./cmd/playground/
|
|
|
|
FROM scratch
|
|
|
|
ARG VERSION
|
|
ENV VERSION=$VERSION
|
|
|
|
WORKDIR /
|
|
|
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
|
COPY --from=builder /app ./
|
|
COPY web ./web
|
|
|
|
EXPOSE 8080
|
|
CMD ["/app"] |