diff --git a/Dockerfile b/Dockerfile index f3d59c12e..21fafb609 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,12 +3,14 @@ ARG STELLAR_CORE_IMAGE_REF ARG HORIZON_IMAGE_REF ARG FRIENDBOT_IMAGE_REF ARG STELLAR_RPC_IMAGE_REF +ARG LAB_IMAGE_REF FROM $STELLAR_XDR_IMAGE_REF AS stellar-xdr FROM $STELLAR_CORE_IMAGE_REF AS stellar-core FROM $HORIZON_IMAGE_REF AS horizon FROM $FRIENDBOT_IMAGE_REF AS friendbot FROM $STELLAR_RPC_IMAGE_REF AS stellar-rpc +FROM $LAB_IMAGE_REF AS lab FROM ubuntu:22.04 @@ -19,6 +21,7 @@ EXPOSE 5432 EXPOSE 8000 EXPOSE 6060 EXPOSE 6061 +EXPOSE 8002 EXPOSE 11625 EXPOSE 11626 @@ -26,14 +29,20 @@ ADD dependencies / RUN /dependencies COPY --from=stellar-xdr /usr/local/cargo/bin/stellar-xdr /usr/local/bin/stellar-xdr - COPY --from=stellar-core /usr/local/bin/stellar-core /usr/bin/stellar-core - COPY --from=horizon /go/bin/horizon /usr/bin/stellar-horizon - COPY --from=friendbot /app/friendbot /usr/local/bin/friendbot - COPY --from=stellar-rpc /bin/stellar-rpc /usr/bin/stellar-rpc +COPY --from=lab /lab /opt/stellar/lab +COPY --from=lab /usr/local/bin/node \ + /usr/local/bin/npm \ + /usr/local/bin/corepack \ + /usr/local/bin/npx \ + /usr/local/bin/yarn \ + /usr/local/bin/yarnpkg \ + /usr/bin/ +COPY --from=lab /usr/local/include/node /usr/local/include/node +COPY --from=lab /usr/local/lib/node_modules /usr/local/lib/node_modules RUN adduser --system --group --quiet --home /var/lib/stellar --disabled-password --shell /bin/bash stellar; diff --git a/Dockerfile.lab b/Dockerfile.lab new file mode 100644 index 000000000..50111169b --- /dev/null +++ b/Dockerfile.lab @@ -0,0 +1,16 @@ +FROM node:22 AS builder + +ARG NEXT_PUBLIC_COMMIT_HASH +ENV NEXT_TELEMETRY_DISABLED=1 +ENV PORT=8002 +WORKDIR /lab +RUN git clone https://github.com/stellar/laboratory /lab +RUN git fetch origin ${NEXT_PUBLIC_COMMIT_HASH} +RUN git checkout ${NEXT_PUBLIC_COMMIT_HASH} +RUN yarn install +ENV NEXT_PUBLIC_DEFAULT_NETWORK=custom +ENV NEXT_BASE_PATH=/lab +RUN yarn build + +EXPOSE 8002 +CMD ["npm", "start"] diff --git a/Makefile b/Makefile index c15195c3a..5b13924e3 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ CORE_CONFIGURE_FLAGS?=--disable-tests STELLAR_RPC_REF?=main HORIZON_REF?=master FRIENDBOT_REF?=$(HORIZON_REF) +LAB_REF?=default-network run: docker run --rm --name stellar -p 8000:8000 stellar/quickstart:$(TAG) --local --enable-stellar-rpc @@ -58,8 +59,9 @@ build: --build-arg HORIZON_IMAGE_REF=stellar-horizon:$(HORIZON_REF) \ --build-arg FRIENDBOT_IMAGE_REF=stellar-friendbot:$(FRIENDBOT_REF) \ --build-arg STELLAR_RPC_IMAGE_REF=stellar-rpc:$(STELLAR_RPC_REF) \ + --build-arg LAB_IMAGE_REF=stellar-lab:$(LAB_REF) -build-deps: build-deps-xdr build-deps-core build-deps-horizon build-deps-friendbot build-deps-stellar-rpc +build-deps: build-deps-xdr build-deps-core build-deps-horizon build-deps-friendbot build-deps-stellar-rpc build-deps-lab build-deps-xdr: docker build -t stellar-xdr:$(XDR_REF) -f Dockerfile.xdr --target builder . --build-arg REPO="$(XDR_REPO)" --build-arg REF="$(XDR_REF)" @@ -75,3 +77,6 @@ build-deps-friendbot: build-deps-stellar-rpc: docker build -t stellar-rpc:$(STELLAR_RPC_REF) -f cmd/stellar-rpc/docker/Dockerfile --target build https://github.com/stellar/stellar-rpc.git#$(STELLAR_RPC_REF) --build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=true + +build-deps-lab: + docker build -t stellar-lab:$(LAB_REF) -f Dockerfile.lab --target builder . --build-arg NEXT_PUBLIC_COMMIT_HASH=$(LAB_REF) diff --git a/common/lab/bin/start b/common/lab/bin/start new file mode 100755 index 000000000..edb0c18af --- /dev/null +++ b/common/lab/bin/start @@ -0,0 +1,10 @@ +#! /bin/bash + +set -e +set -o pipefail + +echo "starting lab..." +export PORT=8002 +export NEXT_BASE_PATH=/lab +export NEXT_PUBLIC_DEFAULT_NETWORK=custom +./node_modules/.bin/next start diff --git a/common/nginx/etc/conf.d/lab.conf b/common/nginx/etc/conf.d/lab.conf new file mode 100644 index 000000000..b8af61ca0 --- /dev/null +++ b/common/nginx/etc/conf.d/lab.conf @@ -0,0 +1,4 @@ +location /lab { + proxy_set_header Host $http_host; + proxy_pass http://127.0.0.1:8002; +} diff --git a/common/supervisor/etc/supervisord.conf.d/stellar-lab.conf b/common/supervisor/etc/supervisord.conf.d/stellar-lab.conf new file mode 100644 index 000000000..21cd8b8bf --- /dev/null +++ b/common/supervisor/etc/supervisord.conf.d/stellar-lab.conf @@ -0,0 +1,9 @@ +[program:stellar-lab] +user=stellar +directory=/opt/stellar/lab +command=/opt/stellar-default/common/lab/bin/start +autostart=false +startretries=50 +autorestart=true +priority=60 +redirect_stderr=true diff --git a/start b/start index bc679b395..479dafc09 100644 --- a/start +++ b/start @@ -13,6 +13,7 @@ export SUPHOME="$STELLAR_HOME/supervisor" export COREHOME="$STELLAR_HOME/core" export HZHOME="$STELLAR_HOME/horizon" export FBHOME="$STELLAR_HOME/friendbot" +export LABHOME="$STELLAR_HOME/lab" export NXHOME="$STELLAR_HOME/nginx" export STELLAR_RPC_HOME="$STELLAR_HOME/stellar-rpc" @@ -26,6 +27,7 @@ export PGPORT=5432 : "${ENABLE_LOGS:=false}" : "${ENABLE_CORE:=false}" : "${ENABLE_HORIZON:=false}" +: "${ENABLE_LAB:=false}" # TODO: Remove once the Soroban RPC name is fully deprecated : "${ENABLE_SOROBAN_RPC:=false}" : "${ENABLE_RPC:=$ENABLE_SOROBAN_RPC}" @@ -617,13 +619,19 @@ function start_optional_services() { supervisorctl start postgresql supervisorctl start stellar-core fi + if [ "$ENABLE_HORIZON" == "true" ]; then supervisorctl start postgresql supervisorctl start horizon fi + if [ "$ENABLE_RPC" == "true" ]; then supervisorctl start stellar-rpc fi + + if [ "$ENABLE_LAB" == "true" ]; then + supervisorctl start stellar-lab + fi } function exec_supervisor() {