Docker package build (#3816)

* bin: ability to use chain type argument for 'run' subcommand

* docker: single image for mainnet and testnet, update build docs

* docker: root user

* github: ghcr publish

* github: build image for master branch only

* docs: fix paths

* docker: move 'server run' to command

* Revert "bin: ability to use chain type argument for 'run' subcommand"

This reverts commit fc2d9199c3ff80c5c7305e3fc5b1f6fe86e8dacf.

* docker: disable tui at config
This commit is contained in:
ardocrat
2026-01-06 21:39:18 +03:00
committed by GitHub
parent dc6f8d2520
commit da7b6b5c50
9 changed files with 83 additions and 111 deletions
+38
View File
@@ -0,0 +1,38 @@
name: Build and Push to GHCR
on:
push:
branches: [master]
jobs:
build-andpush:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Generate image tag
id: vars
run: echo "tag=$(awk -F'"' '/^version/{ print $2; exit; }' Cargo.toml)" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: |
ghcr.io/${{ secrets.GHCR_USERNAME }}/grin:latest
ghcr.io/${{ secrets.GHCR_USERNAME }}/grin:${{ steps.vars.outputs.tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
+40
View File
@@ -0,0 +1,40 @@
# Builder
FROM rust:slim-trixie AS builder
WORKDIR /usr/src/grin
COPY . .
RUN apt update && \
apt install -y libncurses5-dev libncursesw5-dev
RUN cargo build --release
# Runner
FROM debian:trixie-slim
COPY --from=builder /usr/src/grin/target/release/grin /usr/local/bin/grin
RUN apt update && \
apt install -y libncursesw5-dev
# Create mainnet config
WORKDIR /root/.grin/main
RUN grin server config
RUN sed -i '/^run_tui /s/=.*$/= false/' grin-server.toml
# Create testnet config
WORKDIR /root/.grin/test
RUN grin --testnet server config
RUN sed -i '/^run_tui /s/=.*$/= false/' grin-server.toml
# Mainnet ports
EXPOSE 3413 3414
# Testnet ports
EXPOSE 13413 13414
# Stratum port
EXPOSE 3416
WORKDIR /root/.grin
ENTRYPOINT ["grin"]
CMD ["server", "run"]
+1 -3
View File
@@ -106,10 +106,8 @@ grin client --help
## Docker
```sh
docker build -t grin -f etc/Dockerfile .
docker build -t grin .
```
For testnet, use `etc/Dockerfile.testnet` instead
You can bind-mount your grin cache to run inside the container.
```sh
+1 -1
View File
@@ -96,7 +96,7 @@ grin client --help
## Docker
```sh
docker build -t grin -f etc/Dockerfile .
docker build -t grin .
```
Puede ubicar la caché de Grin para que se ejecute dentro del contenedor
+1 -3
View File
@@ -100,10 +100,8 @@ grin client --help
## Docker
```sh
docker build -t grin -f etc/Dockerfile .
docker build -t grin .
```
testnetを使用する場合、代わりに`etc/Dockerfile.testnet`を指定。
コンテナ内で実行する場合、grinのキャッシュをバインドマウントすることも可能。
```sh
+1 -3
View File
@@ -101,10 +101,8 @@ grin client --help
## Docker 사용하기
```sh
docker build -t grin -f etc/Dockerfile .
docker build -t grin .
```
testnet을 사용하려면 `etc/Dockerfile.testnet` 을 사용하세요.
container 안에서 grin cache를 bind-mount로 사용 할 수 있습니다.
```sh
+1 -3
View File
@@ -98,10 +98,8 @@ grin client --help
## Docker
```sh
docker build -t grin -f etc/Dockerfile .
docker build -t grin .
```
对于 testnet, 使用 `etc/Dockerfile.testnet` 代替
您可以绑定安装您的 grin 缓存以在容器中运行。
```sh
-49
View File
@@ -1,49 +0,0 @@
# Multistage docker build, requires docker 17.05
# builder stage
FROM rust:1.45 as builder
RUN set -ex && \
apt-get update && \
apt-get --no-install-recommends --yes install \
clang \
libclang-dev \
llvm-dev \
libncurses5 \
libncursesw5 \
cmake \
git
WORKDIR /usr/src/grin
# Copying Grin
COPY . .
# Building Grin
RUN cargo build --release
# runtime stage
FROM debian:10
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales openssl
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8
ENV LANG en_US.UTF-8
COPY --from=builder /usr/src/grin/target/release/grin /usr/local/bin/grin
WORKDIR /root/.grin
RUN grin server config && \
sed -i -e 's/run_tui = true/run_tui = false/' grin-server.toml
VOLUME ["/root/.grin"]
EXPOSE 3413 3414 3415 3416
ENTRYPOINT ["grin"]
CMD ["server", "run"]
-49
View File
@@ -1,49 +0,0 @@
# Multistage docker build, requires docker 17.05
# builder stage
FROM rust:1.45 as builder
RUN set -ex && \
apt-get update && \
apt-get --no-install-recommends --yes install \
clang \
libclang-dev \
llvm-dev \
libncurses5 \
libncursesw5 \
cmake \
git
WORKDIR /usr/src/grin
# Copying Grin
COPY . .
# Building Grin
RUN cargo build --release
# runtime stage
FROM debian:10
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales openssl
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8
ENV LANG en_US.UTF-8
COPY --from=builder /usr/src/grin/target/release/grin /usr/local/bin/grin
WORKDIR /root/.grin
RUN grin --testnet server config && \
sed -i -e 's/run_tui = true/run_tui = false/' grin-server.toml
VOLUME ["/root/.grin"]
EXPOSE 13413 13414 13415 13416
ENTRYPOINT ["grin", "--testnet"]
CMD ["server", "run"]