From fc54d51ad92f176763a0cfa4aa77cb679ef435dc Mon Sep 17 00:00:00 2001 From: sweexordious Date: Thu, 27 Jun 2024 16:38:27 +0100 Subject: [PATCH] chore: add docker --- Dockerfile | 47 ++++++++++++++++++++++++++++++++++++++++++++ docker/entrypoint.sh | 9 +++++++++ 2 files changed, 56 insertions(+) create mode 100644 Dockerfile create mode 100644 docker/entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..95cd7b6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,47 @@ +# stage 1 Build blobstream-ops binary +FROM --platform=$BUILDPLATFORM docker.io/golang:1.21.6-alpine3.18 as builder + +ARG TARGETOS +ARG TARGETARCH + +ENV CGO_ENABLED=0 +ENV GO111MODULE=on + +RUN apk update && apk --no-cache add make gcc musl-dev git bash + +COPY . /blobstream-ops +WORKDIR /blobstream-ops +RUN uname -a &&\ + CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ + make build + +# final image +FROM docker.io/alpine:3.20.1 + +ARG UID=10001 +ARG USER_NAME=celestia + +ENV CELESTIA_HOME=/home/${USER_NAME} + +# hadolint ignore=DL3018 +RUN apk update && apk add --no-cache \ + bash \ + curl \ + jq \ + # Creates a user with $UID and $GID=$UID + && adduser ${USER_NAME} \ + -D \ + -g ${USER_NAME} \ + -h ${CELESTIA_HOME} \ + -s /sbin/nologin \ + -u ${UID} + +COPY --from=builder /blobstream-ops/build/blobstream-ops /bin/blobstream-ops +COPY --chown=${USER_NAME}:${USER_NAME} docker/entrypoint.sh /opt/entrypoint.sh + +USER ${USER_NAME} + +# p2p port +EXPOSE 30000 + +ENTRYPOINT [ "/bin/bash", "/opt/entrypoint.sh" ] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100644 index 0000000..5c14be0 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +echo "Starting Celestia Blobstream-ops with command:" +echo "$@" +echo "" + +exec "$@"