File tree Expand file tree Collapse file tree 4 files changed +131
-0
lines changed
Expand file tree Collapse file tree 4 files changed +131
-0
lines changed Original file line number Diff line number Diff line change 1+ # Before the docker CLI sends the context to the docker daemon, it looks for a file
2+ # named .dockerignore in the root directory of the context. If this file exists, the
3+ # CLI modifies the context to exclude files and directories that match patterns in it.
4+ #
5+ # You may want to specify which files to include in the context, rather than which
6+ # to exclude. To achieve this, specify * as the first pattern, followed by one or
7+ # more ! exception patterns.
8+ #
9+ # https://docs.docker.com/engine/reference/builder/#dockerignore-file
10+
11+ # Exclude everything:
12+ #
13+ *
14+
15+ # Now un-exclude required files and folders:
16+ #
17+ ! .cargo
18+ ! * .toml
19+ ! * .lock
20+ ! zallet
Original file line number Diff line number Diff line change 1+ name : Build and Push Docker Image to Docker Hub
2+
3+ on :
4+ push :
5+ tags :
6+ - " v*.*.*"
7+ workflow_dispatch :
8+
9+ permissions : {}
10+
11+ jobs :
12+ set_env :
13+ name : Create version tag
14+ runs-on : ubuntu-latest
15+ outputs :
16+ tags : ${{ steps.version_step.outputs.tags }}
17+ env :
18+ VERSION : ${{ github.ref_name }}
19+ SHA : ${{ github.sha }}
20+ steps :
21+ - id : version_step
22+ run : |
23+ set -Eeuo pipefail
24+ IFS=$'\n\t'
25+
26+ if [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-rc-[0-9]+)?$ ]]; then
27+ echo "Valid version: $VERSION"
28+ echo "tags=latest,$VERSION,$SHA" >> "$GITHUB_OUTPUT"
29+ else
30+ echo "Invalid ref_name format: $VERSION" >&2
31+ exit 1
32+ fi
33+
34+ build_push :
35+ uses : zcash/.github/.github/workflows/build-and-push-docker-hub.yaml@main
36+ needs : set_env
37+ with :
38+ image_name : zallet
39+ image_tags : ${{ needs.set_env.outputs.tags }}
40+ dockerfile : Dockerfile
41+ context : .
42+ build-args : " "
43+ secrets :
44+ dockerhub_username : ${{ secrets.DOCKERHUB_USERNAME }}
45+ dockerhub_password : ${{ secrets.DOCKERHUB_PASSWORD }}
46+ dockerhub_registry : ${{ secrets.DOCKERHUB_REGISTRY }}
Original file line number Diff line number Diff line change 1+ name : Build and Run Docker Container
2+
3+ on :
4+ pull_request :
5+ push :
6+ branches : main
7+
8+ permissions : {}
9+
10+ jobs :
11+ build_and_run :
12+ runs-on : ubuntu-latest
13+
14+ steps :
15+ - name : Checkout code
16+ uses : actions/checkout@v4
17+ with :
18+ persist-credentials : false
19+
20+ - name : Build Docker image
21+ run : |
22+ docker build -t zallet .
23+
24+ - name : Run command inside Docker container
25+ run : |
26+ docker run --rm zallet -h
Original file line number Diff line number Diff line change 1+ # syntax=docker/dockerfile:1
2+ # --- Stage 1: Build with Rust --- (amd64) (RUST version: 1.86.0)
3+ FROM rust:1.86.0-slim@sha256:57d415bbd61ce11e2d5f73de068103c7bd9f3188dc132c97cef4a8f62989e944 AS builder
4+
5+ WORKDIR /app
6+
7+ RUN apt-get update && \
8+ apt-get install -y --no-install-recommends \
9+ clang \
10+ libclang-dev \
11+ pkg-config \
12+ git && \
13+ rm -rf /var/lib/apt/lists/*
14+
15+ COPY --link . .
16+
17+ # Build the zallet binary
18+ # Leverage a cache mount to ${CARGO_HOME} for downloaded dependencies,
19+ # and a cache mount to ${CARGO_TARGET_DIR} for compiled dependencies.
20+ RUN --mount=type=bind,source=zallet,target=zallet \
21+ --mount=type=bind,source=Cargo.toml,target=Cargo.toml \
22+ --mount=type=bind,source=Cargo.lock,target=Cargo.lock \
23+ --mount=type=cache,target=/app/.cargo \
24+ --mount=type=cache,target=/app/target/ \
25+ cargo build --locked --release --package zallet --bin zallet && \
26+ cp /app/target/release/zallet /usr/local/bin/
27+
28+
29+ # --- Stage 2: Minimal runtime with distroless ---
30+ FROM gcr.io/distroless/cc AS runtime
31+
32+ COPY --link --from=builder /usr/local/bin/zallet /usr/local/bin/
33+
34+ # USER nonroot (UID 65532) — for K8s, use runAsUser: 65532
35+ USER nonroot
36+
37+ WORKDIR /var/lib/zallet
38+
39+ ENTRYPOINT ["zallet" ]
You can’t perform that action at this time.
0 commit comments