-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from nomad-xyz/arnaud/cleanup
Added Github actions for Docker and rust builds
- Loading branch information
Showing
17 changed files
with
132 additions
and
922 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,58 @@ | ||
# Documentation | ||
# https://github.com/docker/metadata-action | ||
# https://github.com/docker/login-action#google-container-registry-gcr | ||
# https://github.com/docker/build-push-action | ||
name: Build Docker container | ||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
build-docker: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
- uses: Swatinem/rust-cache@v1 | ||
with: | ||
# Add a key to prevent rust cache collision with rust.yml workflows | ||
key: 'release' | ||
|
||
- name: Build agents (release) | ||
run: cargo build --release | ||
|
||
- name: Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
# list of Docker images to use as base name for tags | ||
images: gcr.io/nomad-xyz/nomad-agent | ||
# generate Docker tags based on the following events/attributes | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=sha | ||
- name: Login to Docker repository | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: gcr.io | ||
username: _json_key | ||
password: ${{ secrets.GCLOUD_SERVICE_KEY }} | ||
|
||
- name: Build and push container | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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,55 @@ | ||
name: Rust | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
- uses: Swatinem/rust-cache@v1 | ||
|
||
- name: Build agents | ||
run: cargo build --verbose | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
- uses: Swatinem/rust-cache@v1 | ||
|
||
- name: Run tests | ||
run: cargo test --verbose | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
- uses: Swatinem/rust-cache@v1 | ||
|
||
- name: Rustfmt | ||
run: cargo fmt -- --check | ||
|
||
- name: Clippy | ||
run: cargo clippy -- -D warnings |
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 |
---|---|---|
@@ -1,57 +1,25 @@ | ||
# syntax=docker/dockerfile:experimental | ||
FROM ubuntu:20.04 | ||
|
||
FROM rust:1.56 as builder | ||
WORKDIR /usr/src | ||
ENV TARGET_DIR='target' | ||
WORKDIR /app | ||
|
||
# 1a: Prepare for static linking | ||
RUN apt-get update && \ | ||
apt-get dist-upgrade -y && \ | ||
apt-get install -y musl-tools clang && \ | ||
rustup target add x86_64-unknown-linux-musl | ||
RUN apt-get update \ | ||
&& apt-get install -y libssl-dev ca-certificates \ | ||
&& chmod 777 /app \ | ||
&& mkdir /usr/share/nomad \ | ||
&& chmod 1000 /usr/share/nomad | ||
|
||
# Add workspace to workdir | ||
COPY agents ./agents | ||
COPY chains ./chains | ||
COPY tools ./tools | ||
COPY nomad-base ./nomad-base | ||
COPY nomad-core ./nomad-core | ||
COPY nomad-test ./nomad-test | ||
COPY ${TARGET_DIR}/release/updater \ | ||
${TARGET_DIR}/release/relayer \ | ||
${TARGET_DIR}/release/watcher \ | ||
${TARGET_DIR}/release/processor \ | ||
${TARGET_DIR}/release/kathy \ | ||
${TARGET_DIR}/release/kms-cli \ | ||
${TARGET_DIR}/release/nomad-cli ./ | ||
|
||
COPY Cargo.toml . | ||
COPY Cargo.lock . | ||
COPY config ./config | ||
|
||
# Build binaries | ||
RUN --mount=id=cargo,type=cache,target=/usr/src/target \ | ||
--mount=id=cargo-home-registry,type=cache,target=/usr/local/cargo/registry \ | ||
--mount=id=cargo-home-git,type=cache,target=/usr/local/cargo/git \ | ||
cargo build --release | ||
|
||
# Copy artifacts out of volume | ||
WORKDIR /release | ||
RUN --mount=id=cargo,type=cache,target=/usr/src/target cp /usr/src/target/release/updater . | ||
RUN --mount=id=cargo,type=cache,target=/usr/src/target cp /usr/src/target/release/relayer . | ||
RUN --mount=id=cargo,type=cache,target=/usr/src/target cp /usr/src/target/release/watcher . | ||
RUN --mount=id=cargo,type=cache,target=/usr/src/target cp /usr/src/target/release/processor . | ||
RUN --mount=id=cargo,type=cache,target=/usr/src/target cp /usr/src/target/release/kathy . | ||
RUN --mount=id=cargo,type=cache,target=/usr/src/target cp /usr/src/target/release/kms-cli . | ||
RUN --mount=id=cargo,type=cache,target=/usr/src/target cp /usr/src/target/release/nomad-cli . | ||
|
||
# 2: Copy the binaries to release image | ||
FROM ubuntu:20.04 | ||
RUN apt-get update && \ | ||
apt-get install -y libssl-dev \ | ||
ca-certificates | ||
|
||
WORKDIR /app | ||
COPY --from=builder /release/updater . | ||
COPY --from=builder /release/relayer . | ||
COPY --from=builder /release/watcher . | ||
COPY --from=builder /release/processor . | ||
COPY --from=builder /release/kathy . | ||
COPY --from=builder /release/kms-cli . | ||
COPY --from=builder /release/nomad-cli . | ||
COPY config ./config | ||
RUN chmod 777 /app | ||
RUN mkdir /usr/share/nomad/ && chmod 1000 /usr/share/nomad | ||
USER 1000 | ||
CMD ["./watcher"] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.