Compare commits

...

24 Commits

Author SHA1 Message Date
Marko Barišić
b6d630f4c1 Merge branch 'master' into add-mgbuilder-workflow 2024-01-31 12:24:48 +01:00
Deda
f63cf18703 Fix run.sh build call 2023-12-18 19:00:36 +01:00
Marko Barišić
798c73f5de Merge branch 'master' into add-mgbuilder-workflow 2023-12-18 18:57:54 +01:00
Marko Barišić
5e24f9b0b4 Merge branch 'master' into add-mgbuilder-workflow 2023-11-23 10:35:57 +01:00
Marko Barišić
81c63e70d8 Merge branch 'master' into add-mgbuilder-workflow 2023-11-21 11:41:39 +01:00
Deda
90e0f620c4 Fix typo 2023-11-20 18:25:41 +01:00
Deda
84749b2f05 Add architecture argument to run.sh build calls 2023-11-20 18:20:47 +01:00
Deda
9b2cb3d4d8 Add architecture argument to build command 2023-11-20 18:20:12 +01:00
Deda
e46e3832d8 Modify input descriptions 2023-11-20 17:45:08 +01:00
Marko Barišić
647d62a886 Merge branch 'master' into add-mgbuilder-workflow 2023-11-20 17:31:08 +01:00
Deda
6504f04898 Polish workflow 2023-11-20 16:34:26 +01:00
Deda
bf9b95de70 Fix check for existing image 2023-11-20 16:15:18 +01:00
Deda
9f01e71c26 Add check for existing image 2023-11-20 15:51:32 +01:00
Deda
300f4d6163 Add password to unlock keychain 2023-11-20 14:41:43 +01:00
Deda
b7d143ccbe Add step to unlock keychain on macos self-hosted runner 2023-11-20 14:33:43 +01:00
Deda
1bf265dccd Modify run.sh to use single line docker build command 2023-11-20 14:14:11 +01:00
Deda
88c95f2949 Modify run.sh to use docker buildx 2023-11-20 14:03:48 +01:00
Deda
3791fe3585 Convert docker multiline command into singe line 2023-11-20 14:01:00 +01:00
Deda
84ab085183 Fix docker context typo 2023-11-20 13:58:30 +01:00
Deda
68d4884706 Fix multiline command typo 2023-11-20 13:55:44 +01:00
Deda
533d627a73 Fix run.sh argument positions 2023-11-20 13:52:51 +01:00
Deda
bfe61f0abb Run workflow for debian 11 amd64 and arm 2023-11-20 13:48:49 +01:00
Deda
adf2508f88 Add support for publishing builder images 2023-11-20 13:31:13 +01:00
Deda
b612e8a723 Add workflow for building and publishing memgraph/memgraph-builder docker images 2023-11-20 13:27:07 +01:00
2 changed files with 221 additions and 6 deletions

190
.github/workflows/release_mgbuilder.yml vendored Normal file
View File

@@ -0,0 +1,190 @@
name: Publish memgraph-builder docker images
on:
workflow_dispatch:
inputs:
toolchain_version:
type: choice
description: "Toolchain version for the builder"
options:
- v4
- v5
target_os:
type: choice
description: "Target OS for the builder"
default: 'debian-11'
options:
- all
- all-amd64
- all-arm
- amzn-2
- centos-7
- centos-9
- debian-10
- debian-11
- debian-11-arm
- fedora-36
- ubuntu-18_04
- ubuntu-20_04
- ubuntu-22_04
- ubuntu-22_04-arm
force_release:
type: boolean
description: "Overwrite existing image on dockerhub"
required: false
default: false
jobs:
amd_build:
if: ${{ !startsWith(github.event.inputs.target_os, 'all') && !endsWith(github.event.inputs.target_os, '-arm') }}
name: "Build and publish specific amd64 image"
runs-on: [self-hosted, DockerMgBuild, X64]
env:
DOCKER_ORG: "memgraph"
DOCKER_REPO: "memgraph-builder"
DOCKER_IMAGE_TAG: "${{ github.event.inputs.toolchain_version }}_${{ github.event.inputs.target_os }}"
ARCHITECTURE: "amd64"
steps:
- name: "Set up repository"
uses: actions/checkout@v3
with:
fetch-depth: 0 # Required because of release/get_version.py
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Check if specified image is already pushed
run: |
if [[ $FORCE_RELEASE = true ]]; then
EXISTS=1
else
EXISTS=$(docker manifest inspect $DOCKER_ORG/$DOCKER_REPO:$DOCKER_IMAGE_TAG > /dev/null; echo $?)
fi
if [[ $EXISTS -eq 0 ]]; then
echo "Image $DOCKER_ORG/$DOCKER_REPO:$DOCKER_IMAGE_TAG already exists, skipping next step ..."
fi
echo "EXISTS=$EXISTS" >> $GITHUB_ENV
- name: "Build and publish image"
if: env.EXISTS == 1
run: |
echo "Building and publishing $DOCKER_ORG/$DOCKER_REPO:$DOCKER_IMAGE_TAG"
./release/package/run.sh build ${{ github.event.inputs.toolchain_version }} ${{ github.event.inputs.target_os }} $ARCHITECTURE --publish
arm_build:
if: ${{ !startsWith(github.event.inputs.target_os, 'all') && endsWith(github.event.inputs.target_os, '-arm') }}
name: "Build and publish specific arm image"
runs-on: [self-hosted, DockerMgBuild, ARM64, strange]
env:
DOCKER_ORG: "memgraph"
DOCKER_REPO: "memgraph-builder"
DOCKER_IMAGE_TAG: "${{ github.event.inputs.toolchain_version }}_${{ github.event.inputs.target_os }}"
ARCHITECTURE: "arm64"
steps:
- name: "Set up repository"
uses: actions/checkout@v3
with:
fetch-depth: 0 # Required because of release/get_version.py
- name: "Unlock keychain for current session" # Required beacuse ARM builds run on macos
run: security -v unlock-keychain -p ${{ secrets.SELF_HOSTED_RUNNER_PASSWORD }} ~/Library/Keychains/login.keychain-db
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Check if specified image is already pushed
run: |
if [[ $FORCE_RELEASE = true ]]; then
EXISTS=1
else
EXISTS=$(docker manifest inspect $DOCKER_ORG/$DOCKER_REPO:$DOCKER_IMAGE_TAG > /dev/null; echo $?)
fi
if [[ $EXISTS -eq 0 ]]; then
echo "Image $DOCKER_ORG/$DOCKER_REPO:$DOCKER_IMAGE_TAG already exists, skipping next step ..."
fi
echo "EXISTS=$EXISTS" >> $GITHUB_ENV
- name: "Build and publish image"
if: env.EXISTS == 1
run: |
echo "Building and publishing $DOCKER_ORG/$DOCKER_REPO:$DOCKER_IMAGE_TAG"
./release/package/run.sh build ${{ github.event.inputs.toolchain_version }} ${{ github.event.inputs.target_os }} $ARCHITECTURE --publish
all_amd_build:
if: ${{ github.event.inputs.target_os == 'all-amd64' || github.event.inputs.target_os == 'all'}}
name: "Build and publish all amd64 images"
runs-on: [self-hosted, DockerMgBuild, X64]
strategy:
matrix:
target_os: [amzn-2, centos-7, centos-9, debian-10, debian-11, fedora-36, ubuntu-18_04, ubuntu-20_04, ubuntu-22_04]
env:
DOCKER_ORG: "memgraph"
DOCKER_REPO: "memgraph-builder"
DOCKER_IMAGE_TAG: "${{ github.event.inputs.toolchain_version }}_${{ github.event.inputs.target_os }}"
ARCHITECTURE: "amd64"
steps:
- name: "Set up repository"
uses: actions/checkout@v3
with:
fetch-depth: 0 # Required because of release/get_version.py
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Check if specified image is already pushed
run: |
if [[ $FORCE_RELEASE = true ]]; then
EXISTS=1
else
EXISTS=$(docker manifest inspect $DOCKER_ORG/$DOCKER_REPO:$DOCKER_IMAGE_TAG > /dev/null; echo $?)
fi
if [[ $EXISTS -eq 0 ]]; then
echo "Image $DOCKER_ORG/$DOCKER_REPO:$DOCKER_IMAGE_TAG already exists, skipping next step ..."
fi
echo "EXISTS=$EXISTS" >> $GITHUB_ENV
- name: "Build and publish image"
if: env.EXISTS == 1
run: |
echo "Building and publishing $DOCKER_ORG/$DOCKER_REPO:$DOCKER_IMAGE_TAG"
./release/package/run.sh build ${{ github.event.inputs.toolchain_version }} ${{ github.event.inputs.target_os }} $ARCHITECTURE --publish
all_arm_build:
if: ${{ github.event.inputs.target_os == 'all-arm' || github.event.inputs.target_os == 'all'}}
name: "Build and publish all arm images"
runs-on: [self-hosted, DockerMgBuild, ARM64, strange]
strategy:
matrix:
target_os: [debian-11-arm, ubuntu-22_04-arm]
env:
DOCKER_ORG: "memgraph"
DOCKER_REPO: "memgraph-builder"
DOCKER_IMAGE_TAG: "${{ github.event.inputs.toolchain_version }}_${{ github.event.inputs.target_os }}"
ARCHITECTURE: "arm64"
steps:
- name: "Set up repository"
uses: actions/checkout@v3
with:
fetch-depth: 0 # Required because of release/get_version.py
- name: "Unlock keychain for current session" # Required beacuse ARM builds run on macos
run: security -v unlock-keychain -p ${{ secrets.SELF_HOSTED_RUNNER_PASSWORD }} ~/Library/Keychains/login.keychain-db
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Check if specified image is already pushed
run: |
if [[ $FORCE_RELEASE = true ]]; then
EXISTS=1
else
EXISTS=$(docker manifest inspect $DOCKER_ORG/$DOCKER_REPO:$DOCKER_IMAGE_TAG > /dev/null; echo $?)
fi
if [[ $EXISTS -eq 0 ]]; then
echo "Image $DOCKER_ORG/$DOCKER_REPO:$DOCKER_IMAGE_TAG already exists, skipping next step ..."
fi
echo "EXISTS=$EXISTS" >> $GITHUB_ENV
- name: "Build and publish image"
if: env.EXISTS == 1
run: |
echo "Building and publishing $DOCKER_ORG/$DOCKER_REPO:$DOCKER_IMAGE_TAG"
./release/package/run.sh build ${{ github.event.inputs.toolchain_version }} ${{ github.event.inputs.target_os }} $ARCHITECTURE --publish

View File

@@ -10,15 +10,21 @@ SUPPORTED_OS=(
fedora-36
amzn-2
)
SUPPORTED_TOOLCAHINS=(
v4
v5
)
SUPPORTED_BUILD_TYPES=(
Debug
Release
RelWithDebInfo
)
SUPPORTED_ARCHITECTURES=(
amd64
arm64
)
PROJECT_ROOT="$SCRIPT_DIR/../.."
TOOLCHAIN_VERSION="toolchain-v4"
TOOLCHAIN_VERSION="${TOOLCHAIN_VERSION:-toolchain-v4}"
ACTIVATE_TOOLCHAIN="source /opt/${TOOLCHAIN_VERSION}/activate"
HOST_OUTPUT_DIR="$PROJECT_ROOT/build/output"
@@ -30,6 +36,14 @@ print_help () {
echo " Build types: ${SUPPORTED_BUILD_TYPES[*]}"
exit 1
}
print_help_build () {
echo "$0 build {toolchain_version} {os} {architecture} [--publish]"
echo ""
echo " Toolchain versions: ${SUPPORTED_TOOLCAHINS[*]}"
echo " OSs: ${SUPPORTED_OS[*]}"
echo " Architectures: ${SUPPORTED_ARCHITECTURES[*]}"
exit 1
}
make_package () {
os="$1"
@@ -187,15 +201,26 @@ case "$1" in
build)
shift 1
if [[ "$#" -ne 2 ]]; then
print_help
if [[ "$#" -lt 3 || "$#" -gt 4 ]]; then
print_help_build
fi
# in the vX format, e.g. v5
toolchain_version="$1"
# a name of the os folder, e.g. ubuntu-22.04-arm
os="$2"
cd "$SCRIPT_DIR/$os"
docker build -f Dockerfile --build-arg TOOLCHAIN_VERSION="toolchain-$toolchain_version" -t "memgraph/memgraph-builder:${toolchain_version}_$os" .
# architecture for which the image will be built, e.g. linux/arm64
architecture="$3"
if [[ "$#" -eq 4 ]]; then
if [[ "$4" == "--publish" ]]; then
docker buildx build --file Dockerfile --build-arg TOOLCHAIN_VERSION="toolchain-$toolchain_version" --platform "linux/$architecture" --tag "memgraph/memgraph-builder:${toolchain_version}_$os" --push .
else
print_help_build
exit
fi
else
docker buildx build --file Dockerfile --build-arg TOOLCHAIN_VERSION="toolchain-$toolchain_version" --platform "linux/$architecture" --tag "memgraph/memgraph-builder:${toolchain_version}_$os" .
fi
;;
test)