Skip to content

Commit d33f0b4

Browse files
authored
Merge pull request #427 from shutter-network/feature/play-docker
babashka-play docker
2 parents 19a562d + a5b8dec commit d33f0b4

File tree

5 files changed

+96
-2
lines changed

5 files changed

+96
-2
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ contracts/node_modules
33
contracts/deployments
44
docker/data
55
play/work
6+
play/Dockerfile
67
rolling-shutter/bin
78
tools/snapshot/dummyserver/dist

play/Dockerfile

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
FROM ubuntu:22.04 AS base
2+
3+
SHELL ["/bin/bash", "-c"]
4+
ENV ASDF_DIR=/home/app/.asdf
5+
ENV BASH_ENV=/home/app/.env
6+
7+
RUN groupadd -g 1000 app && \
8+
useradd -g 1000 -u 1000 -m app
9+
10+
RUN --mount=type=cache,target=/var/cache/apt \
11+
apt update && \
12+
apt install -y git curl
13+
14+
USER 1000
15+
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.13.1
16+
17+
RUN echo '. $HOME/.asdf/asdf.sh' >> ~/.env && \
18+
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.env && \
19+
echo '. ~/.env' >> ~/.bashrc
20+
21+
22+
FROM base AS build
23+
24+
USER root
25+
26+
RUN --mount=type=cache,target=/var/cache/apt \
27+
apt install -y build-essential libreadline-dev zlib1g-dev libssl-dev libuuid1 uuid-dev unzip
28+
29+
COPY ./ /src
30+
31+
RUN chown -R app:app /src
32+
USER 1000
33+
34+
WORKDIR /src/rolling-shutter
35+
36+
RUN --mount=type=cache,target=/home/app/.asdf/downloads,uid=1000,gid=1000 \
37+
--mount=type=cache,target=/home/app/.asdf/tmp,uid=1000,gid=1000 \
38+
make install-asdf
39+
40+
RUN --mount=type=cache,target=/home/app/.asdf/downloads,uid=1000,gid=1000 \
41+
--mount=type=cache,target=/home/app/.asdf/tmp,uid=1000,gid=1000 \
42+
--mount=type=cache,target=/home/app/.cache/go-build,uid=1000,gid=1000 \
43+
make install-asdf && \
44+
make install-tools && \
45+
make build
46+
47+
ENV POSTGRES_DB="testdb"
48+
ENV POSTGRES_HOST_AUTH_METHOD="trust"
49+
ENV POSTGRES_PASSWORD="password"
50+
ENV POSTGRES_USER="app"
51+
52+
53+
RUN sh -c "$(curl --location https://raw.githubusercontent.com/F1bonacc1/process-compose/main/scripts/get-pc.sh)" -- -d -b /home/app/.asdf/bin
54+
USER root
55+
RUN ln -s /tmp/.s.PGSQL.5432 /var/run/.s.pgsql.5432
56+
USER 1000
57+
RUN bash -c "mkdir -p /src/play/work/db && /home/app/.asdf/shims/initdb /src/play/work/db"
58+
WORKDIR /src/play
59+
60+
RUN --mount=type=cache,target=/home/app/.cache,uid=1000,gid=1000 \
61+
bb --config /src/play/bb.edn build-all && \
62+
clojure -T:build
63+
64+
ENV ROLLING_SHUTTER_ROOT=/src
65+
ENV ROLLING_SHUTTER_BOOTSTRAP_SIGNING_KEY=479968ffa5ee4c84514a477a8f15f3db0413964fd4c20b08a55fed9fed790fad
66+
ENV ROLLING_SHUTTER_CHAIN_GENESIS_KEYPER=0x440Dc6F164e9241F04d282215ceF2780cd0B755e
67+
USER root
68+
RUN mkdir -p /home/app/.cache/hardhat-nodejs && chown -R 1000:1000 /home/app/.cache/hardhat-nodejs
69+
RUN ln -s /src/contracts/deployments /src/play/deployments
70+
71+
USER 1000

play/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ manually:
7373
BB_EXTERNAL_WD="$(pwd)" BB_EXTERNAL_COMMAND="../rolling-shutter/bin/rolling-shutter keyper --config work/keyper-dkg-external/keyper-2.toml" clojure -M:test keyper-dkg-external
7474
```
7575

76+
(You can do the same inside a docker container (see below)).
77+
7678
### Parameters in the environment
7779

7880
You can find the test system parameters in the environment of the
@@ -99,6 +101,23 @@ Here you see, that the keyper implementation under tests, should use port
99101
`http://127.0.0.1:8545/` etc. Not all of these may be relevant to your
100102
implementation.
101103

104+
### Docker image
105+
106+
There are ready to use docker images at
107+
https://ghcr.io/shutter-network/babashka-play
108+
109+
To run a test inside a container, run:
110+
111+
```
112+
docker run --platform=linux/amd64 --rm -it ghcr.io/shutter-network/babashka-play:latest
113+
114+
process-compose -t=false up & # to start postgres
115+
116+
# RUN TEST
117+
#e.g.
118+
bb test-system
119+
```
120+
102121
### Self contained testrunner
103122

104123
It is possible to compile the testrunner into a self contained `.jar` file, by

play/bb.edn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
(go-install "gotestsum" "gotest.tools/gotestsum@latest")
179179

180180
-install:abigen
181-
(go-install "abigen" "github.com/ethereum/go-ethereum/cmd/abigen")
181+
(go-install "abigen" "github.com/ethereum/go-ethereum/cmd/abigen@v1.12.0")
182182

183183
-install:oapi-codegen
184184
(go-install "oapi-codegen" "github.com/deepmap/oapi-codegen/cmd/oapi-codegen")

rolling-shutter/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ install-asdf-plugins:
9999
../tools/asdf-install-plugins.sh
100100

101101
install-asdf: install-asdf-plugins
102-
asdf install
102+
# Various packages installed by asdf internally also use make and don't like if an external make has already
103+
# tinkered with then environment.
104+
# Therefore we unset MAKELEVEL here.
105+
env -u MAKELEVEL asdf install
103106

104107
lint:
105108
golangci-lint run --tests

0 commit comments

Comments
 (0)