Skip to content

Create Dockerfile #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
46 changes: 46 additions & 0 deletions .github/workflows/build-and-push-docker-hub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build and Push Docker Image to Docker Hub

on:
push:
tags:
- "v*.*.*"
workflow_dispatch:

permissions: {}

jobs:
set_env:
name: Create version tag
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.version_step.outputs.tags }}
env:
VERSION: ${{ github.ref_name }}
SHA: ${{ github.sha }}
steps:
- id: version_step
run: |
set -Eeuo pipefail
IFS=$'\n\t'

if [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-rc-[0-9]+)?$ ]]; then
echo "Valid version: $VERSION"
echo "tags=latest,$VERSION,$SHA" >> "$GITHUB_OUTPUT"
else
echo "Invalid ref_name format: $VERSION" >&2
exit 1
fi

build_push:
uses: zcash/.github/.github/workflows/build-and-push-docker-hub.yaml@main
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this doing? It looks recursive to me which makes no sense. Is this actually pulling from the zcash/zcash repo?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, this is the template we're using in Zcash and across several of our other repositories. - Just realized I missed updating a path — just fixed it now.

needs: set_env
with:
image_name: zallet
image_tags: ${{ needs.set_env.outputs.tags }}
dockerfile: Dockerfile
context: .
build-args: ""
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
dockerhub_registry: ${{ secrets.DOCKERHUB_REGISTRY }}
26 changes: 26 additions & 0 deletions .github/workflows/test-docker-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build and Run Docker Container

on:
pull_request:
push:
branches: main

permissions: {}

jobs:
build_and_run:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Build Docker image
run: |
docker build -t zallet .

- name: Run command inside Docker container
run: |
docker run --rm zallet -h
Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI the problem you last commit was fixing is that you tried to use -help as the flag, which is incorrect for Zallet. --help is what you should use (or -h), as the help text itself should show.

In general, zcashd's support for single-hypen word flags to CLI is not something we are going to support in Zallet.

24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# --- Stage 1: Build with Rust --- (amd64)
FROM rust:1-slim@sha256:57d415bbd61ce11e2d5f73de068103c7bd9f3188dc132c97cef4a8f62989e944 AS builder

WORKDIR /app

RUN apt-get update && \
apt-get install -y --no-install-recommends \
clang \
libclang-dev \
pkg-config \
git && \
rm -rf /var/lib/apt/lists/*

COPY . .

RUN cargo build --release && strip target/release/zallet

# --- Stage 2: Minimal runtime with distroless ---
FROM gcr.io/distroless/cc

COPY --from=builder /app/target/release/zallet /usr/local/bin/zallet

USER nonroot
ENTRYPOINT ["/usr/local/bin/zallet"]
Loading