1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-17 18:32:35 +00:00

Merge branch '890-publish-official-arm-images' into 'develop'

Resolve "Publish official arm images"

Closes 

See merge request 
This commit is contained in:
Nigel Gott 2023-04-25 08:38:19 +00:00
commit a278ff8856
6 changed files with 67 additions and 20 deletions
.gitlab-ci.yml
.gitlab
ci_dind_image
ci_includes
ci_util_image
changelog/entries/unreleased/feature
deploy/all-in-one

View file

@ -334,14 +334,15 @@ build-ci-dind-image:
image: docker:20.10.18
stage: build
services:
- $CI_DIND_IMAGE
- name: $CI_DIND_IMAGE
alias: docker
variables:
DOCKER_BUILDKIT: 1
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
script:
- echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
- cd e2e-tests
- cd .gitlab/ci_dind_image
- docker build -t $CI_DIND_IMAGE .
- docker push $CI_DIND_IMAGE
# Only trigger this job manually to prevent it running every single time a new branch

View file

@ -14,5 +14,5 @@ EXPOSE 2376/tcp
ENTRYPOINT ["dockerd-entrypoint.sh"]
CMD []
ENV DOCKER_VERSION=20.10.17
ENV DOCKER_VERSION=20.10.18
ENV DOCKER_TLS_CERTDIR='/certs'

View file

@ -107,7 +107,32 @@
EXTRA_BUILD_ARGS="$EXTRA_BUILD_ARGS --build-arg FROM_IMAGE=$BUILD_FROM_IMAGE";
echo "Building from $BUILD_FROM_IMAGE."
fi
docker context create multi-context
docker buildx create --use --name multi --driver docker-container --platform linux/amd64 multi-context
if [[ -n "$BUILD_ARM" ]]; then
which ssh-agent
eval `ssh-agent -s`
echo "${ARM_BUILDER_SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add - > /dev/null
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "$ARM_BUILDER_SSH_PUBLIC_KEY" >> ~/.ssh/id_rsa.pub
[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
echo "Building multi-arch images for ARM also."
docker buildx create --append --name multi --driver docker-container --platform linux/arm64/v8 "$ARM_TARGET"
DOCKER_BUILD_PLATFORMS=linux/amd64,linux/arm64/v8
else
DOCKER_BUILD_PLATFORMS=linux/amd64
fi
if [[ "$CI_COMMIT_BRANCH" != "$MASTER_BRANCH_NAME" ]]; then
# We don't use latest branch images from master for any caching so no need to
# bother pushing.
EXTRA_BUILD_ARGS="$EXTRA_BUILD_ARGS --tag $LATEST_BRANCH_CI_IMAGE";
fi
# * Use `--build-arg BUILDKIT_INLINE_CACHE=1` to ensure this image's intermediate
# layers will be cached so builds caching from this image can use those layers.
# * $CACHE_ARG is a --cache-from if we have an existing image that we can use
@ -115,24 +140,17 @@
# * Target the dev image as we want to run tests and linting in this image.
# * Tag as both the ci image for use in later stages and the latest ci image to
# cache any future ci pipeline runs.
docker build \
docker buildx build \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--platform=$DOCKER_BUILD_PLATFORMS \
$CACHE_FROM_BUILD_ARGS \
$EXTRA_BUILD_ARGS \
$IMAGE_LABELS \
--push \
--target dev \
--tag $CI_IMAGE_PATH \
--tag $LATEST_BRANCH_CI_IMAGE \
-f $DOCKERFILE_PATH .;
# ===== 3. Push the CI image for the next stages and latest ci image cache =====
docker push $CI_IMAGE_PATH
if [[ "$CI_COMMIT_BRANCH" != "$MASTER_BRANCH_NAME" ]]; then
# We don't use latest branch images from master for any caching so no need to
# bother pushing.
docker push $LATEST_BRANCH_CI_IMAGE
fi
# Builds a non-dev (no docker build target provided) and fully labelled final image
# and tags and pushes the non-dev and dev images using $TESTED_IMAGE_PREFIX to mark
@ -282,33 +300,54 @@
fi
fi
}
docker context create multi-context
docker buildx create --use --name multi --driver docker-container --platform linux/amd64 multi-context
if [[ -n "$BUILD_ARM" ]]; then
which ssh-agent
eval `ssh-agent -s`
echo "${ARM_BUILDER_SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add - > /dev/null
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "$ARM_BUILDER_SSH_PUBLIC_KEY" >> ~/.ssh/id_rsa.pub
[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
echo "Building multi-arch images for ARM also."
docker buildx create --append --name multi --driver docker-container --platform linux/arm64/v8 "$ARM_TARGET"
DOCKER_BUILD_PLATFORMS=linux/amd64,linux/arm64/v8
else
DOCKER_BUILD_PLATFORMS=linux/amd64
fi
setup_build_from_image ""
setup_build_from_image BACKEND
setup_build_from_image WEBFRONTEND
# Build the normal non-dev image with all the tags and labels.
docker build \
docker buildx build \
--platform=$DOCKER_BUILD_PLATFORMS \
$CACHE_FROM_BUILD_ARGS \
$EXTRA_BUILD_ARGS \
$FORMATTEDTAGLIST \
$IMAGE_LABELS \
--push \
-t $TARGET_NON_DEV_IMAGE_PATH \
-f $DOCKERFILE_PATH .;
docker push $TARGET_NON_DEV_IMAGE_PATH
# Build the cache image with layer caching enabled. We don't enable it for the
# image above to reduce its size.
# We don't do this for master as master always caches from develop.
if [[ "$CI_COMMIT_BRANCH" != "$MASTER_BRANCH_NAME" ]]; then
docker build \
docker buildx build \
--platform=$DOCKER_BUILD_PLATFORMS \
$CACHE_FROM_BUILD_ARGS \
$EXTRA_BUILD_ARGS \
$IMAGE_LABELS \
--push \
--build-arg BUILDKIT_INLINE_CACHE=1 \
-t $NON_DEV_CACHE_IMAGE \
-f $DOCKERFILE_PATH .;
docker push $NON_DEV_CACHE_IMAGE
fi
if [[ -n "$DEV_IMAGE_NAME" ]]; then

View file

@ -1,7 +1,7 @@
# A small helper image which has some useful tools pre-installed that are used by ci
# stages. By building our own little image it means every single ci job doesn't need
# to repeatedly re-install these tools when they run.
FROM docker:20.10.13
FROM docker:20.10.18
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache curl git jq python3 openssh-client nodejs yarn docker-cli-compose bash && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip

View file

@ -0,0 +1,7 @@
{
"type": "feature",
"message": "Update all official Baserow images to now work on arm64 as well as amd64. ",
"issue_number": 890,
"bullet_points": [],
"created_at": "2023-04-20"
}

View file

@ -68,8 +68,8 @@ RUN apt-get update && \
npm install --global yarn@1.22.19 && \
# ========================
# Install Caddy
# ========================
curl -o caddy.tar.gz -sL https://github.com/caddyserver/caddy/releases/download/v2.4.6/caddy_2.4.6_linux_amd64.tar.gz && \
# ======================== \
curl -o caddy.tar.gz -sL "https://github.com/caddyserver/caddy/releases/download/v2.4.6/caddy_2.4.6_linux_$(dpkg --print-architecture).tar.gz" && \
tar -xf caddy.tar.gz && \
mv caddy /usr/bin/ && \
rm caddy.tar.gz && \