Skip to content

Commit

Permalink
refactor: turn into monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega committed Nov 12, 2024
1 parent b84e275 commit 0ddfbf8
Show file tree
Hide file tree
Showing 100 changed files with 10,949 additions and 783 deletions.
4 changes: 4 additions & 0 deletions .github/images/init/dockerfile.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM amazon/aws-cli
RUN yum update -y && yum install -y tar gzip
COPY docker/entrypoint.sh /entrypoint.sh
ENTRYPOINT ["sh", "/entrypoint.sh"]
2 changes: 2 additions & 0 deletions .github/images/init/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
aws s3 cp "s3://$BUCKET/$KEY" "$DATA_DIR"
tar -xzvf "$DATA_DIR/$KEY" -C "$DATA_DIR"
10 changes: 10 additions & 0 deletions .github/images/operator/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM debian:12-slim

RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*

ARG TARGETARCH
COPY bin/operator-Linux-${TARGETARCH} /bin/operator
RUN chmod +x /bin/operator
RUN ln -s /bin/operator /operator

ENTRYPOINT [ "operator" ]
File renamed without changes.
33 changes: 33 additions & 0 deletions .github/images/rpc/dockerfile.hydra
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ARG RUST_VERSION=1.81.0
ARG BRANCH=main

FROM rust:${RUST_VERSION}-slim-bullseye AS build
WORKDIR /app

RUN apt-get update && apt-get install -y libssl-dev pkg-config git ca-certificates
RUN git clone https://github.com/cardano-scaling/hydra-control-plane.git
RUN cd hydra-control-plane && git checkout ${BRANCH}

WORKDIR /app/hydra-control-plane
RUN cargo build --locked --release
RUN cp ./target/release/metrics-exporter /bin/metrics-exporter
RUN cp ./target/release/open-head /bin/open-head
RUN cp ./target/release/control-plane /bin/control-plane

FROM debian:bullseye-slim AS final
RUN apt-get update && apt-get install -y ca-certificates curl
WORKDIR /home/app

# Copy the executable from the "build" stage.
COPY --from=build /bin/metrics-exporter /bin/metrics-exporter
COPY --from=build /bin/open-head /bin/open-head
COPY --from=build /bin/control-plane /bin/control-plane

# Configure rocket to listen on all interfaces.
ENV ROCKET_ADDRESS=0.0.0.0
ENV ROCKET_PORT=8000

# Expose the port that the application listens on.
EXPOSE 8000

CMD ["/bin/metrics-exporter"]
114 changes: 114 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Docker
on:
workflow_dispatch: {}
push:
branches:
- "main"
paths:
- ".github/image/Dockerfile"
- ".github/workflows/docker.yml"
- "src/**"

jobs:
build:
continue-on-error: true

strategy:
matrix:
include:
- release_for: Linux-x86_64
build_on: ubuntu-latest
target: x86_64-unknown-linux-gnu
args: "--locked --release"

- release_for: Linux-arm64
build_on: buildjet-2vcpu-ubuntu-2204-arm
target: "aarch64-unknown-linux-gnu"
args: "--locked --release"

runs-on: ${{ matrix.build_on }}
steps:
- name: checkout repository
uses: actions/checkout@v4

- uses: Swatinem/rust-cache@v2
with:
shared-key: "release"

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Run cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --target ${{ matrix.target }} ${{ matrix.args }}

- name: rename binaries
run: |
mv target/${{ matrix.target }}/release/operator${{ matrix.ext }} operator-${{ matrix.release_for }}${{ matrix.ext }}
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.release_for }}
path: operator-${{ matrix.release_for }}${{ matrix.ext }}

docker:
runs-on: ubuntu-latest
needs: [build]

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/cardano-scaling/doom-patrol-operator
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern=v{{major}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{version}}
type=sha
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: ghcr.io/cardano-scaling
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: binaries-*
merge-multiple: true
path: .github/image/bin

# we need to rename the artifact so that the name matches
# the value that Docker uses for TARGET_ARCH to keep the
# Dockerfile simple
- name: Rename artifacts
run: |+
mv .github/image/bin/operator-Linux-x86_64 .github/image/bin/operator-Linux-amd64
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .github/image
platforms: linux/arm64,linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
42 changes: 0 additions & 42 deletions .github/workflows/hydra-control-plane.yml

This file was deleted.

42 changes: 0 additions & 42 deletions .github/workflows/open-head.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ result*
.envrc
.direnv
# runtime
protocol-parameters.json
utxo.json
*.vk
*.sk
Expand Down
Loading

0 comments on commit 0ddfbf8

Please sign in to comment.