-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
72 lines (64 loc) · 2.29 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
61
62
63
64
65
66
67
68
69
70
71
72
# This Dockerfile performs a multi-stage build. BUILDER_IMAGE is the image used
# to compile the celestia-appd binary. RUNTIME_IMAGE is the image that will be
# returned with the final celestia-appd binary.
#
# Separating the builder and runtime image allows the runtime image to be
# considerably smaller because it doesn't need to have Golang installed.
ARG BUILDER_IMAGE=docker.io/golang:1.23.2-alpine
ARG RUNTIME_IMAGE=docker.io/alpine:3.19.1
ARG TARGETOS
ARG TARGETARCH
# Stage 1: Build the celestia-appd binary inside a builder image that will be discarded later.
# Ignore hadolint rule because hadolint can't parse the variable.
# See https://github.com/hadolint/hadolint/issues/339
# hadolint ignore=DL3006
FROM --platform=$BUILDPLATFORM ${BUILDER_IMAGE} AS builder
ENV CGO_ENABLED=1
ENV GO111MODULE=on
# hadolint ignore=DL3018
RUN apk update && apk add --no-cache \
gcc \
git \
# linux-headers are needed for Ledger support
linux-headers \
make \
musl-dev \
build-base \
libc-dev
COPY . /nitro-das-celestia
WORKDIR /nitro-das-celestia/cmd
RUN go clean -modcache && \
go mod tidy && \
uname -a && \
CGO_ENABLED=1 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -o celestia-server
FROM ${RUNTIME_IMAGE} AS runtime
# Use UID 10,001 because UIDs below 10,000 are a security risk.
# Ref: https://github.com/hexops/dockerfile/blob/main/README.md#do-not-use-a-uid-below-10000
ARG UID=10001
ARG USER_NAME=apollo
ENV APOLLO_HOME=/home/${USER_NAME}
ENV RPC_ADDR=""
ENV RPC_PORT=""
ENV AUTH_TOKEN=""
ENV GAS_PRICE=""
ENV GAS_MULTIPLIER=""
ENV NAMESPACEID=""
ENV CELESTIA_NODE_ENDPOINT=""
# hadolint ignore=DL3018
RUN apk update && apk add --no-cache \
bash \
curl \
jq \
&& adduser ${USER_NAME} \
-D \
-g ${USER_NAME} \
-h ${APOLLO_HOME} \
-s /sbin/nologin \
-u ${UID}
COPY --from=builder /nitro-das-celestia/cmd/celestia-server /bin/celestia-server
#Set the user
USER ${USER_NAME}
# Expose ports:
EXPOSE 1317 9090 26657 1095 8080 26658
ENTRYPOINT ["sh", "-c", "/bin/celestia-server --enable-rpc --rpc-addr $RPC_ADDR --rpc-port $RPC_PORT --celestia.auth-token $AUTH_TOKEN --celestia.gas-price $GAS_PRICE --celestia.gas-multiplier $GAS_MULTIPLIER --celestia.namespace-id $NAMESPACEID --celestia.rpc $CELESTIA_NODE_ENDPOINT --celestia.keyname $KEYNAME"]