feat: allow for running the development process in Docker container

This commit is contained in:
grdddj
2024-11-25 11:28:02 +01:00
parent df44dabfb8
commit a4e659da77
3 changed files with 43 additions and 1 deletions

View File

@@ -59,3 +59,5 @@ ADD Makefile /build/Makefile
VOLUME /out
WORKDIR /build
CMD ["sh", "-c", "while true; do sleep 1000; done"]

View File

@@ -14,5 +14,5 @@ go build
echo "Generating bitcoin regtest config..."
./contrib/scripts/build-blockchaincfg.sh bitcoin_regtest
echo "Running blockbook..."
echo "Running blockbook, visit http://localhost:9130/ in the browser..."
./blockbook -sync -blockchaincfg=build/blockchaincfg.json -internal=:9030 -public=:9130 -logtostderr -enablesubnewtx

40
workshop/docker_run.md Normal file
View File

@@ -0,0 +1,40 @@
```sh
# Build the building image
make .bin-image
# Run the image with mounted code volume and network connections
docker run -v ".:/src" -v "./build:/out" --network=host blockbook-build
# Look at running containers
docker ps
# Get the container ID for the blockbook-build container
CONTAINER_ID=$(docker ps -q --filter ancestor=blockbook-build)
# Get a shell in the container
docker exec -it $CONTAINER_ID /bin/bash
# Full copyable command
docker exec -it $(docker ps -q --filter ancestor=blockbook-build) /bin/bash
---
# INSIDE THE CONTAINER
# Go to the source code directory
cd /src
# Build the main binary
go build
# Regenerate config
./contrib/scripts/build-blockchaincfg.sh bitcoin_regtest
# Run the app ... logs should be visible in the terminal
./blockbook -sync -blockchaincfg=build/blockchaincfg.json -internal=:9030 -public=:9130 -logtostderr -enablesubnewtx
# Visit http://localhost:9130/ in the browser
# LOOP: Now you can modify the code locally and always rebuild and run the app in the container
---
# Stop the container
docker stop $CONTAINER_ID
```