Skip to content

Build Docker images for 7.0.0-nightly-20241122-0446 #1070

Build Docker images for 7.0.0-nightly-20241122-0446

Build Docker images for 7.0.0-nightly-20241122-0446 #1070

Workflow file for this run

name: Build Docker images
run-name: Build Docker images for ${{ inputs.version }}
on:
workflow_dispatch:
inputs:
version:
description: 'RavenDB Version'
required: true
type: string
docker_user:
description: 'DockerHub username'
required: false
type: string
default: ravendb
github_repository:
description: 'Github repository'
required: false
type: string
default: ravendb/ravendb
docker_repository:
description: 'Docker repository'
required: false
type: string
default: ravendb/ravendb
deb_only:
description: 'Build deb packages only'
required: false
type: boolean
default: false
dry_run:
description: 'Dry run'
required: false
type: string
default: ''
exit_on_cves:
description: 'Stop pipeline when cves are found'
required: true
type: boolean
default: true
env:
IS_STABLE: ${{ ! contains(inputs.version, '-') }}
IS_NIGHTLY: ${{ contains(inputs.version, 'nightly') }}
DOCKER_USER: ${{ inputs.docker_user }}
DOCKER_REPO: ${{ inputs.docker_repository }}
DRY_RUN: ${{ inputs.dry_run }}
jobs:
debPackage:
name: Build DEB package
strategy:
matrix:
arch: [ x64, arm32v7, arm64v8 ]
ubuntuName: [focal, jammy, noble ]
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Get ravendb majorminor version, build type & set repo
run: |
v=$(echo ${{ inputs.version }} | cut -d. -f1,2)
echo "RAVEN_MAJOR_MINOR=$v" >> $GITHUB_ENV
[[ ${{ env.IS_NIGHTLY }} == true ]] && DOCKER_REPO="$DOCKER_REPO-nightly"
echo "DOCKER_REPO=$DOCKER_REPO" >> $GITHUB_ENV
buildType=$(echo ${{ inputs.version }} | cut -d- -f2)
echo "TRIGGERING_BUILD_TYPE=$buildType" >> $GITHUB_ENV
echo "Docker repository: $DOCKER_REPO; TRIGGERING_BUILD_TYPE: $buildType"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- uses: actions/checkout@v4
with:
path: current
- uses: actions/checkout@v4
with:
repository: '${{ inputs.github_repository }}'
ref: "v${{ env.RAVEN_MAJOR_MINOR }}"
path: ravendb
- name: Download tar package
run: |
case "${{ matrix.arch }}" in
"arm32v7")
downloadURL="https://daily-builds.s3.amazonaws.com/RavenDB-${{ inputs.version }}-raspberry-pi.tar.bz2"
;;
"arm64v8")
downloadURL="https://daily-builds.s3.amazonaws.com/RavenDB-${{ inputs.version }}-linux-arm64.tar.bz2"
;;
"x64")
downloadURL="https://daily-builds.s3.amazonaws.com/RavenDB-${{ inputs.version }}-linux-x64.tar.bz2"
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac
wget -q -P "temp" "$downloadURL"
working-directory: ravendb/scripts/linux/pkg/deb
- name: Extract build number
run: |
case "${{ matrix.arch }}" in
"arm32v7")
tarName="RavenDB-${{ inputs.version }}-raspberry-pi.tar.bz2"
qemu="qemu-arm"
arch="armhf"
;;
"arm64v8")
tarName="RavenDB-${{ inputs.version }}-linux-arm64.tar.bz2"
qemu="qemu-aarch64"
arch="arm64"
;;
"x64")
tarName="RavenDB-${{ inputs.version }}-linux-x64.tar.bz2"
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac
version=$(echo ${{ inputs.version }} | cut -d. -f1,2)
if [[ "$version" > "6.0" ]]; then
filePath="RavenDB/Server/Raven.Server"
tar -xvf $tarName $filePath
if [[ -z $qemu ]]; then
number=$(./$filePath --info | grep "Build" | cut -d" " -f2)
else
source ../set-ubuntu-${{ matrix.ubuntuName }}.sh
source ../set-raven-platform-${arch}.sh
export DEB_BUILD_ENV_IMAGE="ravendb-server-info-extractor_$DEB_ARCHITECTURE"
docker pull --platform $DOCKER_BUILDPLATFORM ubuntu:$DISTRO_VERSION
docker build \
--platform $DOCKER_BUILDPLATFORM \
--build-arg "DISTRO_VERSION=$DISTRO_VERSION" \
--build-arg "QEMU_ARCH=$QEMU_ARCH" \
-t $DEB_BUILD_ENV_IMAGE \
-f ../../../../../../current/Dockerfile .
docker run --rm \
--platform $DOCKER_BUILDPLATFORM \
-v "$(pwd):/output" \
$DEB_BUILD_ENV_IMAGE
number=$(grep "Build" info.txt | cut -d" " -f2)
fi
echo "BUILD_NUMBER=$number" >> $GITHUB_ENV
else
filePath="RavenDB/Server/Raven.Server.dll"
tar -xvf $tarName $filePath
sudo apt install -y libimage-exiftool-perl
number=$(exiftool $filePath | grep 'File Version Number' | cut -d. -f 4)
echo "BUILD_NUMBER=$number" >> $GITHUB_ENV
echo "BUILD_NUMBER: $BUILD_NUMBER"
fi
working-directory: ravendb/scripts/linux/pkg/deb/temp
- name: Build deb package
run: |
chmod a+x *.sh
case "${{ matrix.arch }}" in
"arm32v7")
arch="armhf"
;;
"arm64v8")
arch="arm64"
;;
"x64")
arch="amd64"
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac
source ./set-ubuntu-${{ matrix.ubuntuName }}.sh
source ./set-raven-platform-${arch}.sh
./build-deb.sh
echo "DEB_ARCH=$arch" >> $GITHUB_ENV
echo "UBUNTU_VERSION=$DISTRO_VERSION" >> $GITHUB_ENV
working-directory: ravendb/scripts/linux/pkg/deb
env:
RAVENDB_VERSION: ${{ inputs.version }}
- name: Upload deb package to artifacts
uses: actions/upload-artifact@v4
with:
name: package-${{ matrix.ubuntuName }}-${{ matrix.arch }}
path: ravendb/scripts/linux/pkg/deb/dist/${{ env.UBUNTU_VERSION }}/ravendb*.deb
- name: Upload deb package to s3
run: |
set -e
set -x
case "${{ matrix.arch }}" in
"arm32v7")
arch="arm32"
;;
"arm64v8")
arch="arm64"
;;
"x64")
arch="x64"
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac
PACKAGES_DIST_DIR=ravendb/scripts/linux/pkg/deb/dist
if [ "${{ env.IS_NIGHTLY }}" == "true" ]; then
NIGHTLY_VERSION_DATE_PART=$(echo ${{ inputs.version }} | cut -d- -f3,4)
export BUILD_VERSION="$NIGHTLY_VERSION_DATE_PART-Nightly"
elif [ "${{ env.IS_STABLE }}" == "true" ]; then
export BUILD_VERSION="${{ env.BUILD_NUMBER }}"
else
export BUILD_VERSION="${{ env.BUILD_NUMBER }}-${{ env.TRIGGERING_BUILD_TYPE }}"
fi
export COMMENT="RavenDB_${RAVENDB_VERSION}_DEB"
export S3UPLOADER="./current/s3uploader.sh"
"$S3UPLOADER" \
--category "RavenDB for Ubuntu ${{ env.UBUNTU_VERSION }} ${arch} DEB" \
--filename "${PACKAGES_DIST_DIR}/${{ env.UBUNTU_VERSION }}/ravendb_${RAVENDB_VERSION}-0_ubuntu.${{ env.UBUNTU_VERSION }}_${{ env.DEB_ARCH }}.deb"
env:
RAVENDB_VERSION: ${{ inputs.version }}
BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
SECRET_PASS: ${{ secrets.SECRET_PASS }}
linux:
name: Build Linux Docker image
strategy:
matrix:
arch: [ x64, arm32v7, arm64v8 ]
fail-fast: false
runs-on: ubuntu-latest
needs: debPackage
if: always() && inputs.deb_only == false
steps:
- name: Get ravendb majorminor version & set repo
run: |
v=$(echo ${{ inputs.version }} | cut -d. -f1,2)
echo "RAVEN_MAJOR_MINOR=$v" >> $GITHUB_ENV
[[ ${{ env.IS_NIGHTLY }} == true ]] && DOCKER_REPO="$DOCKER_REPO-nightly"
echo "DOCKER_REPO=$DOCKER_REPO" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
repository: '${{ inputs.github_repository }}'
ref: "v${{ env.RAVEN_MAJOR_MINOR }}"
- name: Get docker system
run: |
dockerSystem=$(grep -o -P "(?<=FROM\smcr\.microsoft\.com\/dotnet\/runtime-deps:\d\.\d-)([a-zA-Z]+)(?=.*)" Dockerfile.${{ matrix.arch }})
echo "DOCKER_SYSTEM=$dockerSystem" >> $GITHUB_ENV
working-directory: docker/ravendb-ubuntu
- uses: actions/download-artifact@v4
with:
name: package-${{ env.DOCKER_SYSTEM }}-${{ matrix.arch }}
path: downloads
- name: Move deb to correct folder
run: |
chmod -v a+rw ravendb*.deb
mv -v ravendb*.deb ../docker/ravendb-ubuntu/
working-directory: downloads
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Build
uses: docker/setup-buildx-action@v3
- name: Login to docker
run: |
docker login -u ${{ env.DOCKER_USER }} -p ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build image
run: |
case "${{ matrix.arch }}" in
"arm32v7")
downloadURL="https://daily-builds.s3.amazonaws.com/RavenDB-${{ inputs.version }}-raspberry-pi.tar.bz2"
;;
"arm64v8")
downloadURL="https://daily-builds.s3.amazonaws.com/RavenDB-${{ inputs.version }}-linux-arm64.tar.bz2"
;;
"x64")
downloadURL="https://daily-builds.s3.amazonaws.com/RavenDB-${{ inputs.version }}-linux-x64.tar.bz2"
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac
wget -q -P "../artifacts" "$downloadURL"
pwsh build-ubuntu.ps1 -Repo $DOCKER_REPO -Arch ${{ matrix.arch }}
working-directory: docker
- name: Docker Scout
uses: docker/scout-action@v1
with:
command: cves
exit-code: ${{ inputs.exit_on_cves }}
only-severities: critical
- name: Publish package
run: |
pwsh publish-ubuntu.ps1 -Repo $DOCKER_REPO -Arch ${{ matrix.arch }}
docker logout
working-directory: docker
windowsDockerImageBuilder:
name: Matrix Creator for Windows
runs-on: ubuntu-latest
if: inputs.deb_only == false
outputs:
matrix: ${{ steps.create.outputs.matrix }}
steps:
- name: Create Matrix
id: create
run: |
v=$(echo ${{ inputs.version }} | cut -d. -f1,2)
if [[ "$v" < "5.4" ]]; then
echo "matrix=[ { \"os\": \"2019\", \"winVer\": \"1809\"} ]" >> "$GITHUB_OUTPUT"
else
echo "matrix=[ { \"os\": \"2019\", \"winVer\": \"1809\"}, { \"os\": \"2022\", \"winVer\": \"ltsc2022\"} ]" >> "$GITHUB_OUTPUT"
fi
windows:
needs: windowsDockerImageBuilder
name: Build Windows Docker images
strategy:
matrix:
data: ${{ fromJson(needs.windowsDockerImageBuilder.outputs.matrix) }}
fail-fast: false
runs-on: windows-${{ matrix.data.os }}
if: inputs.deb_only == false
steps:
- name: Get ravendb majorminor version & set repo
shell: bash
run: |
v=$(echo ${{ inputs.version }} | cut -d. -f1,2)
echo "RAVEN_MAJOR_MINOR=$v" >> $GITHUB_ENV
[[ ${{ env.IS_NIGHTLY }} == true ]] && DOCKER_REPO="$DOCKER_REPO-nightly"
echo "DOCKER_REPO=$DOCKER_REPO" >> $GITHUB_ENV
- name: Login to docker
shell: pwsh
run: |
docker login -u ${{ env.DOCKER_USER }} -p ${{ secrets.DOCKER_HUB_PASSWORD }}
- uses: actions/checkout@v4
with:
repository: '${{ inputs.github_repository }}'
ref: "v${{ env.RAVEN_MAJOR_MINOR }}"
- name: Download package
shell: pwsh
run: |
$downloadURL="https://daily-builds.s3.amazonaws.com/RavenDB-${{ inputs.version }}-windows-x64.zip"
mkdir artifacts
Invoke-WebRequest -Uri "$downloadURL" -OutFile "artifacts\RavenDB-${{ inputs.version }}-windows-x64.zip"
- name: Build image
shell: pwsh
run: |
& .\build-nanoserver.ps1 -Repo ${{ env.DOCKER_REPO }} -WinVer ${{ matrix.data.winVer }}
working-directory: docker
- name: Docker Scout
uses: docker/scout-action@v1
with:
command: cves
exit-code: ${{ inputs.exit_on_cves }}
only-severities: critical
- name: Publish package
shell: pwsh
run: |
& .\publish-nanoserver.ps1 -Repo ${{ env.DOCKER_REPO }} -WinVer ${{ matrix.data.winVer }}
docker logout
working-directory: docker
multiarch:
needs: [linux, windows]
name: Create docker multiarch manifest
runs-on: ubuntu-latest
if: inputs.deb_only == false
steps:
- name: Get ravendb majorminor version & set repo
shell: bash
run: |
v=$(echo ${{ inputs.version }} | cut -d. -f1,2)
echo "RAVEN_MAJOR_MINOR=$v" >> $GITHUB_ENV
[[ ${{ env.IS_NIGHTLY }} == true ]] && DOCKER_REPO="$DOCKER_REPO-nightly"
echo "DOCKER_REPO=$DOCKER_REPO" >> $GITHUB_ENV
- name: Login to docker
shell: pwsh
run: |
docker login -u ${{ env.DOCKER_USER }} -p ${{ secrets.DOCKER_HUB_PASSWORD }}
- uses: actions/checkout@v4
with:
repository: '${{ inputs.github_repository }}'
ref: "v${{ env.RAVEN_MAJOR_MINOR }}"
- name: Publish multiarch
shell: pwsh
run: |
& .\publish-multiarch.ps1 -Repo ${{ env.DOCKER_REPO }}
docker logout
working-directory: docker