From 66f5e6423fda20b0783033e54aba2240877e1170 Mon Sep 17 00:00:00 2001 From: Jake Thompson Date: Fri, 2 Feb 2024 11:21:35 -0500 Subject: [PATCH] Try round one --- .dockerignore | 1 + .github/workflows/publish-image.yml | 42 +++++++++++++++++++++++++++++ Dockerfile | 42 +++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/publish-image.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..821c19d --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.github \ No newline at end of file diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml new file mode 100644 index 0000000..a4f25d3 --- /dev/null +++ b/.github/workflows/publish-image.yml @@ -0,0 +1,42 @@ +name: Create and publish Docker runner image + +on: + workflow_dispatch: + schedule: + - cron: "0 0 * * *" + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-22.04-16core + + permissions: + packages: write + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7f86f81 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM ghcr.io/actions/actions-runner:latest + +ARG TARGETOS +ARG TARGETARCH +ARG ZIG_VERSION=0.11.0 +ARG CARGO_LAMBDA_VERSION=1.0.3 + +# Install base packages +RUN sudo apt update -y \ + && sudo apt install -y curl wget tar xz-utils unzip build-essential + +# Install GH CLI +RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ + && sudo apt update && sudo apt install -y gh + +# Install Rust +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y +ENV PATH="/home/runner/.cargo/bin:${PATH}" + +RUN rustup target add aarch64-unknown-linux-musl \ + && rustup toolchain add nightly + +RUN cargo install --locked cargo-lambda@${CARGO_LAMBDA_VERSION} + +# Install Zig +RUN export RUNNER_ARCH=${TARGETARCH} \ + && if [ "$RUNNER_ARCH" = "arm64" ]; then export RUNNER_ARCH=aarch64 ; fi \ + && if [ "$RUNNER_ARCH" = "amd64" ]; then export RUNNER_ARCH=x86_64 ; fi \ + && curl -f -L -o zig.tar.xz https://ziglang.org/download/${ZIG_VERSION}/zig-${TARGETOS}-${RUNNER_ARCH}-${ZIG_VERSION}.tar.xz \ + && tar xf zig.tar.xz \ + && rm zig.tar.xz \ + && mv zig-${TARGETOS}-${RUNNER_ARCH}-${ZIG_VERSION} zig-${ZIG_VERSION} + +ENV PATH="/home/runner/zig-${ZIG_VERSION}:${PATH}" + +# Install Node v20 and AWS CDK +RUN curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - \ + && sudo apt-get install -y nodejs \ + && sudo npm i -g aws-cdk + +RUN sudo rm -rf /var/lib/apt/lists/* \ No newline at end of file