Skip to content

Add Lab to quickstart #678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -19,21 +21,28 @@ EXPOSE 5432
EXPOSE 8000
EXPOSE 6060
EXPOSE 6061
EXPOSE 8002
EXPOSE 11625
EXPOSE 11626

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 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the lab is a static website. Can we build the static site and host it with nginx instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is, but I asked in Slack anyway.

/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;

Expand Down
16 changes: 16 additions & 0 deletions Dockerfile.lab
Original file line number Diff line number Diff line change
@@ -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"]
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)"
Expand All @@ -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)
10 changes: 10 additions & 0 deletions common/lab/bin/start
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions common/nginx/etc/conf.d/lab.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
location /lab {
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8002;
}
9 changes: 9 additions & 0 deletions common/supervisor/etc/supervisord.conf.d/stellar-lab.conf
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions start
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -26,6 +27,7 @@ export PGPORT=5432
: "${ENABLE_LOGS:=false}"
: "${ENABLE_CORE:=false}"
: "${ENABLE_HORIZON:=false}"
: "${ENABLE_LAB:=false}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove the enable lab env and instead rely on the enable env var? The other ones for core and horizon are legacy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, the env can stay, but can we hook it into the ENABLE car as well?

# TODO: Remove once the Soroban RPC name is fully deprecated
: "${ENABLE_SOROBAN_RPC:=false}"
: "${ENABLE_RPC:=$ENABLE_SOROBAN_RPC}"
Expand Down Expand Up @@ -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() {
Expand Down
Loading