Temporarily hardcode versions #25
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
| name: "Build Container images" | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build-base: | |
| name: Build base images | |
| runs-on: | |
| - ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| container: [core, db, exporter, jobservice, log, nginx, portal, prepare, redis, registryctl, registry, trivy-adapter] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: 1.24.6 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: harbor.nirvati.org | |
| username: ${{ secrets.REGISTRY_USERNAME }} | |
| password: ${{ secrets.REGISTRY_PASSWORD }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: make/photon/${{ matrix.container }}/Dockerfile.base | |
| push: true | |
| tags: harbor.nirvati.org/registry/${{ matrix.container }}-base:latest | |
| build-main: | |
| name: Build main images | |
| runs-on: | |
| - ubuntu-24.04 | |
| needs: build-base | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - container: core | |
| build_binary: harbor_core | |
| - container: db | |
| - container: exporter | |
| - container: jobservice | |
| build_binary: harbor_jobservice | |
| - container: log | |
| - container: nginx | |
| - container: portal | |
| - container: prepare | |
| - container: redis | |
| - container: registryctl | |
| build_binary: harbor_registryctl | |
| run_build_script: registry | |
| - container: registry | |
| run_build_script: true | |
| - container: standalone-db-migrator | |
| build_binary: migrate | |
| src_name: migration | |
| - container: trivy-adapter | |
| run_build_script: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go 1.23 | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: 1.24.6 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: harbor.nirvati.org | |
| username: ${{ secrets.REGISTRY_USERNAME }} | |
| password: ${{ secrets.REGISTRY_PASSWORD }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Check out copy to subdirectory for go | |
| uses: actions/checkout@v4 | |
| if: ${{ matrix.container == 'core' }} | |
| with: | |
| path: src/github.com/goharbor/harbor | |
| - name: Prepare API files | |
| if: ${{ matrix.container == 'core' }} | |
| run: make gen_apis | |
| - name: Set up additional flags | |
| if: ${{ matrix.container == 'core' }} | |
| # TODO: Proper versioning | |
| run: echo "ADDITIONAL_GO_LDFLAGS=-X github.com/goharbor/harbor/src/lib/config.GitCommit=$(git rev-parse HEAD) -X github.com/goharbor/harbor/src/lib/config.ReleaseVersion=dev" >> $GITHUB_ENV | |
| - name: Build binary | |
| if: ${{ matrix.build_binary != '' }} | |
| run: | | |
| # If ADDITIONAL_GO_LDFLAGS is set, use it; otherwise, use the default | |
| if [ -n "${ADDITIONAL_GO_LDFLAGS}" ]; then | |
| docker run --rm -v .:/harbor -w /harbor/src/${{ matrix.src_name || matrix.container}} golang:1.24.6 /usr/local/go/bin/go build -buildvcs=false -o /harbor/make/photon/${{ matrix.container }}/${{matrix.build_binary}} -ldflags "${ADDITIONAL_GO_LDFLAGS}" | |
| else | |
| docker run --rm -v .:/harbor -w /harbor/src/${{ matrix.src_name || matrix.container}} golang:1.24.6 /usr/local/go/bin/go build -buildvcs=false -o /harbor/make/photon/${{ matrix.container }}/${{matrix.build_binary}} | |
| fi | |
| - name: Run custom build script | |
| if: ${{ matrix.run_build_script }} | |
| run: | | |
| ./make/photon/${{ matrix.run_build_script == true && matrix.container || matrix.run_build_script }}/builder.sh | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: make/photon/${{ matrix.container }}/Dockerfile | |
| push: true | |
| tags: harbor.nirvati.org/registry/${{ matrix.container }}:latest |