Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ COPY --from=builder /app/build/bin/* /usr/local/bin/

WORKDIR /var/lib/erigon

RUN adduser -H -u 1000 -g 1000 -D erigon
RUN chown -R erigon:erigon /var/lib/erigon
USER erigon

EXPOSE 8545 8546 30303 30303/udp 30304 30304/udp 8080 9090 6060
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ GO_DBG_BUILD = go build -trimpath -tags=debug -ldflags "-X github.com/ledgerwatc

GO_MAJOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
ERIGON_HOME = ~/.local/share

all: erigon hack rpctest state pics rpcdaemon integration db-tools sentry

Expand All @@ -22,8 +23,12 @@ docker:
docker build -t turbo-geth:latest --build-arg git_commit='${GIT_COMMIT}' --build-arg git_branch='${GIT_BRANCH}' --build-arg git_tag='${GIT_TAG}' .

docker-compose:
# Uses host's PID,UID,GID. It required to open Erigon's DB from another process (RPCDaemon local-mode)
UID_GID=$(shell id -u):$(shell id -g) docker-compose up
@if test -n "$(XDG_DATA_HOME)"; then \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure we need create folders manually?
On mac folders auto-created under my user (not root).

Copy link
Copy Markdown
Contributor Author

@mariuspod mariuspod Jul 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. https://github.com/mariuspod/erigon/blob/devel/docker-compose.yml#L10
The left part of the second colon is the local volume path which is expanded and created as root user on linux.

This is causing permission issues later on, that's why I'm pre-creating them with the non-root user on the host so that the volume can just pick it up and not change the permissions at runtime.

mkdir -p $(XDG_DATA_HOME)/erigon $(XDG_DATA_HOME)/erigon-grafana $(XDG_DATA_HOME)/erigon-prometheus; \
else \
mkdir -p $(ERIGON_HOME)/erigon $(ERIGON_HOME)/erigon-grafana $(ERIGON_HOME)/erigon-prometheus; \
fi
docker-compose up

# debug build allows see C stack traces, run it with GOTRACEBACK=crash. You don't need debug build for C pit for profiling. To profile C code use SETCGOTRCKEBACK=1
dbg:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ or
XDG_DATA_HOME=/preferred/data/folder make docker-compose
```

Makefile uses host's PID,UID,GID. It required to open Erigon's DB from another process (RPCDaemon local-mode).
Makefile creates the initial directories for erigon, prometheus and grafana. The PID namespace is shared between erigon and rpcdaemon which is required to open Erigon's DB from another process (RPCDaemon local-mode).
See: https://github.com/ledgerwatch/erigon/pull/2392/files

Windows support for docker-compose is not ready yet. Please help us with .ps1 port
Expand Down
9 changes: 3 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ services:
image: thorax/erigon:latest
build: .
command: erigon --datadir=/var/lib/erigon --metrics --metrics.addr=0.0.0.0 --metrics.port=6060 --private.api.addr=0.0.0.0:9090 --pprof --pprof.addr=0.0.0.0 --pprof.port=6061
user: ${UID_GID:-1000:1000} # Uses host's PID,UID,GID. It required to open Erigon's DB from another process (RPCDaemon local-mode)
pid: host
volumes:
- ${XDG_DATA_HOME:-~/.local/share}/erigon:/var/lib/erigon
ports:
Expand All @@ -19,7 +17,7 @@ services:

prometheus:
image: prom/prometheus:v2.28.1
user: ${UID_GID:-1000:1000}
user: 1000:1000 # Uses erigon user from Dockerfile
command: --log.level=warn --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/prometheus --web.console.libraries=/usr/share/prometheus/console_libraries --web.console.templates=/usr/share/prometheus/consoles
ports:
- "9090:9090"
Expand All @@ -30,7 +28,7 @@ services:

grafana:
image: grafana/grafana:8.0.6
user: ${UID_GID:-1000:1000}
user: 1000:1000 # Uses erigon user from Dockerfile
ports:
- "3000:3000"
volumes:
Expand All @@ -43,8 +41,7 @@ services:
rpcdaemon:
image: thorax/erigon:latest
command: rpcdaemon --datadir /var/lib/erigon --private.api.addr=erigon:9090 --http.addr=0.0.0.0 --http.vhosts=* --http.corsdomain=* --http.api=eth,debug,net
user: ${UID_GID:-1000:1000} # Uses host's PID,UID,GID. It required to open Erigon's DB from another process (RPCDaemon local-mode)
pid: host
pid: service:erigon # Use erigon's PID namespace. It's required to open Erigon's DB from another process (RPCDaemon local-mode)
volumes:
- ${XDG_DATA_HOME:-~/.local/share}/erigon:/var/lib/erigon
ports:
Expand Down