Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/storagenode: development Docker images for testing
This patch restores the Storagenode Docker image for development purposes. This is not replacement of the Storagenode image of the end users (https://github.com/storj/storagenode-docker). To avoid confusions, it's NOT pushed to Docker Registry, only to the development registry (img.dev.storj.io). Image supposed to be compatible with all environments (storj-up, Kubernetes environments, ...), but not public network (helper environment variables are intentionally missing). Change-Id: I15d23d61c74b23bc6589351996c244d36408a699
- Loading branch information
Showing
3 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
ARG DOCKER_ARCH | ||
ARG GO_VERSION=1.21 | ||
# Storagenode UI static asset generation | ||
FROM node:18.17.0 as ui | ||
WORKDIR /app | ||
COPY web/storagenode/ /app | ||
RUN ./build.sh | ||
|
||
# Fetch ca-certificates file for arch independent builds below | ||
FROM debian:buster-slim as ca-cert | ||
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates | ||
RUN update-ca-certificates | ||
|
||
# Install storj-up helper (for local/dev runs) | ||
FROM --platform=$TARGETPLATFORM golang:$GO_VERSION AS storjup | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
CGO_ENABLED=0 go install storj.io/storj-up@latest | ||
|
||
# Install dlv (for local/dev runs) | ||
FROM --platform=$TARGETPLATFORM golang:$GO_VERSION AS dlv | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
go install github.com/go-delve/delve/cmd/dlv@latest | ||
|
||
FROM ${DOCKER_ARCH:-amd64}/debian:buster-slim | ||
ARG TAG | ||
ARG GOARCH | ||
ENV GOARCH ${GOARCH} | ||
ENV PATH=$PATH:/app | ||
WORKDIR /app | ||
COPY --from=ui /app/static /app/static | ||
COPY --from=ca-cert /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
COPY release/${TAG}/storagenode_linux_${GOARCH:-amd64} /app/storagenode | ||
COPY release/${TAG}/identity_linux_${GOARCH:-amd64} /app/identity | ||
COPY --from=storjup /go/bin/storj-up /usr/local/bin/storj-up | ||
COPY --from=dlv /go/bin/dlv /usr/local/bin/dlv | ||
COPY cmd/storagenode/entrypoint /entrypoint | ||
ENTRYPOINT ["/entrypoint"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
if [ "${STORJ_IDENTITY_DIR:-""}" ]; then | ||
#Generate identity if missing | ||
if [ ! -f "$STORJ_IDENTITY_DIR/identity.key" ]; then | ||
identity --identity-dir $STORJ_IDENTITY_DIR --difficulty 0 create . | ||
fi | ||
fi | ||
|
||
if [ "${STORJ_NODE_IP:-""}" ]; then | ||
#Initialize config, required only to have all the dirs created | ||
: ${STORJ_CONTACT_EXTERNAL_ADDRESS:=$STORJ_NODE_IP:28967} | ||
fi | ||
|
||
if [ "${STORJ_STORAGENODE_CONSOLE_STATIC_DIR:-}" ]; then | ||
#This is a workaround to set different static dir for statellite/storagenode with env variables. | ||
: ${STORJ_CONSOLE_STATIC_DIR:=$STORJ_STORAGENODE_CONSOLE_STATIC_DIR} | ||
fi | ||
|
||
if [ "${STORJUP_ROLE:-""}" ]; then | ||
if [ "$STORJ_WAIT_FOR_SATELLITE" ]; then | ||
SATELLITE_ADDRESS=$(storj-up util wait-for-satellite satellite-api:7777) | ||
fi | ||
# storj-up uses environment variables, k8s may not have privileges to delete this | ||
if [ -f "/var/lib/storj/.local/share/storj/storagenode/config.yaml" ]; then | ||
rm "/var/lib/storj/.local/share/storj/storagenode/config.yaml" | ||
fi | ||
storagenode --identity-dir $STORJ_IDENTITY_DIR setup || true | ||
fi | ||
|
||
if [ "${GO_DLV:-""}" ]; then | ||
echo "Starting with go dlv" | ||
|
||
#absolute file path is required | ||
CMD=$(which $1) | ||
shift | ||
/usr/local/bin/dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec --check-go-version=false -- $CMD "$@" | ||
exit $? | ||
fi | ||
|
||
exec "$@" |