-
Notifications
You must be signed in to change notification settings - Fork 16
/
Dockerfile.dev
72 lines (50 loc) · 2 KB
/
Dockerfile.dev
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
61
62
63
64
65
66
67
68
69
70
71
72
ARG WITH_GO_WORK=0
# https://hub.docker.com/_/golang
FROM golang:1.22-bookworm AS base
ARG BUILD_TAGS=rocksdb
LABEL org.label-schema.description="IOTA core node"
LABEL org.label-schema.name="iotaledger/iota-core"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.vcs-url="https://github.com/iotaledger/iota-core"
RUN mkdir /scratch /app
WORKDIR /scratch
FROM base AS env-with-go-work-0
# Here we assume our build context is the parent directory of iota-core
COPY . ./iota-core
# We don't want go.work files to interfere in this build environment
RUN rm -f /scratch/iota-core/go.work /scratch/iota-core/go.work.sum
FROM base AS env-with-go-work-1
COPY ./iota-core ./iota-core
COPY ./iota.go ./iota.go
COPY ./hive.go ./hive.go
COPY ./inx/go ./inx/go
COPY ./inx-app ./inx-app
COPY ./go.work ./
COPY ./go.work.sum ./
FROM env-with-go-work-${WITH_GO_WORK} AS build
WORKDIR /scratch/iota-core
# Ensure ca-certificates are up to date
RUN update-ca-certificates
ENV GOCACHE=/go/cache
# Download go modules
RUN --mount=type=cache,target=/go go mod download
# Do not verify modules if we have local modules coming from go.work
RUN --mount=type=cache,target=/go if [ "${WITH_GO_WORK}" = "0" ]; then go mod verify; fi
# Build the binary
RUN --mount=type=cache,target=/go go build -o /app/iota-core -tags="$BUILD_TAGS" -ldflags='-w -s'
# Copy the assets
RUN cp ./config_defaults.json /app/config.json
RUN cp ./peering.json /app/peering.json
RUN mkdir -p /app/data/p2p
############################
# Runtime Image
############################
# https://console.cloud.google.com/gcr/images/distroless/global/cc-debian12
# using distroless cc "nonroot" image, which includes everything in the base image (glibc, libssl and openssl)
FROM gcr.io/distroless/cc-debian12:nonroot
HEALTHCHECK --interval=10s --timeout=5s --retries=30 CMD ["/app/iota-core", "tools", "node-info"]
# Copy the app dir into distroless image
COPY --chown=nonroot:nonroot --from=build /app /app
WORKDIR /app
USER nonroot
ENTRYPOINT ["/app/iota-core"]