2023-03-23 12:30:07 +01:00
|
|
|
#!/usr/bin/env bash
|
2020-06-10 11:01:41 +02:00
|
|
|
|
|
|
|
echo ">>> Building images..."
|
|
|
|
|
2023-03-23 12:30:07 +01:00
|
|
|
# shellcheck source=arches.sh
|
2020-06-10 11:01:41 +02:00
|
|
|
source ./hooks/arches.sh
|
|
|
|
|
2021-01-18 09:19:00 +01:00
|
|
|
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)"
|
2021-04-27 23:18:32 +02:00
|
|
|
org.opencontainers.image.documentation="https://github.com/dani-garcia/vaultwarden/wiki"
|
2022-06-16 15:13:10 +02:00
|
|
|
org.opencontainers.image.licenses="AGPL-3.0-only"
|
2021-01-18 09:19:00 +01:00
|
|
|
org.opencontainers.image.revision="${SOURCE_COMMIT}"
|
|
|
|
org.opencontainers.image.source="${SOURCE_REPOSITORY_URL}"
|
2023-03-23 12:30:07 +01:00
|
|
|
org.opencontainers.image.url="https://github.com/dani-garcia/vaultwarden"
|
2021-01-18 09:19:00 +01:00
|
|
|
org.opencontainers.image.version="${SOURCE_VERSION}"
|
|
|
|
)
|
|
|
|
LABEL_ARGS=()
|
|
|
|
for label in "${LABELS[@]}"; do
|
|
|
|
LABEL_ARGS+=(--label "${label}")
|
|
|
|
done
|
|
|
|
|
2023-01-22 10:01:02 +01:00
|
|
|
# Check if DOCKER_BUILDKIT is set, if so, use the Dockerfile.buildkit as template
|
2021-09-13 12:00:52 +02:00
|
|
|
if [[ -n "${DOCKER_BUILDKIT}" ]]; then
|
2023-01-22 10:01:02 +01:00
|
|
|
buildkit_suffix=.buildkit
|
2021-09-13 12:00:52 +02:00
|
|
|
fi
|
|
|
|
|
2020-06-10 11:01:41 +02:00
|
|
|
set -ex
|
|
|
|
|
|
|
|
for arch in "${arches[@]}"; do
|
|
|
|
docker build \
|
2021-01-18 09:19:00 +01:00
|
|
|
"${LABEL_ARGS[@]}" \
|
2020-06-10 11:01:41 +02:00
|
|
|
-t "${DOCKER_REPO}:${DOCKER_TAG}-${arch}" \
|
2023-03-23 12:30:07 +01:00
|
|
|
-f "docker/${arch}/Dockerfile${buildkit_suffix}${distro_suffix}" \
|
2020-06-10 11:01:41 +02:00
|
|
|
.
|
|
|
|
done
|