From 63e36e93cf1859f21ce303688d35c0009897ccd2 Mon Sep 17 00:00:00 2001 From: Stefan Hattrell <29941279+digorgonzola@users.noreply.github.com> Date: Thu, 13 Apr 2023 14:41:22 +1000 Subject: [PATCH] test native gha vs docker --- .github/workflows/build.yaml | 60 ++++++++++++++++++++++++++++++++++++ Dockerfile.build | 24 +++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 Dockerfile.build diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 000000000..4fe3f8760 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,60 @@ +name: Docker Build Pipeline + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Build Docker Image + uses: docker/build-push-action@v4 + env: + BUILDER_UID: ${{ runner.uid }} + with: + context: . + file: Dockerfile.build + load: true + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + tags: aodn-portal-build + + - name: Run Pipeline Steps + run: | + docker run --rm \ + -v ${{ github.workspace }}:/workspace \ + -v ${{ runner.home }}/bin:${HOME}/bin \ + -w /workspace \ + --entrypoint /bin/bash \ + aodn-portal-build -c ' + mvn -B clean test + grails -DARTIFACT_BUILD_NUMBER=${BUILD_NUMBER} -Dgrails.work.dir=${WORKSPACE}/target clean --non-interactive --plain-output + grails -DARTIFACT_BUILD_NUMBER=${BUILD_NUMBER} -Dgrails.work.dir=${WORKSPACE}/target war --non-interactive --plain-output + ' + + - name: Archive Artifact + if: ${{ !env.ACT }} + uses: actions/upload-artifact@v3 + with: + name: war-file + path: target/*.war diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 000000000..517d5b547 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,24 @@ +FROM ubuntu:20.04 + +ARG DEBIAN_FRONTEND=noninteractive + +ENV GRAILS_VERSION 2.4.4 +ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 +ENV GRAILS_HOME /usr/lib/jvm/grails +ENV PATH $GRAILS_HOME/bin:$PATH + +RUN apt-get update && apt-get install -y --no-install-recommends \ + git \ + libxml2-utils \ + maven \ + openjdk-8-jdk \ + unzip \ + wget \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /usr/lib/jvm + +RUN wget https://github.com/grails/grails-core/releases/download/v$GRAILS_VERSION/grails-$GRAILS_VERSION.zip && \ + unzip grails-$GRAILS_VERSION.zip && \ + rm -rf grails-$GRAILS_VERSION.zip && \ + ln -s grails-$GRAILS_VERSION grails