Skip to content

Commit

Permalink
docker: added a generic Dockerfile and a CI to build and publish an i…
Browse files Browse the repository at this point in the history
…mage for the daemon
  • Loading branch information
Litarvan committed Dec 30, 2023
1 parent a175531 commit accab8b
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 1 deletion.
52 changes: 52 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Docker
on:
push:
branches: [ "master" ]
tags: [ "*" ]
pull_request:
branches: [ "master" ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3

- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' && github.ref_type == 'tag' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: app=xelis_daemon
platforms: linux/amd64,linux/arm64
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# syntax=docker/dockerfile-upstream:master-labs

FROM rust:1.74-bookworm as builder

ARG app
ENV BUILD_DIR /tmp/xelis-build

RUN mkdir -p $BUILD_DIR
WORKDIR $BUILD_DIR

COPY Cargo.toml Cargo.lock ./
COPY --parents xelis_common/src xelis_common/Cargo.toml xelis_common/build.rs ./
COPY --parents xelis_daemon/src xelis_daemon/Cargo.toml ./
COPY --parents xelis_miner/src xelis_miner/Cargo.toml ./
COPY --parents xelis_wallet/src xelis_wallet/Cargo.toml ./

WORKDIR ${BUILD_DIR}/$app

RUN cargo build --release

# ---

FROM gcr.io/distroless/cc-debian12

ARG app
ENV APP_DIR /var/run/xelis
ENV DATA_DIR $APP_DIR/data
ENV BINARY $APP_DIR/xelis

LABEL org.opencontainers.image.name="$app"
LABEL org.opencontainers.image.authors="Slixe <[email protected]>"

COPY --from=builder /tmp/xelis-build/target/release/$app $BINARY

WORKDIR $DATA_DIR

ENTRYPOINT ["/var/run/xelis/xelis"]
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,11 @@ Example: `cargo build --release --bin xelis_miner`
You can also build a debug version (just remove `--release` option) or run it directly from cargo:
`cargo run`

### Build from Docker
To build using Docker, use the following command, using the `app` build argument to chose which project to build:
`docker build -t xelis-daemon:master --build-arg app=xelis_daemon .`

## Dev Fee

No premine, fair-launch, but to fund this project, we set a developer fee percentage at `5%` of every block reward until the project is fully completed.
This will also helps us to rewards community build and attracts others developers.
This will also helps us to rewards community build and attracts others developers.

0 comments on commit accab8b

Please sign in to comment.