From 6068cd8f260177a51a8b49754128bee378be7051 Mon Sep 17 00:00:00 2001 From: Marius Scurtescu Date: Mon, 22 Apr 2024 23:53:58 -0700 Subject: [PATCH] build and document qclient for docker (#165) * specify value of cpus and memory as string * build and document qclient * fix health check command --- DOCKER-README.md | 16 ++++++++++++++-- Dockerfile | 5 +++++ docker-compose.yml | 8 ++++---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/DOCKER-README.md b/DOCKER-README.md index 11f0bd9..9b7ed97 100644 --- a/DOCKER-README.md +++ b/DOCKER-README.md @@ -54,6 +54,9 @@ docker build --build-arg GIT_COMMIT=$(git log -1 --format=%h) -t quilibrium -t q Use latest version instead of `1.4.2`. +> [!TIP] +> You can use the `task build` command instead. See the [Task](#task) section below. + The image that is built is light and safe. It is based on Alpine Linux with the Quilibrium node binary, not the source code, nor the Go development environment. The image also has the `grpcurl` tool that can be used to query the gRPC interface. @@ -105,6 +108,9 @@ Run Quilibrium in a container: docker compose up -d ``` +> [!TIP] +> You can alternatively use the `task up` command. See the [Task](#task-1) section above. + A `.config/` subfolder will be created under the current folder, this is mapped inside the container. Make sure you backup `config.yml` and `keys.yml`. @@ -159,10 +165,10 @@ services: resources: limits: cpus: '4' # Maximum CPU count that the container can use - memory: 16G # Maximum memory that the container can use + memory: '16G' # Maximum memory that the container can use reservations: cpus: '2' # CPU count that the container initially requests - memory: 8G # Memory that the container initially request + memory: '8G' # Memory that the container initially request ``` @@ -213,3 +219,9 @@ Run the DB console: docker compose exec node node -db-console ``` +Run the Quilibrium client: +```shell +docker compose exec node qclient help +docker compose exec node qclient token help +docker compose exec node qclient token balance +``` \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 1e72753..1cfbdc3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,10 @@ WORKDIR /opt/ceremonyclient/node RUN go install ./... RUN go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest +WORKDIR /opt/ceremonyclient/client + +RUN go build -o qclient ./main.go + FROM alpine:3.19 ARG NODE_VERSION @@ -34,6 +38,7 @@ COPY --from=build /go/bin/node /usr/local/bin COPY --from=build /go/bin/grpcurl /usr/local/bin COPY --from=build /opt/ceremonyclient/node/ceremony.json /root COPY --from=build /opt/ceremonyclient/node/retroactive_peers.json /root +COPY --from=build /opt/ceremonyclient/client/qclient /usr/local/bin WORKDIR /root diff --git a/docker-compose.yml b/docker-compose.yml index 6ed7028..1d93017 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,10 +10,10 @@ services: deploy: resources: limits: - memory: 32G + memory: '32G' reservations: - cpus: 12 - memory: 16G + cpus: '12' + memory: '16G' environment: - DEFAULT_LISTEN_GRPC_MULTIADDR=/ip4/0.0.0.0/tcp/8337 - DEFAULT_LISTEN_REST_MULTIADDR=/ip4/0.0.0.0/tcp/8338 @@ -23,7 +23,7 @@ services: - '127.0.0.1:${QUILIBRIUM_GRPC_PORT:-8337}:8337/tcp' # gRPC - '127.0.0.1:${QUILIBRIUM_REST_PORT:-8338}:8338/tcp' # REST healthcheck: - test: ["CMD", "node", "--peer-id"] + test: ["CMD", "grpcurl", "-plaintext", "localhost:8337", "list", "quilibrium.node.node.pb.NodeService"] interval: 30s timeout: 5s retries: 3