From 67d0ca19277dcc72981fb5750c882265c61e148b Mon Sep 17 00:00:00 2001 From: Patrick Hobusch Date: Thu, 29 Apr 2021 12:20:48 +0800 Subject: [PATCH] Add initial Dockerfile and CI workflow --- .dockerignore | 2 ++ .github/workflows/ci.yml | 47 ++++++++++++++++++++++++++++++++++++++++ Dockerfile | 11 ++++++++++ README.md | 21 +++++++++++++++++- download.sh | 9 ++++++++ pom.xml | 12 ++++++++++ 6 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/ci.yml create mode 100644 Dockerfile create mode 100755 download.sh create mode 100644 pom.xml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4589bf5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.git/ +.github/ \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1910ce6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,47 @@ +name: build + +on: + workflow_dispatch: {} # allow workflow to be run manually + push: + branches: [ main ] + release: + types: [ published ] + +jobs: + + build: + + name: Build Image + + runs-on: ubuntu-latest + + steps: + + - name: Checkout + uses: actions/checkout@v2 + + # - run: echo ::set-env name=IMAGE_TAG::${GITHUB_REF:10} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build + id: build + uses: docker/build-push-action@v2 + with: + push: ${{ github.event_name == 'release' }} + tags: | + ghcr.io/${{ github.repository_owner }}/mapi:latest + + - name: Image digest + run: echo ${{ steps.build.outputs.digest }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e466ab5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM maven:3-openjdk-11-slim + +ENV DEPENDENCY="org.apache.maven.plugins:maven-dependency-plugin:3.1.2" + +ADD . / + +# try to download as much dependencies as possible during build + +RUN mvn package -B +RUN mvn ${DEPENDENCY}:go-offline -B +RUN mvn ${DEPENDENCY}:get -Dartifact=${DEPENDENCY}:jar -B diff --git a/README.md b/README.md index 658724f..62b81e2 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,21 @@ -# docker-mapi Maven Atlassian Plugin Installer +================================ + +Usage: Start the Docker container and run the `./download.sh` script as follows: + +``` +./download.sh +``` + +The script will download the artifact without version to the output directory. E.g.: + +``` +./download.sh de.aservo:confapi-crowd-plugin:0.0.8:jar ./plugins +``` + +This will result in: + +``` +$ ls ./plugins +confapi-crowd-plugin.jar +``` diff --git a/download.sh b/download.sh new file mode 100755 index 0000000..070bdaf --- /dev/null +++ b/download.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +ARTIFACT=$1 +OUTPUT=$2 + +DEPENDENCY="org.apache.maven.plugins:maven-dependency-plugin:3.1.2" + +mvn $DEPENDENCY:get -Dartifact=$ARTIFACT -Dtransitive=false -B +mvn $DEPENDENCY:copy -Dartifact=$ARTIFACT -DoutputDirectory=$OUTPUT -Dmdep.stripVersion=true -B diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..be11e31 --- /dev/null +++ b/pom.xml @@ -0,0 +1,12 @@ + + + + 4.0.0 + + de.aservo + stub + 0.0.0 + + \ No newline at end of file