File size: 753 Bytes
8549d8b
 
faedb74
8549d8b
9ef2fb2
f214487
737378f
8549d8b
 
faedb74
8549d8b
 
 
 
faedb74
8549d8b
 
faedb74
8549d8b
f214487
 
8549d8b
 
 
 
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
# syntax = docker/dockerfile:1-experimental
FROM golang:1.23-alpine AS builder

WORKDIR /home/appuser
COPY go.mod go.sum .
COPY index.html index.html
COPY assets ./assets
RUN go mod download
COPY main.go .

#  -s disable symbol table, -w disable DWARF generation (smaller binary)
# cross compile for amd64
RUN --mount=type=cache,target=/root/.cache/go-build \
    CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /bin/mock-server .

# Set platform to x64
FROM --platform=linux/amd64 gcr.io/distroless/static-debian12:nonroot as server

WORKDIR /home/appuser
COPY index.html index.html
COPY assets ./assets
COPY --from=builder --chown=nonroot:nonroot /bin/mock-server ./bin/mock-server

EXPOSE 3001/tcp
ENTRYPOINT ["./bin/mock-server"]