mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Docker images are now multi-architecture
With linux/amd64 and linux/arm64 Use Docker Compose 2.1.1 instead of Docker Compose 1.x Reduce Docker images size, based on Alpine and Debian, again
This commit is contained in:
parent
159d9ca754
commit
539f2b2a4a
@ -11,6 +11,8 @@ variables:
|
|||||||
PSU_TAG: $$CI_COMMIT_SHA
|
PSU_TAG: $$CI_COMMIT_SHA
|
||||||
PSU_TAG_CORE: core-$$CI_COMMIT_SHA
|
PSU_TAG_CORE: core-$$CI_COMMIT_SHA
|
||||||
DOCKER_REGISTRY_IMAGE: $DOCKER_REGISTRY/$CI_PROJECT_PATH
|
DOCKER_REGISTRY_IMAGE: $DOCKER_REGISTRY/$CI_PROJECT_PATH
|
||||||
|
BUILDX_VERSION: "v0.7.1"
|
||||||
|
DOCKER_MULTI_ARCH: "linux/amd64,linux/arm64"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- cleanup
|
- cleanup
|
||||||
@ -28,6 +30,7 @@ stages:
|
|||||||
variables:
|
variables:
|
||||||
- $CI_COMMIT_TAG == "dev"
|
- $CI_COMMIT_TAG == "dev"
|
||||||
script:
|
script:
|
||||||
|
- setup_docker_multi_arch
|
||||||
- setup_docker
|
- setup_docker
|
||||||
- registry_login
|
- registry_login
|
||||||
- cd ${CONTAINER_FOLDER:-.}
|
- cd ${CONTAINER_FOLDER:-.}
|
||||||
@ -38,10 +41,7 @@ stages:
|
|||||||
echo "$CI_COMMIT_SHA";
|
echo "$CI_COMMIT_SHA";
|
||||||
fi)
|
fi)
|
||||||
export CONTAINER_COMMIT_SHA
|
export CONTAINER_COMMIT_SHA
|
||||||
- docker pull $CONTAINER_IMAGE:${CONTAINER_VERSION:-latest} || true
|
- docker buildx build --compress --push --platform $DOCKER_MULTI_ARCH --pull $(if [[ -n "$DOCKER_CACHE_DISABLED" ]]; then echo "--no-cache "; else echo "--cache-from $CONTAINER_IMAGE:${CONTAINER_VERSION:-latest}"; fi) --file ${DOCKER_FILE:-Dockerfile} --tag $CONTAINER_IMAGE:$CONTAINER_COMMIT_SHA --tag $CONTAINER_IMAGE:${CONTAINER_VERSION:-latest} --build-arg HTTP_PROXY="$HTTP_PROXY" --build-arg http_proxy="$http_proxy" --build-arg HTTPS_PROXY="$HTTPS_PROXY" --build-arg https_proxy="$https_proxy" --build-arg FTP_PROXY="$FTP_PROXY" --build-arg ftp_proxy="$ftp_proxy" --build-arg NO_PROXY="$NO_PROXY" --build-arg no_proxy="$no_proxy" .
|
||||||
- docker build --pull $(if [[ -n "$DOCKER_CACHE_DISABLED" ]]; then echo "--no-cache "; else echo "--cache-from $CONTAINER_IMAGE:${CONTAINER_VERSION:-latest}"; fi) --file ${DOCKER_FILE:-Dockerfile} --tag $CONTAINER_IMAGE:$CONTAINER_COMMIT_SHA --tag $CONTAINER_IMAGE:${CONTAINER_VERSION:-latest} --build-arg HTTP_PROXY="$HTTP_PROXY" --build-arg http_proxy="$http_proxy" --build-arg HTTPS_PROXY="$HTTPS_PROXY" --build-arg https_proxy="$https_proxy" --build-arg FTP_PROXY="$FTP_PROXY" --build-arg ftp_proxy="$ftp_proxy" --build-arg NO_PROXY="$NO_PROXY" --build-arg no_proxy="$no_proxy" .
|
|
||||||
- docker push $CONTAINER_IMAGE:$CONTAINER_COMMIT_SHA
|
|
||||||
- docker push $CONTAINER_IMAGE:${CONTAINER_VERSION:-latest}
|
|
||||||
|
|
||||||
build:main:
|
build:main:
|
||||||
<<: *build_definition
|
<<: *build_definition
|
||||||
@ -129,6 +129,7 @@ release:
|
|||||||
variables:
|
variables:
|
||||||
- $CI_COMMIT_TAG == "dev"
|
- $CI_COMMIT_TAG == "dev"
|
||||||
script:
|
script:
|
||||||
|
- setup_docker_multi_arch
|
||||||
- setup_docker
|
- setup_docker
|
||||||
- registry_login
|
- registry_login
|
||||||
- external_registry_login
|
- external_registry_login
|
||||||
|
@ -7,12 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
- Docker images are now multi-architecture (`linux/amd64` and `linux/arm64` 🦾)
|
||||||
- [macOS](https://apple.com/macos) support
|
- [macOS](https://apple.com/macos) support
|
||||||
- [Windows](https://microsoft.com/windows) support, but it could be unstable ⚠️
|
- [Windows](https://microsoft.com/windows) support, but it could be unstable ⚠️
|
||||||
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer <abbr title="Community Edition">CE</abbr> [2.9.3](https://app.swaggerhub.com/apis/portainer/portainer-ce/2.9.2) API
|
- Test <abbr title="Portainer Stack Utils">PSU</abbr> with Portainer <abbr title="Community Edition">CE</abbr> [2.9.3](https://app.swaggerhub.com/apis/portainer/portainer-ce/2.9.2) API
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Upgrade Operating System of Docker based images, with [Alpine 3.15](https://hub.docker.com/_/alpine)
|
- Upgrade Operating System of Docker based images, with [Alpine 3.15](https://hub.docker.com/_/alpine)
|
||||||
|
- Use Docker [Compose 2.1.1](https://github.com/docker/compose/releases/tag/v2.1.1) instead of Docker [Compose 1.x](https://github.com/docker/compose/releases/tag/1.28.0)
|
||||||
|
- Reduce Docker images size, based on Alpine and Debian, again
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix documentation scrolling between pages, with the [`auto2top`](https://docsify.js.org/#/configuration?id=auto2top) option of [docsify](https://docsify.js.org)
|
- Fix documentation scrolling between pages, with the [`auto2top`](https://docsify.js.org/#/configuration?id=auto2top) option of [docsify](https://docsify.js.org)
|
||||||
|
10
Dockerfile
10
Dockerfile
@ -1,9 +1,13 @@
|
|||||||
FROM alpine:3.15
|
FROM --platform=$BUILDPLATFORM alpine:3.15
|
||||||
|
|
||||||
|
ARG DOCKER_COMPOSE_VERSION="v2.1.1"
|
||||||
|
|
||||||
RUN set -e; \
|
RUN set -e; \
|
||||||
apk add --no-cache \
|
apk add --no-cache \
|
||||||
bash ca-certificates curl docker-compose gettext jq; \
|
bash ca-certificates curl gettext jq; \
|
||||||
rm -rf $(find / -regex '.*\.py[co]')
|
\
|
||||||
|
curl --fail --location --silent "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" --output /usr/local/bin/docker-compose; \
|
||||||
|
chmod +x /usr/local/bin/docker-compose
|
||||||
|
|
||||||
ENV LANG="en_US.UTF-8" \
|
ENV LANG="en_US.UTF-8" \
|
||||||
LC_ALL="C.UTF-8" \
|
LC_ALL="C.UTF-8" \
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM alpine:3.15
|
FROM --platform=$BUILDPLATFORM alpine:3.15
|
||||||
|
|
||||||
RUN set -e; \
|
RUN set -e; \
|
||||||
apk add --no-cache \
|
apk add --no-cache \
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
FROM debian:11-slim
|
FROM --platform=$BUILDPLATFORM debian:11-slim
|
||||||
|
|
||||||
ARG DOCKER_COMPOSE_VERSION=1.29.2
|
ARG DOCKER_COMPOSE_VERSION="v2.1.1"
|
||||||
|
|
||||||
RUN set -e; \
|
RUN set -e; \
|
||||||
apt-get update -yqq; \
|
apt-get update -yqq; \
|
||||||
apt-get install \
|
apt-get install \
|
||||||
ca-certificates curl gettext-base jq -yqq; \
|
ca-certificates curl gettext-base jq -yqq; \
|
||||||
\
|
\
|
||||||
curl --fail --silent --location "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose; \
|
curl --fail --location --silent "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" --output /usr/local/bin/docker-compose; \
|
||||||
chmod +x /usr/local/bin/docker-compose; \
|
chmod +x /usr/local/bin/docker-compose; \
|
||||||
\
|
\
|
||||||
apt-get clean; \
|
apt-get clean; \
|
||||||
rm -rf /var/lib/apt/lists/*; \
|
rm -rf /var/lib/apt/lists/*
|
||||||
rm -rf $(find / -regex '.*\.py[co]')
|
|
||||||
|
|
||||||
ENV LANG="en_US.UTF-8" \
|
ENV LANG="en_US.UTF-8" \
|
||||||
LC_ALL="C.UTF-8" \
|
LC_ALL="C.UTF-8" \
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM debian:11-slim
|
FROM --platform=$BUILDPLATFORM debian:11-slim
|
||||||
|
|
||||||
RUN set -e; \
|
RUN set -e; \
|
||||||
apt-get update -yqq; \
|
apt-get update -yqq; \
|
||||||
|
@ -26,6 +26,24 @@ function setup_docker() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setup_docker_multi_arch() {
|
||||||
|
mkdir -p ~/.docker/cli-plugins/
|
||||||
|
current_system="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
||||||
|
current_arch="$(uname -m)"
|
||||||
|
case $current_arch in
|
||||||
|
armv6*) current_arch="arm-v6";;
|
||||||
|
armv7*) current_arch="arm-v7";;
|
||||||
|
aarch64) current_arch="arm64";;
|
||||||
|
x86_64) current_arch="amd64";;
|
||||||
|
esac
|
||||||
|
curl --fail --location --silent "https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.${current_system}-${current_arch}" --output ~/.docker/cli-plugins/docker-buildx
|
||||||
|
chmod a+x ~/.docker/cli-plugins/docker-buildx
|
||||||
|
docker context create multiarch
|
||||||
|
docker run --privileged --rm tonistiigi/binfmt --install all
|
||||||
|
docker buildx create --name multibuilder --use --platform $DOCKER_MULTI_ARCH multiarch
|
||||||
|
docker buildx inspect --bootstrap
|
||||||
|
}
|
||||||
|
|
||||||
function git_tag_on_success() {
|
function git_tag_on_success() {
|
||||||
local git_tag="${1:-dev}"
|
local git_tag="${1:-dev}"
|
||||||
local target_branch="${2:-master}"
|
local target_branch="${2:-master}"
|
||||||
@ -61,13 +79,10 @@ function registry_tag_on_success() {
|
|||||||
local target_external_registry_image="${6:-$DOCKER_REGISTRY_IMAGE}"
|
local target_external_registry_image="${6:-$DOCKER_REGISTRY_IMAGE}"
|
||||||
|
|
||||||
if [ "$CI_COMMIT_REF_NAME" == "$target_branch" ]; then
|
if [ "$CI_COMMIT_REF_NAME" == "$target_branch" ]; then
|
||||||
docker pull "$current_registry_image:$current_registry_tag"
|
echo -e "FROM --platform=\$BUILDPLATFORM $current_registry_image:$current_registry_tag
|
||||||
docker tag "$current_registry_image:$current_registry_tag" "$target_registry_image:$target_registry_tag"
|
" > Dockerfile.tmp
|
||||||
docker push "$target_registry_image:$target_registry_tag"
|
docker buildx build --compress --push --platform $DOCKER_MULTI_ARCH --tag "$target_registry_image:$target_registry_tag" $(if [ -n "$DOCKER_REGISTRY" ] && [ -n "$target_external_registry_image" ]; then echo "--tag $target_external_registry_image:$target_registry_tag"; fi) --file Dockerfile.tmp .
|
||||||
if [ -n "$target_external_registry_image" ]; then
|
rm -f Dockerfile.tmp
|
||||||
docker tag "$current_registry_image:$current_registry_tag" "$target_external_registry_image:$target_registry_tag"
|
|
||||||
docker push "$target_external_registry_image:$target_registry_tag"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user