mirror of
https://github.com/tiennm99/keepalive.git
synced 2026-10-11 03:13:31 +00:00
feat(docker): add dockerfile
This commit is contained in:
1 parent
681b737f2f
commit
740c34daf3
1 file changed
+40
@@ -0,0 +1,40 @@
|
|||||||
|
ARG GO_VERSION=1.24.10
|
||||||
|
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} AS build
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod/ \
|
||||||
|
--mount=type=bind,source=go.sum,target=go.sum \
|
||||||
|
--mount=type=bind,source=go.mod,target=go.mod \
|
||||||
|
go mod download -x
|
||||||
|
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod/ \
|
||||||
|
--mount=type=bind,target=. \
|
||||||
|
CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o /bin/server .
|
||||||
|
|
||||||
|
FROM alpine:latest AS final
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/var/cache/apk \
|
||||||
|
apk --update add \
|
||||||
|
ca-certificates \
|
||||||
|
tzdata \
|
||||||
|
&& \
|
||||||
|
update-ca-certificates
|
||||||
|
|
||||||
|
ARG UID=10001
|
||||||
|
RUN adduser \
|
||||||
|
--disabled-password \
|
||||||
|
--gecos "" \
|
||||||
|
--home "/nonexistent" \
|
||||||
|
--shell "/sbin/nologin" \
|
||||||
|
--no-create-home \
|
||||||
|
--uid "${UID}" \
|
||||||
|
appuser
|
||||||
|
USER appuser
|
||||||
|
|
||||||
|
COPY --from=build /bin/server /bin/
|
||||||
|
|
||||||
|
EXPOSE 1999
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/bin/server" ]
|
||||||
Reference in new issue
Block a user