Skip to content

Commit e86bf52

Browse files
fariedtdiwakergupta
authored andcommitted
chore: make STACKS_NETWORK an ARG for the rosetta docker file
STACKS_NETWORK defaults to testnet, but can be set to mocknet, dev, and testnet. testnet and mocknet use the same Stacks-mocknet.toml configuration file, and dev uses Stacks-dev.toml. If it's set to something else, it runs stacks-node krypton. Tested with docker build -t stx-rosetta:stable -f stx-rosetta.Dockerfile . docker run --rm -p 3999:3999 --mount source=rosetta-data,target=/data \ -e STACKS_NETWORK=dev stx-rosetta:stable docker run --rm -p 3999:3999 --mount source=rosetta-data,target=/data \ -e STACKS_NETWORK=mainnet stx-rosetta:stable docker run --rm -p 3999:3999 --mount source=rosetta-data,target=/data \ -e STACKS_NETWORK=testnet stx-rosetta:stable and by calling curl -d '' -s http://localhost:3999/rosetta/v1/network/list and docker exec -it the-container-id /bin/bash # echo $STACKS_NETWORK # ps auxww | grep stacks-node This depends on a change in commit #db8e3ad44dbb45287a64d678f07de97644fc299c; see line 11 in the stx-rosetta.Dockerfile to test without that change.
1 parent 88b9799 commit e86bf52

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

stx-rosetta.Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ RUN apt-get -y update && apt-get -y install openjdk-11-jre-headless
88
WORKDIR /app
99

1010
RUN git clone -b $API_TAG --depth 1 https://github.com/blockstack/stacks-blockchain-api.git .
11+
# COPY ./rosetta-constants.ts /app/src/api/
12+
RUN grep process.env.STACKS_NETWORK /app/src/api/rosetta-constants.ts
1113
RUN echo "GIT_TAG=$(git tag --points-at HEAD)" >> .env
1214
RUN npm install && npm run build && npm prune --production
13-
# RUN npm config set unsafe-perm true && npm install --unsafe-perm
14-
# RUN npm run build --unsafe-perm && npm prune --production
1515

1616
### Build stacks-node binary
1717

@@ -31,6 +31,8 @@ RUN cp -R /src/target/x86_64-unknown-linux-gnu/release/. /stacks
3131
### Begin building base image
3232
FROM ubuntu:focal
3333

34+
ARG STACKS_NETWORK=testnet
35+
3436
SHELL ["/bin/bash", "-c"]
3537

3638
### Install utils
@@ -105,6 +107,7 @@ ENV PG_DATABASE=postgres
105107

106108
ENV STACKS_CORE_EVENT_PORT=3700
107109
ENV STACKS_CORE_EVENT_HOST=127.0.0.1
110+
ENV STACKS_NETWORK=$STACKS_NETWORK
108111

109112
ENV STACKS_EVENT_OBSERVER=127.0.0.1:3700
110113

@@ -125,7 +128,9 @@ do\n\
125128
pg_start\n\
126129
stacks_api &> stacks-api.log &\n\
127130
stacks_api_pid=$!\n\
128-
if [ $1 = "mocknet" ]; then\n\
131+
if [ $STACKS_NETWORK = "mocknet" -o $STACKS_NETWORK = "dev" ]; then\n\
132+
stacks-node start --config=/data/stacky/Stacks-${STACKS_NETWORK}.toml &> stacks-node.log &\n\
133+
elif [ $STACKS_NETWORK = "testnet"]; then \n\
129134
stacks-node start --config=/data/stacky/Stacks-mocknet.toml &> stacks-node.log &\n\
130135
else\n\
131136
stacks-node krypton &> stacks-node.log &\n\

0 commit comments

Comments
 (0)