Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
klo2k committed Nov 5, 2023
2 parents 6a65f3c + b4499f6 commit 281b7c0
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 24 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/deploy_development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ on:
- Dockerfile

jobs:
get_latest_version:
uses: ./.github/workflows/get_nexus_version_latest.yml

build_deploy_to_registry:
runs-on: ubuntu-latest
needs: get_latest_version
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

# Enable docker cache to speed-up builds
- name: Setup Docker build cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: /tmp/buildx-cache
key: ${{runner.os}}-buildx-${{github.sha}}
Expand All @@ -28,27 +32,31 @@ jobs:
# Enable multi-architecture support on build node
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3
with:
version: latest

- name: Docker login
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{secrets.REGISTRY_USERNAME}}
password: ${{secrets.REGISTRY_PASSWORD}}

- name: Build + Push image ("development")
env:
NEXUS_VERSION: ${{needs.get_latest_version.outputs.nexus_version}}
run: |
docker buildx build \
--build-arg "NEXUS_VERSION=${NEXUS_VERSION}" \
--cache-from type=local,src=/tmp/buildx-cache \
--cache-to type=local,dest=/tmp/buildx-cache \
--label org.opencontainers.image.revision="${{github.sha}}" \
--label org.opencontainers.image.version="${NEXUS_VERSION}" \
--platform "linux/arm/v7,linux/arm64" \
--pull \
--tag "${{secrets.REGISTRY_USERNAME}}/nexus3:development" \
Expand Down
53 changes: 42 additions & 11 deletions .github/workflows/deploy_release.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
name: Deploy Release Build

# Trigger on release
# Trigger on new version tag
on:
release:
types:
- released
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+*'

jobs:
# get_latest_version:
# uses: ./.github/workflows/get_nexus_version_latest.yml

build_deploy_to_registry:
runs-on: ubuntu-latest
# needs: get_latest_version
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

# Enable docker cache to speed-up builds
- name: Setup Docker build cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: /tmp/buildx-cache
key: ${{runner.os}}-buildx-${{github.sha}}
Expand All @@ -24,40 +28,67 @@ jobs:
# Enable multi-architecture support on build node
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3
with:
version: latest

- name: Docker login
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{secrets.REGISTRY_USERNAME}}
password: ${{secrets.REGISTRY_PASSWORD}}

- name: Build + Push image (tag = git release tag)
- name: Build + Push image (tag = git tag)
env:
# `github.ref_name` == git tag triggered build
NEXUS_VERSION: ${{github.ref_name}}
run: |
docker buildx build \
--build-arg "NEXUS_VERSION=${NEXUS_VERSION}" \
--cache-from type=local,src=/tmp/buildx-cache \
--cache-to type=local,dest=/tmp/buildx-cache \
--label org.opencontainers.image.revision="${{github.sha}}" \
--label org.opencontainers.image.version="${NEXUS_VERSION}" \
--platform "linux/arm/v7,linux/arm64" \
--pull \
--tag "${{secrets.REGISTRY_USERNAME}}/nexus3:${GITHUB_REF#refs/tags/}" \
--tag "${{secrets.REGISTRY_USERNAME}}/nexus3:${NEXUS_VERSION}" \
--output "type=image,push=true" \
--file ./Dockerfile .
- name: Build + Push image ("latest")
env:
# `github.ref_name` == git tag triggered build
NEXUS_VERSION: ${{github.ref_name}}
run: |
docker buildx build \
--build-arg "NEXUS_VERSION=${NEXUS_VERSION}" \
--cache-from type=local,src=/tmp/buildx-cache \
--cache-to type=local,dest=/tmp/buildx-cache \
--label org.opencontainers.image.revision="${{github.sha}}" \
--label org.opencontainers.image.version="${NEXUS_VERSION}" \
--platform "linux/arm/v7,linux/arm64" \
--tag "${{secrets.REGISTRY_USERNAME}}/nexus3:latest" \
--output "type=image,push=true" \
--file ./Dockerfile .
create_release:
runs-on: ubuntu-latest
permissions:
contents: write
needs: build_deploy_to_registry
steps:
- name: Create Github Release
uses: ncipollo/[email protected]
with:
tag: ${{github.ref_name}}
name: ${{github.ref_name}}
body: (Automated release)
draft: false
prerelease: false
# Allow re-run workflow job
skipIfReleaseExists: true
22 changes: 22 additions & 0 deletions .github/workflows/get_nexus_version_latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Get Latest Nexus Version

on:
workflow_call:
outputs:
nexus_version:
description: Latest Nexus Version
value: ${{ jobs.get_latest_version.outputs.nexus_version }}

jobs:
get_latest_version:
runs-on: ubuntu-latest
outputs:
NEXUS_VERSION: ${{ steps.getversion.outputs.nexus_version }}
steps:
- id: getversion
name: Get Nexus Version
run: |
set -eu -o pipefail
NEXUS_VERSION="$(curl --silent 'https://raw.githubusercontent.com/sonatype/docker-nexus3/main/Dockerfile'|grep -Ei '^ARG NEXUS_VERSION'|cut --delimiter='=' --fields=2|tr --delete '[:space:]')"
echo "DEBUG: ${NEXUS_VERSION}"
echo "nexus_version=${NEXUS_VERSION}" >> "$GITHUB_OUTPUT"
16 changes: 12 additions & 4 deletions .github/workflows/github_cache_warmer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ on:
workflow_dispatch:

jobs:
get_latest_version:
uses: ./.github/workflows/get_nexus_version_latest.yml

build_image_to_cache:
runs-on: ubuntu-latest
needs: get_latest_version
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

# Setup docker cache to keep warm
- name: Setup Docker build cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: /tmp/buildx-cache
key: ${{runner.os}}-buildx-${{github.sha}}
Expand All @@ -28,21 +32,25 @@ jobs:
# Enable multi-architecture support on build node
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3
with:
version: latest

- name: Build to GitHub cache (keep it warm)
env:
NEXUS_VERSION: ${{needs.get_latest_version.outputs.nexus_version}}
run: |
docker buildx build \
--build-arg "NEXUS_VERSION=${NEXUS_VERSION}" \
--cache-from type=local,src=/tmp/buildx-cache \
--cache-to type=local,dest=/tmp/buildx-cache \
--label org.opencontainers.image.revision="${{github.sha}}" \
--label org.opencontainers.image.version="${NEXUS_VERSION}" \
--platform "linux/arm/v7,linux/arm64" \
--pull \
--output "type=image,push=false" \
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/validate_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,36 @@ on:
- Dockerfile

jobs:
get_latest_version:
uses: ./.github/workflows/get_nexus_version_latest.yml

# Verify image build success
build_image:
runs-on: ubuntu-latest
needs: get_latest_version
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

# Enable multi-architecture support on build node
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3
with:
version: latest

- name: Build image (no push)
env:
NEXUS_VERSION: ${{needs.get_latest_version.outputs.nexus_version}}
run: |
docker buildx build \
--build-arg "NEXUS_VERSION=${NEXUS_VERSION}" \
--label org.opencontainers.image.revision="${{github.sha}}" \
--label org.opencontainers.image.version="${NEXUS_VERSION}" \
--platform "linux/arm/v7,linux/arm64" \
--pull \
--output "type=image,push=false" \
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Download, extract Nexus to /tmp/sonatype/nexus
FROM eclipse-temurin:8-jre-jammy as downloader

ARG NEXUS_VERSION=3.43.0-01
ARG NEXUS_VERSION=${NEXUS_VERSION}
ARG NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/nexus-${NEXUS_VERSION}-unix.tar.gz

# Download Nexus and other stuff we need later
Expand All @@ -27,6 +27,7 @@ FROM eclipse-temurin:8-jre-jammy
# git commit
LABEL org.opencontainers.image.revision="-"
LABEL org.opencontainers.image.source="https://github.com/klo2k/nexus3-docker"
LABEL org.opencontainers.image.version="-"

# Setup: Rename App, Data and Work directory per official image
# App directory (/opt/sonatype/nexus)
Expand Down

0 comments on commit 281b7c0

Please sign in to comment.