Update workflow to fix dependency issue (#2309)

* Update workflow to fix dependency issue

* Update workflow

* Update workflow and dockerfile

* Specify tag

* Update main dockerfile as well

* Mirror rust image to docker hub

* Update submodule ref

Co-authored-by: Rory de Zoete <rdezoete@Rorys-Mac-Studio.fritz.box>
This commit is contained in:
Rory de Zoete
2022-08-19 12:07:46 +02:00
committed by GitHub
parent 6b9cef02a1
commit 12e87f0df3
4 changed files with 21 additions and 36 deletions

View File

@@ -446,29 +446,13 @@ jobs:
- name: Kaniko build compute tools - name: Kaniko build compute tools
run: /kaniko/executor --snapshotMode=redo --cache=true --cache-repo 369495373322.dkr.ecr.eu-central-1.amazonaws.com/cache --snapshotMode=redo --context . --dockerfile Dockerfile.compute-tools --destination 369495373322.dkr.ecr.eu-central-1.amazonaws.com/compute-tools:$GITHUB_RUN_ID run: /kaniko/executor --snapshotMode=redo --cache=true --cache-repo 369495373322.dkr.ecr.eu-central-1.amazonaws.com/cache --snapshotMode=redo --context . --dockerfile Dockerfile.compute-tools --destination 369495373322.dkr.ecr.eu-central-1.amazonaws.com/compute-tools:$GITHUB_RUN_ID
promote-image-compute-tools:
runs-on: dev
needs: [ compute-tools-image ]
if: github.event_name != 'workflow_dispatch'
container: amazon/aws-cli
strategy:
fail-fast: false
matrix:
name: [ compute-tools ]
steps:
- name: Promote image to latest
run:
MANIFEST=$(aws ecr batch-get-image --repository-name ${{ matrix.name }} --image-ids imageTag=$GITHUB_RUN_ID --query 'images[].imageManifest' --output text) && aws ecr put-image --repository-name ${{ matrix.name }} --image-tag latest --image-manifest "$MANIFEST"
compute-node-image: compute-node-image:
runs-on: dev runs-on: dev
container: gcr.io/kaniko-project/executor:v1.9.0-debug container: gcr.io/kaniko-project/executor:v1.9.0-debug
# note: This image depends on neondatabase/compute-tools:latest (or :thisversion), # note: This image depends on neondatabase/compute-tools:latest (or :thisversion),
# which isn't available until after the image is promoted. # which isn't available until after the image is promoted.
# Ergo, we must explicitly build and promote compute-tools separately. # Ergo, we must explicitly build and promote compute-tools separately.
needs: needs: [ compute-tools-image ]
- promote-image-compute-tools
steps: steps:
- name: Checkout - name: Checkout
@@ -482,17 +466,17 @@ jobs:
- name: Kaniko build compute node - name: Kaniko build compute node
working-directory: ./vendor/postgres/ working-directory: ./vendor/postgres/
run: /kaniko/executor --snapshotMode=redo --cache=true --cache-repo 369495373322.dkr.ecr.eu-central-1.amazonaws.com/cache --snapshotMode=redo --context . --build-arg=COMPUTE_TOOLS_TAG=$GITHUB_RUN_ID --destination 369495373322.dkr.ecr.eu-central-1.amazonaws.com/compute-node:$GITHUB_RUN_ID run: /kaniko/executor --snapshotMode=redo --cache=true --cache-repo 369495373322.dkr.ecr.eu-central-1.amazonaws.com/cache --snapshotMode=redo --context . --build-arg=TAG=$GITHUB_RUN_ID --destination 369495373322.dkr.ecr.eu-central-1.amazonaws.com/compute-node:$GITHUB_RUN_ID
promote-images: promote-images:
runs-on: dev runs-on: dev
needs: [ neon-image, compute-node-image ] needs: [ neon-image, compute-node-image, compute-tools-image ]
if: github.event_name != 'workflow_dispatch' if: github.event_name != 'workflow_dispatch'
container: amazon/aws-cli container: amazon/aws-cli
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
name: [ neon, compute-node ] name: [ neon, compute-node, compute-tools ]
steps: steps:
- name: Promote image to latest - name: Promote image to latest
@@ -509,18 +493,6 @@ jobs:
run: | run: |
go install github.com/google/go-containerregistry/cmd/crane@31786c6cbb82d6ec4fb8eb79cd9387905130534e # v0.11.0 go install github.com/google/go-containerregistry/cmd/crane@31786c6cbb82d6ec4fb8eb79cd9387905130534e # v0.11.0
go install github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login@69c85dc22db6511932bbf119e1a0cc5c90c69a7f # v0.6.0 go install github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login@69c85dc22db6511932bbf119e1a0cc5c90c69a7f # v0.6.0
# - name: Get build tag
# run: |
# if [[ "$GITHUB_REF_NAME" == "main" ]]; then
# echo "::set-output name=tag::$(git rev-list --count HEAD)"
# elif [[ "$GITHUB_REF_NAME" == "release" ]]; then
# echo "::set-output name=tag::release-$(git rev-list --count HEAD)"
# else
# echo "GITHUB_REF_NAME (value '$GITHUB_REF_NAME') is not set to either 'main' or 'release' "
# echo "::set-output name=tag::$GITHUB_RUN_ID"
# fi
# id: build-tag
- name: Configure ECR login - name: Configure ECR login
run: | run: |
@@ -536,6 +508,9 @@ jobs:
- name: Pull compute node image from ECR - name: Pull compute node image from ECR
run: crane pull 369495373322.dkr.ecr.eu-central-1.amazonaws.com/compute-node:latest compute-node run: crane pull 369495373322.dkr.ecr.eu-central-1.amazonaws.com/compute-node:latest compute-node
- name: Pull rust image from ECR
run: crane pull 369495373322.dkr.ecr.eu-central-1.amazonaws.com/rust:pinned rust
- name: Configure docker login - name: Configure docker login
run: | run: |
# ECR Credential Helper & Docker Hub don't work together in config, hence reset # ECR Credential Helper & Docker Hub don't work together in config, hence reset
@@ -551,6 +526,9 @@ jobs:
- name: Push compute node image to Docker Hub - name: Push compute node image to Docker Hub
run: crane push compute-node neondatabase/compute-node:${{needs.tag.outputs.build-tag}} run: crane push compute-node neondatabase/compute-node:${{needs.tag.outputs.build-tag}}
- name: Push rust image to Docker Hub
run: crane push rust neondatabase/rust:pinned
- name: Add latest tag to images - name: Add latest tag to images
if: | if: |
(github.ref_name == 'main' || github.ref_name == 'release') && (github.ref_name == 'main' || github.ref_name == 'release') &&

View File

@@ -2,9 +2,12 @@
### The image itself is mainly used as a container for the binaries and for starting e2e tests with custom parameters. ### The image itself is mainly used as a container for the binaries and for starting e2e tests with custom parameters.
### By default, the binaries inside the image have some mock parameters and can start, but are not intended to be used ### By default, the binaries inside the image have some mock parameters and can start, but are not intended to be used
### inside this image in the real deployments. ### inside this image in the real deployments.
ARG REPOSITORY=369495373322.dkr.ecr.eu-central-1.amazonaws.com
ARG IMAGE=rust
ARG TAG=pinned
# Build Postgres # Build Postgres
FROM 369495373322.dkr.ecr.eu-central-1.amazonaws.com/rust:pinned AS pg-build FROM $REPOSITORY/$IMAGE:$TAG AS pg-build
WORKDIR /home/nonroot WORKDIR /home/nonroot
COPY vendor/postgres vendor/postgres COPY vendor/postgres vendor/postgres
@@ -17,7 +20,7 @@ RUN set -e \
&& tar -C tmp_install -czf /home/nonroot/postgres_install.tar.gz . && tar -C tmp_install -czf /home/nonroot/postgres_install.tar.gz .
# Build zenith binaries # Build zenith binaries
FROM 369495373322.dkr.ecr.eu-central-1.amazonaws.com/rust:pinned AS build FROM $REPOSITORY/$IMAGE:$TAG AS build
WORKDIR /home/nonroot WORKDIR /home/nonroot
ARG GIT_VERSION=local ARG GIT_VERSION=local

View File

@@ -1,6 +1,10 @@
# First transient image to build compute_tools binaries # First transient image to build compute_tools binaries
# NB: keep in sync with rust image version in .github/workflows/build_and_test.yml # NB: keep in sync with rust image version in .github/workflows/build_and_test.yml
FROM 369495373322.dkr.ecr.eu-central-1.amazonaws.com/rust:pinned AS rust-build ARG REPOSITORY=369495373322.dkr.ecr.eu-central-1.amazonaws.com
ARG IMAGE=rust
ARG TAG=pinned
FROM $REPOSITORY/$IMAGE:$TAG AS rust-build
WORKDIR /home/nonroot WORKDIR /home/nonroot
# Enable https://github.com/paritytech/cachepot to cache Rust crates' compilation results in Docker builds. # Enable https://github.com/paritytech/cachepot to cache Rust crates' compilation results in Docker builds.