This repository has been archived by the owner on Aug 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
111 additions
and
0 deletions.
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,75 @@ | ||
name: Build and Dockerize | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Rust toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
components: rustfmt, clippy | ||
|
||
- name: Build binaries | ||
run: | | ||
rustup target add x86_64-unknown-linux-gnu | ||
rustup target add x86_64-apple-darwin | ||
rustup target add aarch64-unknown-linux-gnu | ||
rustup target add aarch64-apple-darwin | ||
cargo build --release --target x86_64-unknown-linux-gnu | ||
cargo build --release --target x86_64-apple-darwin | ||
cargo build --release --target aarch64-unknown-linux-gnu | ||
cargo build --release --target aarch64-apple-darwin | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
tags: ark-network/clark:latest | ||
platforms: linux/amd64,linux/arm64,darwin/amd64,darwin/arm64 | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload Release Assets | ||
run: | | ||
for binary in arkd noah; do | ||
for target in x86_64-unknown-linux-gnu x86_64-apple-darwin aarch64-unknown-linux-gnu aarch64-apple-darwin; do | ||
path="./target/$target/release/$binary" | ||
echo "Uploading $path" | ||
curl \ | ||
--header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
--header "Content-Type: $(file -b --mime-type $path)" \ | ||
--data-binary @$path \ | ||
--request POST \ | ||
"${{ steps.create_release.outputs.upload_url }}?name=$binary-$target" | ||
done | ||
done |
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,36 @@ | ||
# Stage 1: Building the code | ||
FROM rust:1.78 as builder | ||
|
||
WORKDIR /usr/src | ||
|
||
# Install protobuf-compiler and libclang | ||
RUN apt-get update && apt-get install -y protobuf-compiler clang libclang-dev && rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy over your manifests and source code | ||
COPY . . | ||
|
||
# Build for release. | ||
RUN cargo build --release | ||
|
||
# Stage 2: Setup the runtime environment | ||
FROM debian:buster-slim | ||
|
||
# Install necessary runtime dependencies | ||
RUN apt-get update && apt-get install -y libssl-dev ca-certificates && rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy the binary from the builder stage | ||
COPY --from=builder /usr/src/target/release/arkd /usr/local/bin/arkd | ||
COPY --from=builder /usr/src/target/release/noah /usr/local/bin/noah | ||
|
||
# Set the data directory and give write permissions | ||
RUN mkdir /data && chown -R nobody:nogroup /data | ||
VOLUME ["/data"] | ||
|
||
# Expose the necessary ports | ||
EXPOSE 35035 3536 | ||
|
||
# Switch to a non-root user | ||
USER nobody | ||
|
||
# Set the startup command to run your binary | ||
CMD ["arkd"] |