Repository navigation
feat: add Docker image support with Testcontainers integration #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Licensed to the Apache Software Foundation (ASF) under one or more | |
| # contributor license agreements. See the NOTICE file distributed with | |
| # this work for additional information regarding copyright ownership. | |
| # The ASF licenses this file to You under the Apache License, Version 2.0 | |
| # (the "License"); you may not use this file except in compliance with | |
| # the License. You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| name: "Docker Image" | |
| on: | |
| push: | |
| branches: [ "master" ] | |
| tags: [ "v*" ] | |
| # pull_request: | |
| # branches: [ "master" ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 130 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Use released Apache Directory dependencies | |
| run: | | |
| sed -i 's|<version>51-SNAPSHOT</version>|<version>51</version>|' pom.xml | |
| sed -i 's|<org.apache.directory.api.version>2.1.8-SNAPSHOT</org.apache.directory.api.version>|<org.apache.directory.api.version>2.1.8</org.apache.directory.api.version>|' pom.xml | |
| - name: Log in to GitHub Container Registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract image metadata | |
| id: image | |
| shell: bash | |
| run: | | |
| image_name="ghcr.io/${GITHUB_REPOSITORY,,}/apacheds" | |
| sha_tag="${GITHUB_SHA::8}" | |
| version="$(python3 -c "import xml.etree.ElementTree as ET; ns={'m':'http://maven.apache.org/POM/4.0.0'}; root=ET.parse('pom.xml').getroot(); version=root.find('m:version', ns); print(version.text.strip() if version is not None and version.text else '')")" | |
| if [ -z "${version}" ]; then | |
| echo "Could not find root project version in pom.xml" >&2 | |
| exit 1 | |
| fi | |
| echo "image_name=${image_name}" >> "${GITHUB_OUTPUT}" | |
| echo "sha_tag=${sha_tag}" >> "${GITHUB_OUTPUT}" | |
| echo "version=${version}" >> "${GITHUB_OUTPUT}" | |
| - name: Build Docker image with Maven | |
| run: > | |
| mvn -B -Pdocker -DskipTests | |
| -pl docker-image -am package | |
| -Dorg.apache.directory.api.version=2.1.8 | |
| -Dapacheds.docker.image=${{ steps.image.outputs.image_name }}:${{ steps.image.outputs.sha_tag }} | |
| - name: Publish Docker image to GHCR | |
| if: github.event_name != 'pull_request' | |
| run: > | |
| mvn -B -Pdocker -DskipTests | |
| -pl docker-image | |
| -Dorg.apache.directory.api.version=2.1.8 | |
| -Dapacheds.docker.image=${{ steps.image.outputs.image_name }}:${{ steps.image.outputs.sha_tag }} | |
| io.fabric8:docker-maven-plugin:0.45.1:push |