Support for building docker images with local modifications for the purpose of testing and debugging

This commit is contained in:
benbierens 2023-04-26 07:49:52 +02:00 committed by Eric Mastro
parent 132d860ff3
commit bf17bc821f
No known key found for this signature in database
6 changed files with 38 additions and 5 deletions

View File

@ -10,6 +10,13 @@ Stop and delete image and volume data:
`docker-compose down --rmi all -v`
`rm -R hostdatadir`
# Building local modifications for testing
Sometimes, you just need to make a small change and build a new docker image for the purpose of testing. To speed up this process, the docker build has been cut into two steps.
Step 1: (buildsetup.bat) builds the setup.Dockerfile and takes care of the slow process of building the nim buildsystem. This does not need to be re-done for most small changes to the nim-codex codebase.
Step 2: (buildlocal.bat) builds the local.Dockerfile and pushes the new image as `thatbenbierens/codexlocal:latest`.
- The CI build cannot use this two-step speed-up because it builds images for multiple architectures, which the local scripts don't do.
# Environment variables
Codex docker image supports the following environment variables:
- LISTEN_ADDRS(*)

2
docker/buildlocal.bat Normal file
View File

@ -0,0 +1,2 @@
docker build -t thatbenbierens/codexlocal:latest -f codex.Dockerfile ..
docker push thatbenbierens/codexlocal:latest

2
docker/buildsetup.bat Normal file
View File

@ -0,0 +1,2 @@
docker build -t thatbenbierens/codexsetup:latest -f setup.Dockerfile ..
docker push thatbenbierens/codexsetup:latest

12
docker/local.Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM thatbenbierens/codexsetup:latest AS builder
WORKDIR /src
COPY ./codex ./codex
COPY ./docker ./docker
RUN make NIM_PARAMS="-d:disableMarchNative"
FROM alpine:3.17.2
WORKDIR /root/
RUN apk add --no-cache openssl libstdc++ libgcc libgomp
COPY --from=builder /src/build/codex ./
COPY --from=builder /src/docker/startCodex.sh ./
CMD ["sh", "startCodex.sh"]

6
docker/setup.Dockerfile Normal file
View File

@ -0,0 +1,6 @@
FROM nimlang/nim:1.6.10-alpine AS builder
WORKDIR /src
RUN apk update && apk add git cmake curl make git bash linux-headers
COPY . .
RUN make clean
RUN make update

View File

@ -2,6 +2,10 @@ echo "Starting Codex..."
args=""
## local ip as NAT?
do_nat=$(ifconfig eth0 | awk '/inet addr/ {gsub("addr:", "", $2); print $2}')
echo "got nat:$do_nat"
# Required arguments
if [ -n "$LISTEN_ADDRS" ]; then
echo "Listen address: $LISTEN_ADDRS"
@ -40,10 +44,10 @@ if [ -n "$METRICS_ADDR" ] && [ -n "$METRICS_PORT" ]; then
fi
# NAT
if [ -n "$NAT_IP" ]; then
echo "NAT: $NAT_IP"
args="$args --nat=$NAT_IP"
fi
# if [ -n "$NAT_IP" ]; then
echo "NAT: $do_nat"
args="$args --nat=$do_nat"
# fi
# Discovery IP
if [ -n "$DISC_IP" ]; then
@ -108,7 +112,7 @@ fi
# Ethereum persistence
if [ -n "$ETH_PROVIDER" ] && [ -n "$ETH_ACCOUNT" ] && [ -n "$ETH_MARKETPLACE_ADDRESS" ]; then
echo "Persistence enabled"
args="$args --persistence=true"
args="$args --persistence"
args="$args --eth-provider=$ETH_PROVIDER"
args="$args --eth-account=$ETH_ACCOUNT"
# args="$args --validator"