Build Docker images for 5.4.110-nightly-20230908-0302 #381
This file contains 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 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 | |
dry_run: | |
description: 'Dry run' | |
required: false | |
type: string | |
default: '' | |
env: | |
IS_STABLE: ${{ ! contains(inputs.version, '-') }} | |
IS_NIGHTLY: ${{ contains(inputs.version, 'nightly') }} | |
DOCKER_USER: ${{ inputs.docker_user }} | |
DOCKER_REPO: '${{ inputs.docker_user }}/ravendb' | |
DRY_RUN: ${{ inputs.dry_run }} | |
jobs: | |
debPackage: | |
name: Build DEB package | |
strategy: | |
matrix: | |
arch: [ x64, arm32v7, arm64v8 ] | |
ubuntuName: [bionic, focal, jammy] | |
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@v3 | |
with: | |
path: current | |
- uses: actions/checkout@v3 | |
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 -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" | |
;; | |
"arm64v8") | |
tarName="RavenDB-${{ inputs.version }}-linux-arm64.tar.bz2" | |
;; | |
"x64") | |
tarName="RavenDB-${{ inputs.version }}-linux-x64.tar.bz2" | |
;; | |
*) | |
echo "Unsupported architecture" | |
exit 1 | |
;; | |
esac | |
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 | |
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@v3 | |
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() | |
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@v3 | |
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@v3 | |
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@v2 | |
- name: Set up Docker Build | |
uses: docker/setup-buildx-action@v2 | |
- 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 -P "../artifacts" "$downloadURL" | |
pwsh build-ubuntu.ps1 -Repo $DOCKER_REPO -Arch ${{ matrix.arch }} | |
working-directory: docker | |
- 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 | |
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 }} | |
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@v3 | |
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: Publish package | |
shell: pwsh | |
run: | | |
& .\publish-nanoserver.ps1 -Repo ${{ env.DOCKER_REPO }} -WinVer ${{ matrix.data.winVer }} | |
docker logout | |
working-directory: docker |