Skip to content

Commit

Permalink
Merge pull request #7 from nomad-xyz/arnaud/cleanup
Browse files Browse the repository at this point in the history
Added Github actions for Docker and rust builds
  • Loading branch information
Arnaud Delabarre authored Feb 14, 2022
2 parents 1ee4151 + 20b45d0 commit d4bee91
Show file tree
Hide file tree
Showing 17 changed files with 132 additions and 922 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/docker.yml
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 }}
55 changes: 55 additions & 0 deletions .github/workflows/rust.yml
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
64 changes: 16 additions & 48 deletions Dockerfile
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"]
21 changes: 0 additions & 21 deletions DockerfileV2

This file was deleted.

23 changes: 0 additions & 23 deletions helm/nomad-agent/.helmignore

This file was deleted.

6 changes: 0 additions & 6 deletions helm/nomad-agent/Chart.yaml

This file was deleted.

44 changes: 0 additions & 44 deletions helm/nomad-agent/README.md

This file was deleted.

Empty file.
63 changes: 0 additions & 63 deletions helm/nomad-agent/templates/_helpers.tpl

This file was deleted.

35 changes: 0 additions & 35 deletions helm/nomad-agent/templates/configmap.yaml

This file was deleted.

Loading

0 comments on commit d4bee91

Please sign in to comment.