mirror of
https://github.com/alexgo-io/stacks-blockchain-api.git
synced 2026-01-12 22:43:34 +08:00
feat: docker cleanup
* cleaning up docker feat/cleanup needed it's own cleanup since it was so out of date. better to just start over with an up to date pull of develop * Update paths for docker-compose files * Updating paths and compose version * switch network to testnet * adjusting stacks-blockchain configs * use correct context to build api image * use the defaults from develop branch * feat: update to latest stacks blockchain * fix: rosetta output paths * chore: update stacks api to v0.71.2 Co-authored-by: Charlie <2747302+CharlieC3@users.noreply.github.com> * fix: remove magic_byte from mainnet toml Co-authored-by: Charlie <2747302+CharlieC3@users.noreply.github.com> * fix: update stacks node everywhere Co-authored-by: wileyj <2847772+wileyj@users.noreply.github.com> Co-authored-by: Charlie <2747302+CharlieC3@users.noreply.github.com>
This commit is contained in:
2
.github/workflows/stacks-blockchain-api.yml
vendored
2
.github/workflows/stacks-blockchain-api.yml
vendored
@@ -467,7 +467,7 @@ jobs:
|
||||
- name: Build/Tag/Push standalone Image
|
||||
uses: docker/build-push-action@v1
|
||||
with:
|
||||
dockerfile: follower.Dockerfile
|
||||
dockerfile: docker/stx-rosetta.Dockerfile
|
||||
repository: blockstack/${{ github.workflow }}-standalone
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
2
.gitpod.Dockerfile
vendored
2
.gitpod.Dockerfile
vendored
@@ -1,4 +1,4 @@
|
||||
FROM blockstack/stacks-blockchain:2.0.11.2.0-stretch as corenode
|
||||
FROM blockstack/stacks-blockchain:2.05.0.0.0-stretch as corenode
|
||||
|
||||
FROM gitpod/workspace-postgres
|
||||
|
||||
|
||||
2
docker/.gitignore
vendored
Normal file
2
docker/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
rosetta-output/
|
||||
rosetta-output-construction/
|
||||
@@ -1,11 +1,12 @@
|
||||
version: '3.7'
|
||||
version: "3"
|
||||
services:
|
||||
bitcoind:
|
||||
image: "ruimarinho/bitcoin-core:0.19.1-alpine"
|
||||
image: "blockstack/bitcoind:v0.20.99.0"
|
||||
ports:
|
||||
- "18443:18443"
|
||||
- "18444:18444"
|
||||
command:
|
||||
/usr/local/bin/bitcoind
|
||||
-printtoconsole
|
||||
-regtest=1
|
||||
-txindex=1
|
||||
@@ -2,9 +2,8 @@ version: '3.7'
|
||||
services:
|
||||
rosetta-cli:
|
||||
build:
|
||||
context: ./rosetta-cli-config
|
||||
context: ../rosetta-cli-config
|
||||
dockerfile: docker/Dockerfile
|
||||
command: ${CMD}
|
||||
volumes:
|
||||
- ${OUTPUT}
|
||||
|
||||
@@ -2,7 +2,7 @@ version: '3.7'
|
||||
services:
|
||||
stacks-blockchain:
|
||||
build:
|
||||
context: ./stacks-blockchain/docker
|
||||
context: ../stacks-blockchain/docker
|
||||
command: stacks-node start --config=/app/config/Stacks-follower.toml
|
||||
restart: on-failure
|
||||
environment:
|
||||
@@ -12,5 +12,5 @@ services:
|
||||
- "20443:20443"
|
||||
- "20444:20444"
|
||||
volumes:
|
||||
- ./stacks-blockchain/:/app/config
|
||||
- ./stacks-blockchain/.chaindata:/tmp/stacks-blockchain-data
|
||||
- ../stacks-blockchain/:/app/config
|
||||
- ../stacks-blockchain/.chaindata:/tmp/stacks-blockchain-data
|
||||
@@ -2,7 +2,7 @@ version: '3.7'
|
||||
services:
|
||||
stacks-blockchain:
|
||||
build:
|
||||
context: ./stacks-blockchain/docker
|
||||
context: ../stacks-blockchain/docker
|
||||
command: stacks-node start --config=/app/config/Stacks-dev.toml
|
||||
restart: on-failure
|
||||
environment:
|
||||
@@ -13,5 +13,5 @@ services:
|
||||
- "20443:20443"
|
||||
- "20444:20444"
|
||||
volumes:
|
||||
- ./stacks-blockchain/:/app/config
|
||||
- ./stacks-blockchain/.chaindata:/tmp/stacks-blockchain-data
|
||||
- ../stacks-blockchain/:/app/config
|
||||
- ../stacks-blockchain/.chaindata:/tmp/stacks-blockchain-data
|
||||
@@ -13,7 +13,7 @@ services:
|
||||
- backend
|
||||
stacks-blockchain:
|
||||
build:
|
||||
context: ./stacks-blockchain/docker
|
||||
context: ../stacks-blockchain/docker
|
||||
command: stacks-node start --config=/app/config/Stacks-follower.toml
|
||||
restart: on-failure
|
||||
environment:
|
||||
@@ -24,13 +24,13 @@ services:
|
||||
- "20443:20443"
|
||||
- "20444:20444"
|
||||
volumes:
|
||||
- ./stacks-blockchain/:/app/config
|
||||
- ./stacks-blockchain/.chaindata:/tmp/stacks-blockchain-data
|
||||
- ../stacks-blockchain/:/app/config
|
||||
- ../stacks-blockchain/.chaindata:/tmp/stacks-blockchain-data
|
||||
networks:
|
||||
- backend
|
||||
stacks-blockchain-api:
|
||||
build:
|
||||
context: .
|
||||
context: ..
|
||||
restart: on-failure
|
||||
environment:
|
||||
PG_HOST: postgres
|
||||
@@ -50,7 +50,7 @@ services:
|
||||
- "3999:3999"
|
||||
- "9153:9153"
|
||||
volumes:
|
||||
- ./stacks-blockchain/:/app/config
|
||||
- ../stacks-blockchain/:/app/config
|
||||
networks:
|
||||
- backend
|
||||
depends_on:
|
||||
@@ -1,15 +1,20 @@
|
||||
ARG STACKS_API_VERSION=v0.63.0
|
||||
ARG STACKS_NODE_VERSION=2.0.11.2.0
|
||||
ARG STACKS_API_REPO=hirosystems/stacks-blockchain-api
|
||||
ARG STACKS_API_VERSION=v0.71.2
|
||||
ARG STACKS_NODE_VERSION=2.05.0.0.0
|
||||
ARG STACKS_API_REPO=blockstack/stacks-blockchain-api
|
||||
ARG STACKS_NODE_REPO=blockstack/stacks-blockchain
|
||||
ARG PG_VERSION=12
|
||||
ARG STACKS_NETWORK=testnet
|
||||
ARG STACKS_NETWORK=mainnet
|
||||
ARG STACKS_LOG_DIR=/var/log/stacks-node
|
||||
ARG STACKS_SVC_DIR=/etc/service
|
||||
ARG STACKS_BLOCKCHAIN_DIR=/stacks-blockchain
|
||||
ARG STACKS_BLOCKCHAIN_API_DIR=/stacks-blockchain-api
|
||||
ARG PG_DATA=/data/postgres
|
||||
ARG V2_POX_MIN_AMOUNT_USTX=90000000260
|
||||
ARG PG_DATA=/data/postgres
|
||||
ARG PG_DATABASE=postgres
|
||||
ARG PG_HOST=127.0.0.1
|
||||
ARG PG_PORT=5432
|
||||
ARG PG_USER=postgres
|
||||
ARG PG_PASSWORD=postgres
|
||||
|
||||
#######################################################################
|
||||
## Build the stacks-blockchain-api
|
||||
@@ -60,13 +65,17 @@ ARG STACKS_BLOCKCHAIN_API_DIR
|
||||
ARG PG_DATA
|
||||
ARG PG_VERSION
|
||||
ARG V2_POX_MIN_AMOUNT_USTX
|
||||
ENV PG_HOST=127.0.0.1
|
||||
ENV PG_PORT=5432
|
||||
ENV PG_USER=postgres
|
||||
ENV PG_PASSWORD=postgres
|
||||
ENV PG_DATABASE=postgres
|
||||
ARG PG_HOST
|
||||
ARG PG_PORT
|
||||
ARG PG_USER
|
||||
ARG PG_PASSWORD
|
||||
ARG PG_DATABASE
|
||||
ENV PG_HOST=${PG_HOST}
|
||||
ENV PG_PORT=${PG_PORT}
|
||||
ENV PG_USER=${PG_USER}
|
||||
ENV PG_PASSWORD=${PG_PASSWORD}
|
||||
ENV PG_DATABASE=${PG_DATABASE}
|
||||
ENV PG_DATA=${PG_DATA}
|
||||
ENV PG_VERSION=${PG_VERSION}
|
||||
ENV STACKS_SVC_DIR=${STACKS_SVC_DIR}
|
||||
ENV STACKS_BLOCKCHAIN_DIR=${STACKS_BLOCKCHAIN_DIR}
|
||||
ENV STACKS_BLOCKCHAIN_API_DIR=${STACKS_BLOCKCHAIN_API_DIR}
|
||||
@@ -79,6 +88,7 @@ ENV STACKS_BLOCKCHAIN_API_PORT=3999
|
||||
ENV STACKS_BLOCKCHAIN_API_HOST=0.0.0.0
|
||||
ENV STACKS_CORE_RPC_HOST=127.0.0.1
|
||||
ENV STACKS_CORE_RPC_PORT=20443
|
||||
ENV STACKS_CORE_P2P_PORT=20444
|
||||
ENV MAINNET_STACKS_CHAIN_ID=0x00000001
|
||||
ENV TESTNET_STACKS_CHAIN_ID=0x80000000
|
||||
ENV V2_POX_MIN_AMOUNT_USTX=${V2_POX_MIN_AMOUNT_USTX}
|
||||
@@ -110,15 +120,14 @@ RUN mkdir -p \
|
||||
&& rm -rf /var/cache/apt/* /var/lib/apt/lists/* /tmp/* ${STACKS_SVC_DIR}/getty*
|
||||
COPY --from=stacks-blockchain-build /out ${STACKS_BLOCKCHAIN_DIR}
|
||||
COPY --from=stacks-blockchain-api-build /app ${STACKS_BLOCKCHAIN_API_DIR}
|
||||
RUN cp ${STACKS_BLOCKCHAIN_API_DIR}/stacks-blockchain/Stacks-mocknet.toml ${STACKS_BLOCKCHAIN_DIR}/Stacks-testnet.toml \
|
||||
&& cp ${STACKS_BLOCKCHAIN_API_DIR}/stacks-blockchain/Stacks-mocknet.toml ${STACKS_BLOCKCHAIN_DIR}/Stacks-mocknet.toml
|
||||
COPY stacks-blockchain/Stacks-*.toml ${STACKS_BLOCKCHAIN_DIR}/
|
||||
|
||||
###################################
|
||||
## runit service files
|
||||
RUN printf '#!/bin/sh\nexec 2>&1\n[ ! -d %s ] && mkdir -p %s && chown -R postgres:postgres %s && gosu postgres /usr/lib/postgresql/%s/bin/pg_ctl init -D %s\nexec gosu postgres /usr/lib/postgresql/%s/bin/postmaster -D %s' ${PG_DATA} ${PG_DATA} ${PG_DATA} ${PG_VERSION} ${PG_DATA} ${PG_VERSION} ${PG_DATA} > ${STACKS_SVC_DIR}/postgresql/run \
|
||||
&& printf '#!/bin/sh\nrm -rf %s' ${PG_DATA} > ${STACKS_SVC_DIR}/postgresql/finish \
|
||||
&& printf '#!/bin/sh\nexec svlogd -tt %s/postgresql' ${STACKS_LOG_DIR} > ${STACKS_SVC_DIR}/postgresql/log/run \
|
||||
&& printf '#!/bin/sh\nexec 2>&1\nif [ $STACKS_NETWORK != "mainnet" ]; then\n exec %s/stacks-node start --config=%s/Stacks-testnet.toml 2>&1\nelse\n exec %s/stacks-node mainnet 2>&1\nfi' ${STACKS_BLOCKCHAIN_DIR} ${STACKS_BLOCKCHAIN_DIR} ${STACKS_BLOCKCHAIN_DIR} > ${STACKS_SVC_DIR}/stacks-blockchain/run \
|
||||
&& printf '#!/bin/sh\nexec 2>&1\ncase $STACKS_NETWORK in\n testnet)\n exec %s/stacks-node start --config=%s/Stacks-testnet.toml 2>&1\n ;;\n mocknet)\n exec %s/stacks-node start --config=%s/Stacks-mocknet.toml 2>&1\n ;;\n *)\n exec %s/stacks-node start --config=%s/Stacks-mainnet.toml 2>&1\n ;;\nesac' ${STACKS_BLOCKCHAIN_DIR} ${STACKS_BLOCKCHAIN_DIR} ${STACKS_BLOCKCHAIN_DIR} ${STACKS_BLOCKCHAIN_DIR} ${STACKS_BLOCKCHAIN_DIR} ${STACKS_BLOCKCHAIN_DIR} > ${STACKS_SVC_DIR}/stacks-blockchain/run \
|
||||
&& printf '#!/bin/bash\nexec 2>&1\nsv start postgresql stacks-blockchain || exit 1\nif [ $STACKS_NETWORK != "mainnet" ]; then\n export STACKS_CHAIN_ID=%s\nelse\n export STACKS_CHAIN_ID=%s\n export V2_POX_MIN_AMOUNT_USTX=%s\nfi\ncd %s && exec node ./lib/index.js 2>&1' ${TESTNET_STACKS_CHAIN_ID} ${MAINNET_STACKS_CHAIN_ID} ${V2_POX_MIN_AMOUNT_USTX} ${STACKS_BLOCKCHAIN_API_DIR} > ${STACKS_SVC_DIR}/stacks-blockchain-api/run \
|
||||
&& printf '#!/bin/sh\nexec svlogd -tt %s/stacks-blockchain-api' ${STACKS_LOG_DIR} > ${STACKS_SVC_DIR}/stacks-blockchain-api/log/run \
|
||||
&& printf '#!/bin/sh\n/usr/bin/runsvdir %s' ${STACKS_SVC_DIR} > /entrypoint.sh \
|
||||
@@ -131,6 +140,6 @@ RUN printf '#!/bin/sh\nexec 2>&1\n[ ! -d %s ] && mkdir -p %s && chown -R postgre
|
||||
${STACKS_SVC_DIR}/stacks-blockchain-api/log/run \
|
||||
/entrypoint.sh
|
||||
|
||||
EXPOSE ${STACKS_BLOCKCHAIN_API_PORT} ${STACKS_CORE_RPC_PORT}
|
||||
EXPOSE ${STACKS_BLOCKCHAIN_API_PORT} ${STACKS_CORE_RPC_PORT} ${STACKS_CORE_P2P_PORT}
|
||||
VOLUME /data
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD ["/entrypoint.sh"]
|
||||
@@ -1,120 +0,0 @@
|
||||
### Build blockstack-core-sidecar API
|
||||
FROM node:14-alpine as build
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN apk add --no-cache --virtual .build-deps alpine-sdk python2 git openjdk8-jre
|
||||
RUN echo "GIT_TAG=$(git tag --points-at HEAD)" >> .env
|
||||
RUN npm config set unsafe-perm true && npm install && npm run build && npm prune --production
|
||||
|
||||
### Fetch stacks-node binary
|
||||
FROM blockstack/stacks-blockchain:2.0.11.2.0-stretch as stacks-node-build
|
||||
|
||||
### Begin building base image
|
||||
FROM ubuntu:focal
|
||||
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
|
||||
### Install utils
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y sudo curl pslist
|
||||
|
||||
### Install nodejs
|
||||
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
|
||||
RUN apt-get install -y nodejs
|
||||
|
||||
### Set noninteractive apt-get
|
||||
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
|
||||
|
||||
### stacky user ###
|
||||
# see https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
|
||||
RUN useradd -l -u 33333 -G sudo -md /home/stacky -s /bin/bash -p stacky stacky \
|
||||
# passwordless sudo for users in the 'sudo' group
|
||||
&& sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers
|
||||
ENV HOME=/home/stacky
|
||||
WORKDIR $HOME
|
||||
USER stacky
|
||||
RUN sudo chown -R stacky:stacky $HOME
|
||||
RUN mkdir /home/stacky/.bashrc.d
|
||||
|
||||
### Setup stacks-node
|
||||
COPY --from=stacks-node-build /bin/stacks-node stacks-node/
|
||||
ENV PATH="$PATH:$HOME/stacks-node"
|
||||
|
||||
#### Copy stacks-node mocknet config
|
||||
COPY ./stacks-blockchain/Stacks-mocknet.toml ./
|
||||
|
||||
### Setup stacks-blockchain-api
|
||||
COPY --from=build /app stacks-blockchain-api
|
||||
RUN sudo chown -Rh stacky:stacky stacks-blockchain-api
|
||||
RUN printf '#!/bin/bash\ncd $(dirname $0)\nnpm run start\n' > stacks-blockchain-api/stacks_api \
|
||||
&& chmod +x stacks-blockchain-api/stacks_api
|
||||
ENV PATH="$PATH:$HOME/stacks-blockchain-api"
|
||||
EXPOSE 3999
|
||||
|
||||
### Install Postgres
|
||||
RUN sudo apt-get install -y postgresql-12 postgresql-contrib-12
|
||||
|
||||
### Setup Postgres
|
||||
# Borrowed from https://github.com/gitpod-io/workspace-images/blob/master/postgres/Dockerfile
|
||||
ENV PATH="$PATH:/usr/lib/postgresql/12/bin"
|
||||
ENV PGDATA="/home/stacky/.pgsql/data"
|
||||
RUN mkdir -p ~/.pg_ctl/bin ~/.pg_ctl/sockets \
|
||||
&& printf '#!/bin/bash\n[ ! -d $PGDATA ] && mkdir -p $PGDATA && initdb -D $PGDATA\npg_ctl -D $PGDATA -l ~/.pg_ctl/log -o "-k ~/.pg_ctl/sockets" start\n' > ~/.pg_ctl/bin/pg_start \
|
||||
&& printf '#!/bin/bash\npg_ctl -D $PGDATA -l ~/.pg_ctl/log -o "-k ~/.pg_ctl/sockets" stop\n' > ~/.pg_ctl/bin/pg_stop \
|
||||
&& chmod +x ~/.pg_ctl/bin/*
|
||||
ENV PATH="$PATH:$HOME/.pg_ctl/bin"
|
||||
|
||||
### Clear caches
|
||||
RUN sudo apt-get clean && sudo rm -rf /var/cache/apt/* /var/lib/apt/lists/* /tmp/*
|
||||
|
||||
### Setup service env vars
|
||||
ENV PG_HOST=127.0.0.1
|
||||
ENV PG_PORT=5432
|
||||
ENV PG_USER=stacky
|
||||
ENV PG_PASSWORD=postgres
|
||||
ENV PG_DATABASE=postgres
|
||||
|
||||
ENV STACKS_CORE_EVENT_PORT=3700
|
||||
ENV STACKS_CORE_EVENT_HOST=127.0.0.1
|
||||
|
||||
ENV STACKS_EVENT_OBSERVER=127.0.0.1:3700
|
||||
|
||||
ENV STACKS_BLOCKCHAIN_API_PORT=3999
|
||||
ENV STACKS_BLOCKCHAIN_API_HOST=0.0.0.0
|
||||
|
||||
ENV STACKS_CORE_RPC_HOST=127.0.0.1
|
||||
ENV STACKS_CORE_RPC_PORT=20443
|
||||
|
||||
### Startup script & coordinator
|
||||
RUN printf '#!/bin/bash\n\
|
||||
MAINNET_ID=0x00000001\n\
|
||||
MOCKNET_ID=0x80000000\n\
|
||||
[ $1 = "mocknet" ] && STACKS_CHAIN_ID="${MOCKNET_ID}" || STACKS_CHAIN_ID="${MAINNET_ID}"\n\
|
||||
export STACKS_CHAIN_ID\n\
|
||||
trap "exit" INT TERM\n\
|
||||
trap "kill 0" EXIT\n\
|
||||
echo Your container args are: "$@"\n\
|
||||
tail --retry -F stacks-api.log stacks-node.log 2>&1 &\n\
|
||||
while true\n\
|
||||
do\n\
|
||||
pg_start\n\
|
||||
stacks_api &> stacks-api.log &\n\
|
||||
stacks_api_pid=$!\n\
|
||||
if [ $1 = "mocknet" ]; then\n\
|
||||
stacks-node start --config=/home/stacky/Stacks-mocknet.toml &> stacks-node.log &\n\
|
||||
else\n\
|
||||
stacks-node mainnet &> stacks-node.log &\n\
|
||||
fi\n\
|
||||
stacks_node_pid=$!\n\
|
||||
wait $stacks_node_pid\n\
|
||||
echo "node exit, restarting..."\n\
|
||||
rkill -9 $stacks_api_pid\n\
|
||||
pg_stop\n\
|
||||
rm -rf $PGDATA\n\
|
||||
sleep 5\n\
|
||||
done\n\
|
||||
' >> run.sh && chmod +x run.sh
|
||||
|
||||
ENTRYPOINT ["/home/stacky/run.sh"]
|
||||
|
||||
CMD ["/home/stacky/run.sh"]
|
||||
14
package.json
14
package.json
@@ -30,13 +30,13 @@
|
||||
"lint:prettier": "prettier --check src/**/*.{ts,json}",
|
||||
"lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx -f codeframe --fix && prettier --write --check src/**/*.{ts,json}",
|
||||
"migrate": "node-pg-migrate -m src/migrations",
|
||||
"devenv:build": "docker-compose -f docker-compose.dev.postgres.yml -f docker-compose.dev.stacks-blockchain.yml -f docker-compose.dev.bitcoind.yml -f docker-compose.dev.rosetta-cli.yml build --no-cache",
|
||||
"devenv:deploy": "docker-compose -f docker-compose.dev.postgres.yml -f docker-compose.dev.stacks-blockchain.yml -f docker-compose.dev.bitcoind.yml up",
|
||||
"devenv:deploy:pg": "docker-compose -f docker-compose.dev.postgres.yml up",
|
||||
"devenv:follower": "docker-compose -f docker-compose.dev.postgres.yml -f docker-compose.dev.stacks-blockchain-follower.yml up",
|
||||
"devenv:stop": "docker-compose -f docker-compose.dev.postgres.yml -f docker-compose.dev.stacks-blockchain.yml -f docker-compose.dev.bitcoind.yml down -v -t 0",
|
||||
"devenv:stop:pg": "docker-compose -f docker-compose.dev.postgres.yml kill",
|
||||
"devenv:logs": "docker-compose -f docker-compose.dev.postgres.yml -f docker-compose.dev.stacks-blockchain.yml -f docker-compose.dev.bitcoind.yml logs -t -f"
|
||||
"devenv:build": "docker-compose -f docker/docker-compose.dev.postgres.yml -f docker/docker-compose.dev.stacks-blockchain.yml -f docker/docker-compose.dev.bitcoind.yml -f docker/docker-compose.dev.rosetta-cli.yml build --no-cache",
|
||||
"devenv:deploy": "docker-compose -f docker/docker-compose.dev.postgres.yml -f docker/docker-compose.dev.stacks-blockchain.yml -f docker/docker-compose.dev.bitcoind.yml up",
|
||||
"devenv:deploy:pg": "docker-compose -f docker/docker-compose.dev.postgres.yml up",
|
||||
"devenv:follower": "docker-compose -f docker/docker-compose.dev.postgres.yml -f docker/docker-compose.dev.stacks-blockchain-follower.yml up",
|
||||
"devenv:stop": "docker-compose -f docker/docker-compose.dev.postgres.yml -f docker/docker-compose.dev.stacks-blockchain.yml -f docker/docker-compose.dev.bitcoind.yml down -v -t 0",
|
||||
"devenv:stop:pg": "docker-compose -f docker/docker-compose.dev.postgres.yml kill",
|
||||
"devenv:logs": "docker-compose -f docker/docker-compose.dev.postgres.yml -f docker/docker-compose.dev.stacks-blockchain.yml -f docker/docker-compose.dev.bitcoind.yml logs -t -f"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -16,9 +16,15 @@ RUN mkdir -p /bin /app
|
||||
|
||||
COPY --from=build /bin/rosetta-cli /bin/
|
||||
|
||||
COPY docker/docker-entrypoint.sh /bin
|
||||
COPY docker/docker-entrypoint.sh /bin/
|
||||
RUN chmod +x /bin/docker-entrypoint.sh
|
||||
|
||||
COPY docker/start-construction.sh /bin/
|
||||
RUN chmod +x /bin/start-construction.sh
|
||||
|
||||
COPY docker/start-data.sh /bin/
|
||||
RUN chmod +x /bin/start-data.sh
|
||||
|
||||
COPY . /app
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
3
rosetta-cli-config/docker/start-construction.sh
Normal file
3
rosetta-cli-config/docker/start-construction.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
/bin/rosetta-cli --configuration-file /app/rosetta-config-docker.json check:construction
|
||||
chmod -R 777 /app/rosetta-output
|
||||
3
rosetta-cli-config/docker/start-data.sh
Normal file
3
rosetta-cli-config/docker/start-data.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
/bin/rosetta-cli --configuration-file /app/rosetta-config-docker.json check:data
|
||||
chmod -R 777 /app/rosetta-output
|
||||
@@ -1,2 +1,2 @@
|
||||
CMD=/bin/rosetta-cli --configuration-file /app/rosetta-config-docker.json check:construction
|
||||
CMD="/bin/start-construction.sh"
|
||||
OUTPUT=./rosetta-output-construction:/app/rosetta-output
|
||||
|
||||
@@ -9,11 +9,9 @@ import { StacksTestnet } from '@stacks/network';
|
||||
import * as BN from 'bn.js';
|
||||
import * as fs from 'fs';
|
||||
import { StacksCoreRpcClient, getCoreNodeEndpoint } from '../core-rpc/client';
|
||||
import { timeout } from '../helpers';
|
||||
import * as compose from 'docker-compose';
|
||||
import * as path from 'path';
|
||||
import Docker = require('dockerode');
|
||||
|
||||
const docker = new Docker();
|
||||
|
||||
const sender1 = {
|
||||
address: 'STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6',
|
||||
@@ -26,22 +24,6 @@ const HOST = 'localhost';
|
||||
const PORT = 20443;
|
||||
const stacksNetwork = GetStacksTestnetNetwork();
|
||||
|
||||
const isContainerRunning = async (name: string): Promise<boolean> =>
|
||||
new Promise((resolve, reject): void => {
|
||||
docker.listContainers((err: any, containers: any): void => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
|
||||
const running = (containers || []).filter((container: any): boolean =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
container.Names.includes(name)
|
||||
);
|
||||
|
||||
resolve(running.length > 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Rosetta API', () => {
|
||||
let db: PgDataStore;
|
||||
let client: PoolClient;
|
||||
@@ -57,16 +39,13 @@ describe('Rosetta API', () => {
|
||||
eventServer = await startEventServer({ datastore: db, chainId: ChainID.Testnet });
|
||||
api = await startApiServer({ datastore: db, chainId: ChainID.Testnet });
|
||||
|
||||
// remove previous outputs if any
|
||||
fs.rmdirSync('rosetta-output-construction', { recursive: true });
|
||||
|
||||
// build rosetta-cli container
|
||||
await compose.buildOne('rosetta-cli', {
|
||||
cwd: path.join(__dirname, '../../'),
|
||||
log: true,
|
||||
composeOptions: [
|
||||
'-f',
|
||||
'docker-compose.dev.rosetta-cli.yml',
|
||||
'docker/docker-compose.dev.rosetta-cli.yml',
|
||||
'--env-file',
|
||||
'src/tests-rosetta-cli-construction/envs/env.construction',
|
||||
],
|
||||
@@ -77,7 +56,7 @@ describe('Rosetta API', () => {
|
||||
log: true,
|
||||
composeOptions: [
|
||||
'-f',
|
||||
'docker-compose.dev.rosetta-cli.yml',
|
||||
'docker/docker-compose.dev.rosetta-cli.yml',
|
||||
'--env-file',
|
||||
'src/tests-rosetta-cli-construction/envs/env.construction',
|
||||
],
|
||||
@@ -85,18 +64,20 @@ describe('Rosetta API', () => {
|
||||
});
|
||||
|
||||
await waitForBlock(api);
|
||||
// await sleep(10000);
|
||||
|
||||
await transferStx(recipientAdd1, 1000000000, sender1.privateKey, api);
|
||||
await transferStx(recipientAdd1, 1000000000, sender1.privateKey, api);
|
||||
await transferStx(recipientAdd1, 1000000000, sender1.privateKey, api);
|
||||
await transferStx(recipientAdd1, 1000000000, sender1.privateKey, api);
|
||||
await transferStx(recipientAdd1, 1000000000, sender1.privateKey, api);
|
||||
|
||||
//wait on rosetta-cli to finish output
|
||||
// Wait on rosetta-cli to finish output
|
||||
while (!rosettaOutput) {
|
||||
if (fs.existsSync('rosetta-output-construction/rosetta-cli-output-const.json'))
|
||||
rosettaOutput = require('../../rosetta-output-construction/rosetta-cli-output-const.json');
|
||||
await sleep(1000);
|
||||
if (fs.existsSync('docker/rosetta-output-construction/rosetta-cli-output-const.json')) {
|
||||
rosettaOutput = require('../../docker/rosetta-output-construction/rosetta-cli-output-const.json');
|
||||
} else {
|
||||
await timeout(1000);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
CMD=/bin/rosetta-cli --configuration-file /app/rosetta-config-docker.json check:data
|
||||
CMD="/bin/start-data.sh"
|
||||
OUTPUT=./rosetta-output:/app/rosetta-output
|
||||
|
||||
@@ -26,9 +26,6 @@ import { StacksCoreRpcClient, getCoreNodeEndpoint } from '../core-rpc/client';
|
||||
import { timeout, unwrapOptional } from '../helpers';
|
||||
import * as compose from 'docker-compose';
|
||||
import * as path from 'path';
|
||||
import Docker = require('dockerode');
|
||||
|
||||
const docker = new Docker();
|
||||
|
||||
const sender1 = {
|
||||
address: 'STF9B75ADQAVXQHNEQ6KGHXTG7JP305J2GRWF3A2',
|
||||
@@ -97,22 +94,6 @@ const HOST = 'localhost';
|
||||
const PORT = 20443;
|
||||
const stacksNetwork = getStacksTestnetNetwork();
|
||||
|
||||
const isContainerRunning = async (name: string): Promise<boolean> =>
|
||||
new Promise((resolve, reject): void => {
|
||||
docker.listContainers((err: any, containers: any): void => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
|
||||
const running = (containers || []).filter((container: any): boolean =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
container.Names.includes(name)
|
||||
);
|
||||
|
||||
resolve(running.length > 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Rosetta API', () => {
|
||||
let db: PgDataStore;
|
||||
let client: PoolClient;
|
||||
@@ -128,16 +109,13 @@ describe('Rosetta API', () => {
|
||||
eventServer = await startEventServer({ datastore: db, chainId: ChainID.Testnet });
|
||||
api = await startApiServer({ datastore: db, chainId: ChainID.Testnet });
|
||||
|
||||
// remove previous outputs if any
|
||||
fs.rmdirSync('rosetta-output', { recursive: true });
|
||||
|
||||
// build rosetta-cli container
|
||||
await compose.buildOne('rosetta-cli', {
|
||||
cwd: path.join(__dirname, '../../'),
|
||||
log: true,
|
||||
composeOptions: [
|
||||
'-f',
|
||||
'docker-compose.dev.rosetta-cli.yml',
|
||||
'docker/docker-compose.dev.rosetta-cli.yml',
|
||||
'--env-file',
|
||||
'src/tests-rosetta-cli-data/envs/env.data',
|
||||
],
|
||||
@@ -148,7 +126,7 @@ describe('Rosetta API', () => {
|
||||
log: true,
|
||||
composeOptions: [
|
||||
'-f',
|
||||
'docker-compose.dev.rosetta-cli.yml',
|
||||
'docker/docker-compose.dev.rosetta-cli.yml',
|
||||
'--env-file',
|
||||
'src/tests-rosetta-cli-data/envs/env.data',
|
||||
],
|
||||
@@ -177,11 +155,13 @@ describe('Rosetta API', () => {
|
||||
await callContractFunction(api, sender2.privateKey, contract, 'say-hi');
|
||||
}
|
||||
|
||||
//wait on rosetta-cli to finish output
|
||||
// Wait on rosetta-cli to finish output
|
||||
while (!rosettaOutput) {
|
||||
if (fs.existsSync('rosetta-output'))
|
||||
rosettaOutput = require('../../rosetta-output/rosetta-cli-output.json');
|
||||
await timeout(1000);
|
||||
if (fs.existsSync('docker/rosetta-output/rosetta-cli-output.json')) {
|
||||
rosettaOutput = require('../../docker/rosetta-output/rosetta-cli-output.json');
|
||||
} else {
|
||||
await timeout(1000);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
14
stacks-blockchain/Stacks-mainnet.toml
Normal file
14
stacks-blockchain/Stacks-mainnet.toml
Normal file
@@ -0,0 +1,14 @@
|
||||
[node]
|
||||
rpc_bind = "0.0.0.0:20443"
|
||||
p2p_bind = "0.0.0.0:20444"
|
||||
bootstrap_node = "02da7a464ac770ae8337a343670778b93410f2f3fef6bea98dd1c3e9224459d36b@seed-0.mainnet.stacks.co:20444,02afeae522aab5f8c99a00ddf75fbcb4a641e052dd48836408d9cf437344b63516@seed-1.mainnet.stacks.co:20444,03652212ea76be0ed4cd83a25c06e57819993029a7b9999f7d63c36340b34a4e62@seed-2.mainnet.stacks.co:20444"
|
||||
# working_dir = "/tmp/stacks-blockchain-data"
|
||||
|
||||
[burnchain]
|
||||
chain = "bitcoin"
|
||||
mode = "mainnet"
|
||||
peer_host = "bitcoin.blockstack.com"
|
||||
username = "blockstack"
|
||||
password = "blockstacksystem"
|
||||
rpc_port = 8332
|
||||
peer_port = 8333
|
||||
37
stacks-blockchain/Stacks-testnet.toml
Normal file
37
stacks-blockchain/Stacks-testnet.toml
Normal file
@@ -0,0 +1,37 @@
|
||||
[node]
|
||||
rpc_bind = "0.0.0.0:20443"
|
||||
p2p_bind = "0.0.0.0:20444"
|
||||
bootstrap_node = "047435c194e9b01b3d7f7a2802d6684a3af68d05bbf4ec8f17021980d777691f1d51651f7f1d566532c804da506c117bbf79ad62eea81213ba58f8808b4d9504ad@testnet.stacks.co:20444"
|
||||
# working_dir = "/tmp/stacks-blockchain-data"
|
||||
|
||||
|
||||
[burnchain]
|
||||
chain = "bitcoin"
|
||||
mode = "xenon"
|
||||
peer_host = "bitcoind.testnet.stacks.co"
|
||||
username = "blockstack"
|
||||
password = "blockstacksystem"
|
||||
rpc_port = 18332
|
||||
peer_port = 18333
|
||||
|
||||
# Used for sending events to a local stacks-blockchain-api service
|
||||
[[events_observer]]
|
||||
endpoint = "localhost:3700"
|
||||
retry_count = 255
|
||||
events_keys = ["*"]
|
||||
|
||||
[[mstx_balance]]
|
||||
address = "ST2QKZ4FKHAH1NQKYKYAYZPY440FEPK7GZ1R5HBP2"
|
||||
amount = 10000000000000000
|
||||
|
||||
[[mstx_balance]]
|
||||
address = "ST319CF5WV77KYR1H3GT0GZ7B8Q4AQPY42ETP1VPF"
|
||||
amount = 10000000000000000
|
||||
|
||||
[[mstx_balance]]
|
||||
address = "ST221Z6TDTC5E0BYR2V624Q2ST6R0Q71T78WTAX6H"
|
||||
amount = 10000000000000000
|
||||
|
||||
[[mstx_balance]]
|
||||
address = "ST2TFVBMRPS5SSNP98DQKQ5JNB2B6NZM91C4K3P7B"
|
||||
amount = 10000000000000000
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM blockstack/stacks-blockchain:2.0.11.2.0-stretch as build
|
||||
FROM blockstack/stacks-blockchain:2.05.0.0.0-stretch as build
|
||||
|
||||
FROM debian:stretch
|
||||
|
||||
|
||||
Reference in New Issue
Block a user