-
Notifications
You must be signed in to change notification settings - Fork 147
/
Dockerfile
60 lines (45 loc) · 1.75 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# syntax=docker/dockerfile:1
ARG GOLANG_IMAGE_TAG=1.22-bullseye
# Build stage
FROM golang:${GOLANG_IMAGE_TAG} AS build
ARG BUILD_TAGS=rocksdb
ARG BUILD_LD_FLAGS="--X=github.com/iotaledger/wasp/components/app.Version=v0.0.0-testing"
LABEL org.label-schema.description="Wasp"
LABEL org.label-schema.name="iotaledger/wasp"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.vcs-url="https://github.com/iotaledger/wasp"
# Ensure ca-certificates are up to date
RUN update-ca-certificates
# Set the current Working Directory inside the container
RUN mkdir /scratch
WORKDIR /scratch
# Prepare the folder where we are putting all the files
RUN mkdir /app
RUN mkdir /app/waspdb
# Make sure that modules only get pulled when the module file has changed
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go mod download
# Project build stage
COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go build -o /app/wasp -a -tags=${BUILD_TAGS} -ldflags=${BUILD_LD_FLAGS} .
############################
# Image
############################
# https://console.cloud.google.com/gcr/images/distroless/global/cc-debian11
# using distroless cc "nonroot" image, which includes everything in the base image (glibc, libssl and openssl)
FROM gcr.io/distroless/cc-debian11:nonroot
EXPOSE 9090/tcp
EXPOSE 6060/tcp
EXPOSE 4000/udp
EXPOSE 4000/tcp
HEALTHCHECK --interval=10s --timeout=5s --retries=30 CMD ["/app/wasp", "tools", "node-health"]
# Copy the app dir into distroless image
COPY --chown=nonroot:nonroot --from=build /app /app
COPY --chown=nonroot:nonroot --from=build /app/waspdb /app/waspdb
WORKDIR /app
USER nonroot
ENTRYPOINT ["/app/wasp"]