diff options
author | Alexandre Flament <alex@al-f.net> | 2021-04-24 08:53:12 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2021-04-28 14:40:00 +0200 |
commit | 20580bcbd458fa18c13bb9c1a32466ee5af48f97 (patch) | |
tree | 6667317d1953b92685bd094d0c23f791cd31d68d /manage | |
parent | fe3831db1aa73ebda6eb12fa3a321002c176ccc1 (diff) | |
download | searxng-20580bcbd458fa18c13bb9c1a32466ee5af48f97.tar.gz searxng-20580bcbd458fa18c13bb9c1a32466ee5af48f97.zip |
[docker] multiarch support: linux/amd64,linux/arm64,linux/arm/v7
make docker.buildx : build and push multiarch build.
(it can't be only build)
use buildx with the --cache-from and --cache-to options to cache the layers
(only the last built is cached)
Diffstat (limited to 'manage')
-rwxr-xr-x | manage | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -152,6 +152,10 @@ docker.push() { docker.build push } +docker.buildx() { + docker.build buildx +} + # shellcheck disable=SC2119 docker.build() { pyenv.install @@ -210,23 +214,34 @@ docker.build() { GITHUB_USER=$(echo "${GIT_URL}" | sed 's/.*github\.com\/\([^\/]*\).*/\1/') SEARX_IMAGE_NAME="${SEARX_IMAGE_NAME:-${GITHUB_USER:-searxng}/searxng}" + BUILD="build" + if [ "$1" = "buildx" ]; then + # buildx includes the push option + CACHE_TAG="${SEARX_IMAGE_NAME}:latest-build-cache" + BUILD="buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --push --cache-from=type=registry,ref=$CACHE_TAG --cache-to=type=registry,ref=$CACHE_TAG,mode=max" + shift + fi + build_msg DOCKER "Build command: ${BUILD}" + # build Docker image build_msg DOCKER "Building image ${SEARX_IMAGE_NAME}:${SEARX_GIT_VERSION}" - sudo docker build \ + # shellcheck disable=SC2086 + docker $BUILD \ + --build-arg BASE_IMAGE="${DEPENDENCIES_IMAGE_NAME}" \ --build-arg GIT_URL="${GIT_URL}" \ --build-arg SEARX_GIT_VERSION="${SEARX_GIT_VERSION}" \ --build-arg VERSION_GITCOMMIT="${VERSION_GITCOMMIT}" \ --build-arg LABEL_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \ --build-arg LABEL_VCS_REF="$(git rev-parse HEAD)" \ --build-arg LABEL_VCS_URL="${GIT_URL}" \ - --build-arg TIMESTAMP_SETTINGS="$(git log -1 --format="%cd" --date=unix -- searx/settings.yml)" \ - --build-arg TIMESTAMP_UWSGI="$(git log -1 --format="%cd" --date=unix -- dockerfiles/uwsgi.ini)" \ + --build-arg TIMESTAMP_SETTINGS="$(git log -1 --format="%cd" --date=unix -- searx/settings.yml)" \ + --build-arg TIMESTAMP_UWSGI="$(git log -1 --format="%cd" --date=unix -- dockerfiles/uwsgi.ini)" \ -t "${SEARX_IMAGE_NAME}:latest" -t "${SEARX_IMAGE_NAME}:${SEARX_GIT_VERSION}" . if [ "$1" = "push" ]; then - sudo docker push "${SEARX_IMAGE_NAME}:latest" - sudo docker push "${SEARX_IMAGE_NAME}:${SEARX_GIT_VERSION}" - fi + docker push "${SEARX_IMAGE_NAME}:latest" + docker push "${SEARX_IMAGE_NAME}:${SEARX_GIT_VERSION}" + fi ) dump_return $? } |