2023-04-09 12:33:30 +08:00
|
|
|
# syntax=docker/dockerfile:1
|
|
|
|
|
|
|
|
FROM golang:alpine AS base
|
2022-12-20 05:06:29 +08:00
|
|
|
ENV CGO_ENABLED=0
|
|
|
|
RUN apk add --no-cache file git
|
|
|
|
WORKDIR /src
|
|
|
|
|
2023-04-09 12:33:30 +08:00
|
|
|
FROM base AS build
|
|
|
|
RUN --mount=type=bind,target=/src \
|
|
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
|
|
|
go build -ldflags "-s -w" -o /usr/bin/app .
|
2022-12-20 05:06:29 +08:00
|
|
|
|
|
|
|
FROM scratch AS binary
|
|
|
|
COPY --from=build /usr/bin/app /bin/app
|
|
|
|
|
2023-04-09 12:33:30 +08:00
|
|
|
FROM alpine AS image
|
2022-12-20 05:06:29 +08:00
|
|
|
COPY --from=build /usr/bin/app /bin/app
|
2023-04-09 12:33:30 +08:00
|
|
|
EXPOSE 8080
|
|
|
|
ENTRYPOINT ["/bin/app"]
|