From e5e2c4b36c1b1235a58553319ba50663bbe3d7d6 Mon Sep 17 00:00:00 2001 From: David Boike Date: Tue, 4 Jun 2024 11:25:43 -0500 Subject: [PATCH 1/6] Build database containers --- .github/workflows/release.yml | 40 +++++++++++++++++++++++++++ src/ServiceControl.RavenDB/Dockerfile | 15 ++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/ServiceControl.RavenDB/Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 76f4a36c36..9d0909c3ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -175,3 +175,43 @@ jobs: run: | docker buildx build --push --tag ghcr.io/particular/${{ matrix.name }}:${{ env.TAG_NAME }} --file src/${{ matrix.project }}/Dockerfile --build-arg VERSION=${{ env.MinVerVersion }} --platform linux/arm64,linux/arm,linux/amd64 . docker buildx imagetools inspect ghcr.io/particular/${{ matrix.name }}:${{ env.TAG_NAME }} + db-containers: + if: ${{ github.actor != 'dependabot[bot]' }} + runs-on: ubuntu-22.04 + name: db-container-${{ matrix.tag }} + defaults: + run: + shell: bash + strategy: + matrix: + include: + - arch: amd64 + tag: x64 + - arch: arm64/v8 + tag: arm64v8 + - arch: arm/v7 + tag: arm32v7 + fail-fast: false + steps: + - name: Check for secrets + env: + SECRETS_AVAILABLE: ${{ secrets.SECRETS_AVAILABLE }} + shell: pwsh + run: exit $(If ($env:SECRETS_AVAILABLE -eq 'true') { 0 } Else { 1 }) + - name: Checkout + uses: actions/checkout@v4.1.6 + with: + fetch-depth: 0 + - name: Install MinVer CLI + run: dotnet tool install --global minver-cli + - name: Determine versions + run: echo "MinVerVersion=$(minver)" >> $GITHUB_ENV + - name: Log in to GitHub container registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + - name: Build & inspect image + env: + TAG_NAME: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || env.MinVerVersion }} + run: | + BASETAG=5.4.118-ubuntu.22.04-${{ matrix.tag }} + docker build -t servicecontrol-ravendb:${{ env.MinVerVersion }}-${{ matrix.tag}} --file src/ServiceControl.RavenDB/Dockerfile --build-arg VERSION=${{ env.MinVerVersion }} --build-arg BASETAG=$BASETAG --platform linux/${{ matrix.arch }} . + docker images diff --git a/src/ServiceControl.RavenDB/Dockerfile b/src/ServiceControl.RavenDB/Dockerfile new file mode 100644 index 0000000000..7e77835a87 --- /dev/null +++ b/src/ServiceControl.RavenDB/Dockerfile @@ -0,0 +1,15 @@ +ARG BASETAG +ARG VERSION +FROM ravendb/ravendb:$BASETAG AS ravendb + +COPY src/ServiceControl.Persistence.RavenDB/RavenLicense.json /opt/RavenDB/servicecontrol-license.json + +ENV RAVEN_ARGS='--Setup.Mode=None --License.Eula.Accepted=true --License.Path=/opt/RavenDB/servicecontrol-license.json' + +LABEL org.opencontainers.image.source=https://github.com/Particular/ServiceControl \ + org.opencontainers.image.authors="Particular Software" \ + org.opencontainers.image.url=https://docs.particular.net/servicecontrol/ \ + org.opencontainers.image.documentation=https://docs.particular.net/servicecontrol/ \ + org.opencontainers.image.version=$VERSION \ + org.opencontainers.image.title=ServiceControl.RavenDB \ + org.opencontainers.image.description="ServiceControl database storage using RavenDB" \ No newline at end of file From 48bc292b984821d0e8e8f0988369f91605ff4cd2 Mon Sep 17 00:00:00 2001 From: David Boike Date: Tue, 4 Jun 2024 12:04:07 -0500 Subject: [PATCH 2/6] No matrix --- .github/workflows/release.yml | 27 ++++++++++------------ src/ServiceControl.RavenDB/containers.json | 14 +++++++++++ 2 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 src/ServiceControl.RavenDB/containers.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9d0909c3ad..9232e3b206 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -178,20 +178,10 @@ jobs: db-containers: if: ${{ github.actor != 'dependabot[bot]' }} runs-on: ubuntu-22.04 - name: db-container-${{ matrix.tag }} + name: db-containers defaults: run: shell: bash - strategy: - matrix: - include: - - arch: amd64 - tag: x64 - - arch: arm64/v8 - tag: arm64v8 - - arch: arm/v7 - tag: arm32v7 - fail-fast: false steps: - name: Check for secrets env: @@ -208,10 +198,17 @@ jobs: run: echo "MinVerVersion=$(minver)" >> $GITHUB_ENV - name: Log in to GitHub container registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - name: Build & inspect image + - name: Build images env: TAG_NAME: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || env.MinVerVersion }} + shell: pwsh run: | - BASETAG=5.4.118-ubuntu.22.04-${{ matrix.tag }} - docker build -t servicecontrol-ravendb:${{ env.MinVerVersion }}-${{ matrix.tag}} --file src/ServiceControl.RavenDB/Dockerfile --build-arg VERSION=${{ env.MinVerVersion }} --build-arg BASETAG=$BASETAG --platform linux/${{ matrix.arch }} . - docker images + $containers = cat src/ServiceControl.RavenDB/containers.json | ConvertFrom-Json + $containers | ForEach-Object -Process { + $FULLTAG="${{ env.MinVerVersion }}-$($_.tag)" + $BASETAG="5.4.118-ubuntu.22.04-$($_.tag)" + echo "Building ${{ env.MinVerVersion }}-$($_.tag) for architecture $($_.arch) from $BASETAG" + docker build -t servicecontrol-ravendb:$FULLTAG --file src/ServiceControl.RavenDB/Dockerfile --build-arg VERSION=${{ env.MinVerVersion }} --build-arg BASETAG=$BASETAG --platform linux/$($_.arch) . + } + - name: List local images + run: docker images diff --git a/src/ServiceControl.RavenDB/containers.json b/src/ServiceControl.RavenDB/containers.json new file mode 100644 index 0000000000..ddacc822ba --- /dev/null +++ b/src/ServiceControl.RavenDB/containers.json @@ -0,0 +1,14 @@ +[ + { + "arch": "amd64", + "tag": "x64" + }, + { + "arch": "arm64/v8", + "tag": "arm64v8" + }, + { + "arch": "arm/v7", + "tag": "arm32v7" + } +] \ No newline at end of file From e4241520d280b99079f81f4465cc5114254f939f Mon Sep 17 00:00:00 2001 From: David Boike Date: Tue, 4 Jun 2024 12:19:30 -0500 Subject: [PATCH 3/6] Push images --- .github/workflows/release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9232e3b206..a550eaf00e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -208,7 +208,9 @@ jobs: $FULLTAG="${{ env.MinVerVersion }}-$($_.tag)" $BASETAG="5.4.118-ubuntu.22.04-$($_.tag)" echo "Building ${{ env.MinVerVersion }}-$($_.tag) for architecture $($_.arch) from $BASETAG" - docker build -t servicecontrol-ravendb:$FULLTAG --file src/ServiceControl.RavenDB/Dockerfile --build-arg VERSION=${{ env.MinVerVersion }} --build-arg BASETAG=$BASETAG --platform linux/$($_.arch) . + docker build -t ghcr.io/particular/servicecontrol-ravendb:$FULLTAG --file src/ServiceControl.RavenDB/Dockerfile --build-arg VERSION=${{ env.MinVerVersion }} --build-arg BASETAG=$BASETAG --platform linux/$($_.arch) . } - name: List local images run: docker images + - name: Push images to GitHub Container registry + run: docker image push --all-tags ghcr.io/particular/servicecontrol-ravendb From c22ec4b8cd4f8a5dd09a404664070dc59501cb67 Mon Sep 17 00:00:00 2001 From: David Boike Date: Tue, 4 Jun 2024 12:24:52 -0500 Subject: [PATCH 4/6] Fix for PR-based tag name --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a550eaf00e..46e705e94d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -205,9 +205,9 @@ jobs: run: | $containers = cat src/ServiceControl.RavenDB/containers.json | ConvertFrom-Json $containers | ForEach-Object -Process { - $FULLTAG="${{ env.MinVerVersion }}-$($_.tag)" + $FULLTAG="${{ env.TAG_NAME }}-$($_.tag)" $BASETAG="5.4.118-ubuntu.22.04-$($_.tag)" - echo "Building ${{ env.MinVerVersion }}-$($_.tag) for architecture $($_.arch) from $BASETAG" + echo "Building $FULLTAG for architecture $($_.arch) from $BASETAG" docker build -t ghcr.io/particular/servicecontrol-ravendb:$FULLTAG --file src/ServiceControl.RavenDB/Dockerfile --build-arg VERSION=${{ env.MinVerVersion }} --build-arg BASETAG=$BASETAG --platform linux/$($_.arch) . } - name: List local images From 7472efe02d7d8a099892c6afc03fa1fc2985b284 Mon Sep 17 00:00:00 2001 From: David Boike Date: Tue, 4 Jun 2024 12:39:03 -0500 Subject: [PATCH 5/6] Determine RavenDB server version from Directory.Packages.props file --- .github/workflows/release.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 46e705e94d..89b4c0624b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -203,12 +203,20 @@ jobs: TAG_NAME: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || env.MinVerVersion }} shell: pwsh run: | + Write-Output "Determining RavenDB version from Directory.Packages.props file" + [xml]$packagesFile = Get-Content src/Directory.Packages.props + $RavenVersion = $packagesFile.selectNodes("//Project/ItemGroup/PackageVersion[@Include='RavenDB.Embedded']").Version + + if (-not $RavenVersion) { throw "Unable to determine RavenDB server version from Directory.Packages.props" } + + Write-Output "Determining container variants to build" $containers = cat src/ServiceControl.RavenDB/containers.json | ConvertFrom-Json $containers | ForEach-Object -Process { $FULLTAG="${{ env.TAG_NAME }}-$($_.tag)" - $BASETAG="5.4.118-ubuntu.22.04-$($_.tag)" - echo "Building $FULLTAG for architecture $($_.arch) from $BASETAG" + $BASETAG="$($RavenVersion)-ubuntu.22.04-$($_.tag)" + Write-Output "::group::Building $FULLTAG for architecture $($_.arch) from $BASETAG" docker build -t ghcr.io/particular/servicecontrol-ravendb:$FULLTAG --file src/ServiceControl.RavenDB/Dockerfile --build-arg VERSION=${{ env.MinVerVersion }} --build-arg BASETAG=$BASETAG --platform linux/$($_.arch) . + Write-Output "::endgroup::" } - name: List local images run: docker images From 4a555b03933063b5f92dffb3c11117e144838263 Mon Sep 17 00:00:00 2001 From: David Boike Date: Mon, 10 Jun 2024 11:25:43 -0500 Subject: [PATCH 6/6] Don't skip setup --- src/ServiceControl.RavenDB/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ServiceControl.RavenDB/Dockerfile b/src/ServiceControl.RavenDB/Dockerfile index 7e77835a87..08ca5377cd 100644 --- a/src/ServiceControl.RavenDB/Dockerfile +++ b/src/ServiceControl.RavenDB/Dockerfile @@ -4,7 +4,7 @@ FROM ravendb/ravendb:$BASETAG AS ravendb COPY src/ServiceControl.Persistence.RavenDB/RavenLicense.json /opt/RavenDB/servicecontrol-license.json -ENV RAVEN_ARGS='--Setup.Mode=None --License.Eula.Accepted=true --License.Path=/opt/RavenDB/servicecontrol-license.json' +ENV RAVEN_ARGS='--License.Eula.Accepted=true --License.Path=/opt/RavenDB/servicecontrol-license.json' LABEL org.opencontainers.image.source=https://github.com/Particular/ServiceControl \ org.opencontainers.image.authors="Particular Software" \ @@ -12,4 +12,4 @@ LABEL org.opencontainers.image.source=https://github.com/Particular/ServiceContr org.opencontainers.image.documentation=https://docs.particular.net/servicecontrol/ \ org.opencontainers.image.version=$VERSION \ org.opencontainers.image.title=ServiceControl.RavenDB \ - org.opencontainers.image.description="ServiceControl database storage using RavenDB" \ No newline at end of file + org.opencontainers.image.description="ServiceControl database storage using RavenDB"