diff --git a/.github/workflows/build-base-image.yml b/.github/workflows/build-base-image.yml new file mode 100644 index 0000000..b852c31 --- /dev/null +++ b/.github/workflows/build-base-image.yml @@ -0,0 +1,80 @@ +# Apache License 2.0 + +name: Build Base Development Image + +on: + push: + branches: + - main + pull_request: + + +concurrency: + group: main-${{ github.ref }} + cancel-in-progress: true + +env: + PROJECT_NAME: open-space-toolkit-base + +jobs: + prepare-environment: + name: Prepare Environment Variables + runs-on: ubuntu-latest + outputs: + project_name: ${{ steps.project-name.outputs.value }} + project_version: ${{ steps.project-version.outputs.value }} + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + lfs: true + - id: project-name + name: Get Project Name + run: | + echo "Project name: ${{ env.PROJECT_NAME }}" + echo "value=${{ env.PROJECT_NAME }}" >> $GITHUB_OUTPUT + - id: project-version + name: Get Project Version + run: | + project_version=$(git describe --tags --always) + echo "Project version: ${project_version}" + echo "value=${project_version}" >> $GITHUB_OUTPUT + + build-base1-image: + name: Build Base1 Image + needs: + - prepare-environment + uses: ./.github/workflows/build-image.yml + with: + project_name: ${{ needs.prepare-environment.outputs.project_name }} + project_version: ${{ needs.prepare-environment.outputs.project_version }} + push: false + target: base1 + secrets: inherit + + build-base2-image: + name: Build Base2 Image + needs: + - prepare-environment + - build-base1-image + uses: ./.github/workflows/build-image.yml + with: + project_name: ${{ needs.prepare-environment.outputs.project_name }} + project_version: ${{ needs.prepare-environment.outputs.project_version }} + push: false + target: base2 + secrets: inherit + + build-base3-image: + name: Build Base3 Image + needs: + - prepare-environment + - build-base2-image + uses: ./.github/workflows/build-image.yml + with: + project_name: ${{ needs.prepare-environment.outputs.project_name }} + project_version: ${{ needs.prepare-environment.outputs.project_version }} + push: true + target: base3 + secrets: inherit diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 3e86645..1dd57d2 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -1,6 +1,6 @@ # Apache License 2.0 -name: Build Image +name: Build Development Image on: workflow_call: @@ -13,6 +13,16 @@ on: description: The version of the project. required: true type: string + push: + description: Push the image to the registry. + default: true + required: false + type: boolean + target: + description: The target to build. + default: root-user + required: false + type: string secrets: DOCKERHUB_USERNAME: required: true @@ -33,6 +43,8 @@ jobs: with: fetch-depth: 0 lfs: true + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Login to DockerHub @@ -51,5 +63,6 @@ jobs: VERSION=${{ inputs.project_version }} cache-from: type=gha cache-to: type=gha,mode=max - target: root-user - push: true + target: ${{ inputs.target }} + platforms: linux/amd64,linux/arm64 + push: ${{ inputs.push }} diff --git a/.github/workflows/build-packages.yml b/.github/workflows/build-packages.yml index e1d93b3..9409d2e 100644 --- a/.github/workflows/build-packages.yml +++ b/.github/workflows/build-packages.yml @@ -27,12 +27,20 @@ jobs: build-package-cpp: name: Build C++ Package runs-on: ubuntu-latest + strategy: + matrix: + architecture: [amd64, arm64] steps: - name: Checkout Repository uses: actions/checkout@v3 with: fetch-depth: 0 lfs: true + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + if: matrix.architecture == 'arm64' && github.event_name == 'push' && github.ref == 'refs/heads/main' + with: + platforms: arm64 - name: Login to DockerHub uses: docker/login-action@v2 with: @@ -41,7 +49,7 @@ jobs: - name: Pull Development Image run: docker pull ${{ env.DOCKER_REGISTRY_PATH }}/${{ inputs.project_name }}-development:${{ inputs.project_version }} - name: Build C++ Package - run: make build-packages-cpp-standalone + run: make build-packages-cpp-standalone PLATFORM=${{ matrix.architecture }} - name: Upload C++ Package uses: actions/upload-artifact@v3 with: @@ -51,12 +59,20 @@ jobs: build-package-python: name: Build Python Package runs-on: ubuntu-latest + strategy: + matrix: + architecture: [amd64, arm64] steps: - name: Checkout Repository uses: actions/checkout@v3 with: fetch-depth: 0 lfs: true + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + if: matrix.architecture == 'arm64' && github.event_name == 'push' && github.ref == 'refs/heads/main' + with: + platforms: arm64 - name: Login to DockerHub uses: docker/login-action@v2 with: @@ -65,7 +81,7 @@ jobs: - name: Pull Development Image run: docker pull ${{ env.DOCKER_REGISTRY_PATH }}/${{ inputs.project_name }}-development:${{ inputs.project_version }} - name: Build Python Package - run: make build-packages-python-standalone + run: make build-packages-python-standalone PLATFORM=${{ matrix.architecture }} - name: Upload Python Package uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 058bca5..703c75c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,7 +70,7 @@ jobs: with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} - packages_dir: packages/python/ + packages-dir: packages/python/ deploy-documentation: name: Deploy Documentation diff --git a/docker/development/Dockerfile b/docker/development/Dockerfile index c94eceb..cfe8248 100644 --- a/docker/development/Dockerfile +++ b/docker/development/Dockerfile @@ -1,6 +1,6 @@ # Apache License 2.0 -FROM ubuntu:20.04 +FROM ubuntu:20.04 as base1 LABEL maintainer="lucas.bremond@gmail.com" @@ -93,6 +93,7 @@ RUN mkdir -p /tmp/py39 \ && make altinstall \ && rm -rf /tmp/py39 +FROM base1 as base2 ## Python 3.10 ARG PYTHON_3_10_VERSION="3.10.9" @@ -119,6 +120,9 @@ RUN mkdir -p /tmp/py311 \ && make altinstall \ && rm -rf /tmp/py311 + +FROM base2 as base3 + ## Python tools RUN apt-get update -y \