Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2024-11-05 02:28:00 +01:00
ca0fd7a31b
- Split Debian and Alpine into different build matrix This starts building both Debian and Alpine based images at the same time - Make use of Docker BuildKit, which improves speed also. - Use BuildKit caching for Rust Cargo across docker images. This prevents downloading the same crates multiple times. - Use Github Actions Services to start a docker registry, starting it via the build script sometimes caused issues. - Updated the Build workflow to use Ubuntu 20.04 which is more close to the Bullseye Debian release regarding package versions.
50 Zeilen
1,6 KiB
Bash
Ausführbare Datei
50 Zeilen
1,6 KiB
Bash
Ausführbare Datei
#!/bin/bash
|
|
|
|
echo ">>> Building images..."
|
|
|
|
source ./hooks/arches.sh
|
|
|
|
if [[ -z "${SOURCE_COMMIT}" ]]; then
|
|
# This var is typically predefined by Docker Hub, but it won't be
|
|
# when testing locally.
|
|
SOURCE_COMMIT="$(git rev-parse HEAD)"
|
|
fi
|
|
|
|
# Construct a version string in the style of `build.rs`.
|
|
GIT_EXACT_TAG="$(git describe --tags --abbrev=0 --exact-match 2>/dev/null)"
|
|
if [[ -n "${GIT_EXACT_TAG}" ]]; then
|
|
SOURCE_VERSION="${GIT_EXACT_TAG}"
|
|
else
|
|
GIT_LAST_TAG="$(git describe --tags --abbrev=0)"
|
|
SOURCE_VERSION="${GIT_LAST_TAG}-${SOURCE_COMMIT:0:8}"
|
|
fi
|
|
|
|
LABELS=(
|
|
# https://github.com/opencontainers/image-spec/blob/master/annotations.md
|
|
org.opencontainers.image.created="$(date --utc --iso-8601=seconds)"
|
|
org.opencontainers.image.documentation="https://github.com/dani-garcia/vaultwarden/wiki"
|
|
org.opencontainers.image.licenses="GPL-3.0-only"
|
|
org.opencontainers.image.revision="${SOURCE_COMMIT}"
|
|
org.opencontainers.image.source="${SOURCE_REPOSITORY_URL}"
|
|
org.opencontainers.image.url="https://hub.docker.com/r/${DOCKER_REPO#*/}"
|
|
org.opencontainers.image.version="${SOURCE_VERSION}"
|
|
)
|
|
LABEL_ARGS=()
|
|
for label in "${LABELS[@]}"; do
|
|
LABEL_ARGS+=(--label "${label}")
|
|
done
|
|
|
|
# Check if DOCKER_BUILDKIT is set, if so, use the Dockerfile.buildx as template
|
|
if [[ -n "${DOCKER_BUILDKIT}" ]]; then
|
|
buildx_suffix=.buildx
|
|
fi
|
|
|
|
set -ex
|
|
|
|
for arch in "${arches[@]}"; do
|
|
docker build \
|
|
"${LABEL_ARGS[@]}" \
|
|
-t "${DOCKER_REPO}:${DOCKER_TAG}-${arch}" \
|
|
-f docker/${arch}/Dockerfile${buildx_suffix}${distro_suffix} \
|
|
.
|
|
done
|