Skip to content

Commit 1a64e78

Browse files
committed
feat: add Go debugging environment
1 parent 7bd34d6 commit 1a64e78

File tree

4 files changed

+131
-3
lines changed

4 files changed

+131
-3
lines changed

Dockerfiles/Dockerfile.dela.debug

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM golang:1.20.6-bookworm
2+
3+
# https://blog.jetbrains.com/go/2020/05/06/debugging-a-go-application-inside-a-docker-container/
4+
RUN go install github.com/go-delve/delve/cmd/dlv@latest
5+
6+
RUN apt-get update && apt-get install git
7+
RUN git clone https://github.com/dedis/dela.git
8+
RUN git clone https://github.com/dedis/d-voting.git
9+
WORKDIR /go/dela/cli/crypto
10+
RUN go install
11+
WORKDIR /go/d-voting/cli/memcoin
12+
13+
RUN go build -gcflags="all=-N -l"
14+
15+
ENV PATH=/go/dela/cli/crypto:/go/d-voting/cli/memcoin:${PATH}
16+
WORKDIR /go
17+
ENTRYPOINT ["/bin/bash", "-c", "/dlv --listen=:40000 --headless=true --api-version=2 --accept-multiclient exec /go/d-voting/cli/memcoin/memcoin --config /data/node start --postinstall --proxyaddr :$PROXYPORT --proxykey $PROXYKEY --listen tcp://0.0.0.0:2000 --public http://$HOSTNAME:2000 --routing tree"]
18+
CMD []

README.docker.md

+10
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,13 @@ to delete the volumes (this will reset your instance).
5353
2. `docker compose exec backend /bin/bash`
5454
3. execute `npx cli addAdmin --sciper 123455` with your SCIPER to add yourself as admin
5555
5. exit the container and run `docker compose down && docker compose up -d`
56+
57+
## Go debugging environment
58+
59+
To use the Go debugging environment, pass the
60+
61+
```
62+
--file docker-compose.yml.debug
63+
```
64+
65+
flag to all `docker compose` invocations.

docker-compose.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
environment:
88
PROXYKEY: ${PUBLIC_KEY}
99
PROXYPORT: ${PROXYPORT}
10-
LLVL: debug
10+
LLVL: info
1111
volumes:
1212
- dela-leader-data:/data
1313
hostname: dela-leader
@@ -18,7 +18,7 @@ services:
1818
environment:
1919
PROXYKEY: ${PUBLIC_KEY}
2020
PROXYPORT: ${PROXYPORT}
21-
LLVL: debug
21+
LLVL: info
2222
volumes:
2323
- dela-worker-1-data:/data
2424
hostname: dela-worker-1
@@ -29,7 +29,7 @@ services:
2929
environment:
3030
PROXYKEY: ${PUBLIC_KEY}
3131
PROXYPORT: ${PROXYPORT}
32-
LLVL: debug
32+
LLVL: info
3333
volumes:
3434
- dela-worker-2-data:/data
3535
hostname: dela-worker-2

docker-compose.yml.debug

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
services:
2+
3+
dela-leader: # inital DELA leader node
4+
image: dela
5+
build:
6+
dockerfile: ./Dockerfiles/Dockerfile.dela.debug
7+
environment:
8+
PROXYKEY: ${PUBLIC_KEY}
9+
PROXYPORT: ${PROXYPORT}
10+
LLVL: debug
11+
volumes:
12+
- dela-leader-data:/data
13+
hostname: dela-leader
14+
ports:
15+
- 127.0.0.1:40000:40000
16+
security_opt:
17+
- apparmor:unconfined
18+
cap_add:
19+
- SYS_PTRACE
20+
dela-worker-1: # DELA worker node
21+
image: dela
22+
build:
23+
dockerfile: ./Dockerfiles/Dockerfile.dela.debug
24+
environment:
25+
PROXYKEY: ${PUBLIC_KEY}
26+
PROXYPORT: ${PROXYPORT}
27+
LLVL: debug
28+
volumes:
29+
- dela-worker-1-data:/data
30+
hostname: dela-worker-1
31+
ports:
32+
- 127.0.0.1:40001:40000
33+
security_opt:
34+
- apparmor:unconfined
35+
cap_add:
36+
- SYS_PTRACE
37+
dela-worker-2: # DELA worker node
38+
image: dela
39+
build:
40+
dockerfile: ./Dockerfiles/Dockerfile.dela.debug
41+
environment:
42+
PROXYKEY: ${PUBLIC_KEY}
43+
PROXYPORT: ${PROXYPORT}
44+
LLVL: debug
45+
volumes:
46+
- dela-worker-2-data:/data
47+
hostname: dela-worker-2
48+
ports:
49+
- 127.0.0.1:40002:40000
50+
security_opt:
51+
- apparmor:unconfined
52+
cap_add:
53+
- SYS_PTRACE
54+
55+
frontend: # web service frontend
56+
image: frontend
57+
build:
58+
dockerfile: ./Dockerfiles/Dockerfile.frontend
59+
ports:
60+
- 127.0.0.1:3000:3000
61+
environment:
62+
BACKEND_HOST: ${BACKEND_HOST}
63+
BACKEND_PORT: ${BACKEND_PORT}
64+
65+
backend: # web service backend
66+
image: backend
67+
build:
68+
dockerfile: ./Dockerfiles/Dockerfile.backend
69+
environment:
70+
DATABASE_USERNAME: ${DATABASE_USERNAME}
71+
DATABASE_PASSWORD: ${DATABASE_PASSWORD}
72+
DATABASE_HOST: ${DATABASE_HOST}
73+
DATABASE_PORT: ${DATABASE_PORT}
74+
FRONT_END_URL: ${FRONT_END_URL}
75+
DELA_NODE_URL: ${DELA_NODE_URL}
76+
SESSION_SECRET: ${SESSION_SECRET}
77+
PUBLIC_KEY: ${PUBLIC_KEY}
78+
PRIVATE_KEY: ${PRIVATE_KEY}
79+
ports:
80+
- 127.0.0.1:5000:5000
81+
- 127.0.0.1:80:80
82+
depends_on:
83+
db:
84+
condition: service_started
85+
86+
db: # PostgreSQL database
87+
image: postgres:15
88+
environment:
89+
POSTGRES_USER: ${DATABASE_USERNAME}
90+
POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
91+
volumes:
92+
- postgres-data:/var/lib/postgresql/data
93+
- ./web/backend/src/migration.sql:/docker-entrypoint-initdb.d/init.sql
94+
95+
volumes:
96+
postgres-data: # PostgreSQL database
97+
dela-leader-data:
98+
dela-worker-1-data:
99+
dela-worker-2-data:
100+

0 commit comments

Comments
 (0)