-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker: added a generic Dockerfile and a CI to build and publish an i…
…mage for the daemon
- Loading branch information
Showing
3 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters