From 9017f9816afb6449ec2313602171b024351a09b8 Mon Sep 17 00:00:00 2001 From: Roman Zajic Date: Thu, 5 Oct 2023 08:34:36 +0800 Subject: [PATCH] Test: container image workflow (#792) * test: Container image workflow and dockerfile * test: test build container image workflow * test: Test build container image workflow - authorization fixed * test: Test build container image workflow - remove dummy job * test: delete Test build container image workflow --- .github/workflows/container-image.yml | 50 +++++++++++++++++++++++++++ docker/Dockerfile.test.amd64 | 30 ++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 .github/workflows/container-image.yml create mode 100644 docker/Dockerfile.test.amd64 diff --git a/.github/workflows/container-image.yml b/.github/workflows/container-image.yml new file mode 100644 index 00000000..8987ef96 --- /dev/null +++ b/.github/workflows/container-image.yml @@ -0,0 +1,50 @@ +name: container-image-build + +on: + workflow_call: + inputs: + image_tag: + type: string + default: ${{ github.event.number }} + outputs: + image: + description: The resulting image link + value: ${{ jobs.build-docker-image.outputs.image }} + + workflow_dispatch: + +jobs: + build-docker-image: + strategy: + matrix: + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + + name: docker-build-${{ matrix.os }} + outputs: + image: ${{ steps.build.outputs.image }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Build image + id: build + run: | + + SHORT_REF=$(git rev-parse --short HEAD) + + TAG=$([ "${PR_NUMBER}" == "" ] && echo "${SHORT_REF}" || echo "${PR_NUMBER}") + IMAGE=quay.io/wakuorg/go-waku-pr:${TAG} + + echo "image=${IMAGE}" >> $GITHUB_OUTPUT + echo "commit_hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + + docker login -u ${QUAY_USER} -p ${QUAY_PASSWORD} quay.io + docker build -t ${IMAGE} -f docker/Dockerfile.test.amd64 --label quay.expires-after=7d . + docker push ${IMAGE} + env: + QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }} + QUAY_USER: ${{ secrets.QUAY_USER }} + PR_NUMBER: ${{ inputs.image_tag }} + diff --git a/docker/Dockerfile.test.amd64 b/docker/Dockerfile.test.amd64 new file mode 100644 index 00000000..49fdec90 --- /dev/null +++ b/docker/Dockerfile.test.amd64 @@ -0,0 +1,30 @@ +# BUILD IMAGE -------------------------------------------------------- +FROM golang:1.20 as builder + +WORKDIR /app +COPY . . + +# Build the final node binary +RUN make -j$(nproc) build + +# ACTUAL IMAGE ------------------------------------------------------- + +FROM debian:12.1-slim + +LABEL maintainer="romanzac@status.im" +LABEL source="https://github.com/waku-org/go-waku" +LABEL description="go-waku: Waku V2 node - test" + +# color, nocolor, json +ENV GOLOG_LOG_FMT=nocolor + +RUN apt update && apt install -y ca-certificates + +# go-waku default ports +EXPOSE 9000 30303 60000 60001 8008 8009 + +COPY --from=builder /app/build/waku /usr/bin/waku + +ENTRYPOINT ["/usr/bin/waku"] +# By default just show help if called without arguments +CMD ["--help"]