-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathDockerfile
39 lines (29 loc) · 1.13 KB
/
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
32
33
34
35
36
37
38
39
# syntax=docker/dockerfile:1.0.0-experimental
# NOTE: Must be run in the context of the repo's root directory
## Build the app binary
FROM --platform=$BUILDPLATFORM golang:1.20 AS build-app
# Build the app binary in /app
RUN mkdir /app
WORKDIR /app
# add the pubkey of github.com to knownhosts, so ssh-agent doesn't bark
RUN mkdir -p /root/.ssh && ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts
RUN git config --global 'url.ssh://git@github.com/.insteadOf' https://github.com/
COPY . .
ARG TARGETOS
ARG TARGETARCH
RUN --mount=type=ssh \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
GO111MODULE=on CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator
## Add the binary to a fresh distroless image
FROM gcr.io/distroless/static
COPY --from=build-app /app/app /bin/app
# Expose GRPC and HTTP ports
EXPOSE 8080
EXPOSE 3569
# Run the CLI binary as the entrypoint
ENTRYPOINT ["/bin/app"]
# These arguments are separated from the entrypoint to simplify running other
# commands with this image.
CMD ["emulator", "start"]