Skip to content

Commit

Permalink
Docker refactoring + remove travis (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
vharseko authored May 16, 2022
1 parent a11fa90 commit bc6166b
Show file tree
Hide file tree
Showing 7 changed files with 416 additions and 134 deletions.
128 changes: 121 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Maven
name: Build

on:
push:
Expand All @@ -7,22 +7,24 @@ on:
branches: [ master ]

jobs:
build:
name: Maven build
build-maven:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java: [ '8']
os: [ 'ubuntu-latest', 'macos-10.15', 'windows-latest' ]
os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Java ${{ matrix.Java }} (${{ matrix.os }})
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: 'adopt'
- name: Cache Maven packages
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-repository-${{ hashFiles('**/pom.xml') }}
Expand All @@ -37,4 +39,116 @@ jobs:
- name: Build with Maven
env:
MAVEN_OPTS: -Dhttps.protocols=TLSv1.2 -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true -Dmaven.wagon.http.retryHandler.count=10
run: mvn --batch-mode --update-snapshots package ${{ steps.maven-profile-flag.outputs.MAVEN_VERIFY_STAGE }} --file pom.xml ${{ steps.maven-profile-flag.outputs.MAVEN_PROFILE_FLAG }}
run: mvn --batch-mode --errors --update-snapshots package ${{ steps.maven-profile-flag.outputs.MAVEN_VERIFY_STAGE }} --file pom.xml ${{ steps.maven-profile-flag.outputs.MAVEN_PROFILE_FLAG }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}-${{ matrix.java }}
retention-days: 5
path: |
openam-distribution/openam-distribution-kit/target/*.zip
openam-distribution/openam-distribution-ssoconfiguratortools/target/*.zip
openam-distribution/openam-distribution-fedlet-unconfigured/target/*.zip
openam-distribution/openam-distribution-ssoadmintools/target/*.zip
openam-console/target/*.war
openam-server/target/*.war
openam-server-only/target/*.war
openam-distribution/openam-distribution-docker/Dockerfile*
build-docker:
runs-on: 'ubuntu-latest'
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Get latest release version
shell: bash
run: |
git fetch -t; export git_version_last="$(git describe --abbrev=0 --tags)" ; echo "last release: $git_version_last"
echo "release_version=$git_version_last" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
localhost:5000/${{ github.repository }}
tags: |
type=raw,value=latest
type=raw,value=${{ env.release_version }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
- name: Build image
uses: docker/build-push-action@v2
continue-on-error: true
with:
context: ./openam-distribution/openam-distribution-docker
file: ./openam-distribution/openam-distribution-docker/Dockerfile
build-args: |
VERSION=${{ env.release_version }}
platforms: linux/amd64,linux/arm64/8
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Docker test
shell: bash
run: |
docker run --rm -it -d --name=test localhost:5000/${GITHUB_REPOSITORY,,}:${{ env.release_version }}
timeout 3m bash -c 'until docker inspect --format="{{json .State.Health.Status}}" test | grep -q \"healthy\"; do sleep 10; done'
build-docker-alpine:
runs-on: 'ubuntu-latest'
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Get latest release version
shell: bash
run: |
git fetch -t; export git_version_last="$(git describe --abbrev=0 --tags)" ; echo "last release: $git_version_last"
echo "release_version=$git_version_last" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
localhost:5000/${{ github.repository }}
tags: |
type=raw,value=alpine
type=raw,value=${{ env.release_version }}-alpine
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
- name: Build image
uses: docker/build-push-action@v2
continue-on-error: true
with:
context: ./openam-distribution/openam-distribution-docker
file: ./openam-distribution/openam-distribution-docker/Dockerfile-alpine
build-args: |
VERSION=${{ env.release_version }}
platforms: linux/amd64,linux/arm64/8, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6, linux/ppc64le
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Docker test
shell: bash
run: |
docker run --rm -it -d --name=test localhost:5000/${GITHUB_REPOSITORY,,}:${{ env.release_version }}-alpine
timeout 3m bash -c 'until docker inspect --format="{{json .State.Health.Status}}" test | grep -q \"healthy\"; do sleep 10; done'
77 changes: 62 additions & 15 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
name: Deploy Maven
name: Package/Deploy

on:
workflow_dispatch:
workflow_run:
branches: [ master ]
workflows: ["Build Maven"]
workflows: ["Build"]
types: [completed]
jobs:
deploy:
name: Maven deploy
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event=='push' }}
deploy-maven:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: 'ubuntu-latest'
steps:
- name: Print github context
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Install gpg secret key
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
if: ${{ env.GPG_PRIVATE_KEY!=''}}
run: |
cat <(echo -e "${{ secrets.GPG_PRIVATE_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Set up Java for publishing to Maven Central Repository OSS
uses: actions/setup-java@v2
with:
Expand All @@ -38,10 +33,62 @@ jobs:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-repository-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2-repository
- name: Install gpg secret key
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
if: ${{ env.GPG_PRIVATE_KEY!=''}}
run: |
cat <(echo -e "${{ secrets.GPG_PRIVATE_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- name: Build package local
env:
MAVEN_OPTS: -Dhttps.protocols=TLSv1.2 -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true -Dmaven.wagon.http.retryHandler.count=10
if: ${{ !(github.event.workflow_run.event=='push' && env.MAVEN_USERNAME!='' && env.MAVEN_PASSWORD!='')}}
run: mvn --batch-mode --errors --update-snapshots -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} package --file pom.xml
- name: Publish to the Maven Central Repository
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_OPTS: -Dhttps.protocols=TLSv1.2 -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true -Dmaven.wagon.http.retryHandler.count=10
if: ${{ env.MAVEN_USERNAME!='' && env.MAVEN_PASSWORD!=''}}
run: mvn --batch-mode --update-snapshots -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} deploy --file pom.xml
if: ${{ github.event.workflow_run.event=='push' && env.MAVEN_USERNAME!='' && env.MAVEN_PASSWORD!=''}}
run: mvn --batch-mode --errors --update-snapshots -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} deploy --file pom.xml
- name: Upload artifacts OpenAM Distribution Kit, containing all distributable artifacts
uses: actions/upload-artifact@v3
with:
name: OpenAM Distribution Kit, containing all distributable artifacts
path: openam-distribution/openam-distribution-kit/target/*.zip
- name: Upload artifacts OpenAM Distribution SSO Configurator Tools Kit
uses: actions/upload-artifact@v3
with:
name: OpenAM Distribution SSO Configurator Tools Kit
path: openam-distribution/openam-distribution-ssoconfiguratortools/target/*.zip
- name: Upload artifacts OpenAM Distribution Fedlet UnConfigured zip
uses: actions/upload-artifact@v3
with:
name: OpenAM Distribution Fedlet UnConfigured zip
path: openam-distribution/openam-distribution-fedlet-unconfigured/target/*.zip
- name: Upload artifacts OpenAM Distribution SSO Admin Tools Kit
uses: actions/upload-artifact@v3
with:
name: OpenAM Distribution SSO Admin Tools Kit
path: openam-distribution/openam-distribution-ssoadmintools/target/*.zip
- name: Upload artifacts OpenAM Admin Console
uses: actions/upload-artifact@v3
with:
name: OpenAM Admin Console
path: openam-console/target/*.war
- name: Upload artifacts OpenAM Server Component
uses: actions/upload-artifact@v3
with:
name: OpenAM Server Component
path: openam-server/target/*.war
- name: Upload artifacts OpenAM Server Only Component
uses: actions/upload-artifact@v3
with:
name: OpenAM Server Only Component
path: openam-server-only/target/*.war
- name: Upload artifacts OpenAM Dockerfile
uses: actions/upload-artifact@v3
with:
name: OpenAM Dockerfile
path: openam-distribution/openam-distribution-docker/Dockerfile*
Loading

0 comments on commit bc6166b

Please sign in to comment.