feat: automate docker build and deploy workflows via Taskfile

This commit is contained in:
Hamza Hamud 2025-12-24 20:24:19 +00:00
parent bf5a96ce13
commit 1d978cf211
3 changed files with 56 additions and 18 deletions

View File

@ -34,53 +34,55 @@ sudo ufw reload
Quilibrium nodes require a valid configuration and cryptographic keys to participate in the network. For containerized deployments, it is recommended to generate these separately from the main node execution.
### Generating Config
You can use the `config-gen` utility included in the Docker image or build it from source.
You can use the `config-gen` utility included
**Using Go (from repo root):**
**Using Task (Recommended):**
```bash
go run ./utils/config-gen --config $(pwd)/.config
task config:gen
```
**Using Docker:**
You can override the directory using `CONFIG_DIR`:
```bash
docker run --rm -it \
--entrypoint config-gen \
-v $(pwd)/.config:/root/.config \
quilibrium --config /root/.config
task config:gen CONFIG_DIR=/path/to/config
```
## 3. Build from Source
Using `DOCKER_BUILDKIT`, we can build a highly optimized, slim image specifically for the node.
### The Build Command
Navigate to your monorepo directory and execute:
**Using Task:**
```bash
task build:node:source
```
**Using Docker directly:**
```bash
DOCKER_BUILDKIT=1 docker build \
--target node-only \
-f Dockerfile.source \
--build-arg GIT_COMMIT=$(git log -1 --format=%h) \
-t quilibrium \
-t quilibrium:$(git describe --tags --abbrev=0 2>/dev/null || echo "latest") .
-t quilibrium:node-only .
```
### Why these flags?
- `--target node-only`: Excludes unnecessary build tools from the final image.
- `--build-arg GIT_COMMIT`: Embeds the specific version hash into the binary for network identification.
- `-t quilibrium:tag`: Tags the image with a specific version for easy management and rollbacks.
## 4. Deployment
For servers with dedicated public IPs, **Host Networking** is the recommended deployment method. It eliminates Docker NAT overhead and ensures the node is easily reachable by peers.
### Run the Container
**Using Task:**
```bash
task deploy:node
```
**Using Docker directly:**
```bash
docker run -d --name q-node \
--network host \
--restart unless-stopped \
-v $(pwd)/.config:/root/.config \
quilibrium -signature-check=false
quilibrium:node-only -signature-check=false
```
## 5. Managing the Container

View File

@ -260,6 +260,9 @@ RUN apt-get update && apt-get install -y \
libmpfr6 \
&& rm -rf /var/lib/apt/lists/*
ENV QUILIBRIUM_SIGNATURE_CHECK=true
ENV GOEXPERIMENT=arenas
COPY --from=build-node /usr/bin/node /usr/local/bin/node
WORKDIR /root
ENTRYPOINT ["node"]
@ -295,6 +298,7 @@ ARG GIT_BRANCH
ARG GIT_COMMIT
ENV GOEXPERIMENT=arenas
ENV QUILIBRIUM_SIGNATURE_CHECK=false
LABEL org.opencontainers.image.title="Quilibrium Network Node"
LABEL org.opencontainers.image.description="Quilibrium is a decentralized alternative to platform as a service providers."

View File

@ -168,3 +168,35 @@ tasks:
desc: Test the Quilibrium docker image.
cmds:
- client/test/run_tests.sh -d 'ubuntu' -v '24.04'
config:gen:
desc: Generate configuration and keys using Go.
cmds:
- go run ./utils/config-gen --config {{.CONFIG_DIR | default ".config"}}
build:node:source:
desc: Build the optimized Quilibrium node-only docker image.
cmds:
- |
docker build \
--target node-only \
-f Dockerfile.source \
--build-arg NODE_VERSION={{.VERSION}} \
--build-arg GIT_REPO={{.GIT_REPO}} \
--build-arg GIT_BRANCH={{.GIT_BRANCH}} \
--build-arg GIT_COMMIT={{.GIT_COMMIT}} \
-t ${QUILIBRIUM_IMAGE_NAME:-quilibrium}:{{.VERSION}}-node-only \
-t ${QUILIBRIUM_IMAGE_NAME:-quilibrium}:node-only \
.
deploy:node:
desc: Run the Quilibrium node using host networking and external config.
cmds:
- |
docker run -d --name q-node \
--network host \
--restart unless-stopped \
-v {{.CONFIG_DIR | default "$(pwd)/.config"}}:/root/.config \
${QUILIBRIUM_IMAGE_NAME:-quilibrium}:node-only \
-signature-check=false