-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
31 lines (22 loc) · 857 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# syntax=docker/dockerfile:1
FROM golang:1.23 AS build
WORKDIR /mod
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
RUN mkdir /app
# Build the application.
# Leverage a cache mount to /go/pkg/mod/ to speed up subsequent builds.
# Leverage a bind mount to the current directory to avoid having to copy the
# source code into the container.
# Leverage a cache mount to GOCACHE to speed up subsequent builds.
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,target=. \
--mount=type=cache,target=/root/.cache/go-build \
GOARCH=amd64 CGO_ENABLED=0 go build -o /app .
FROM --platform=linux/amd64 scratch
WORKDIR /app
COPY --from=build /app/marwanio /app/marwanio
EXPOSE 3091
ENTRYPOINT ["/app/marwanio"]