-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
27 lines (18 loc) · 746 Bytes
/
Dockerfile
File metadata and controls
27 lines (18 loc) · 746 Bytes
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
# stage 0: generate mock server code
FROM gcatanese/openapi-native-mock-server
ARG openapifile=openapi/openapi.yaml
ADD $openapifile /openapi/$openapifile
RUN java -cp /openapi/bin/openapi-native-mock-server.jar:/openapi/bin/openapi-generator-cli.jar \
org.openapitools.codegen.OpenAPIGenerator generate -g com.tweesky.cloudtools.codegen.NativeMockServerCodegen \
-i /openapi/$openapifile -o /openapi/go-server
# stage 1: build Go executable
FROM golang:1.19-alpine3.15
COPY --from=0 /openapi/go-server ./go-server
WORKDIR /go/go-server
RUN go mod tidy
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /build .
# stage 2: build minimal image
FROM scratch AS runtime
COPY --from=1 /build .
EXPOSE 8080
ENTRYPOINT ["./build"]