forked from bitnami/minideb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pushone
executable file
·43 lines (33 loc) · 1.3 KB
/
pushone
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
set -e
set -u
set -o pipefail
DIST=${1:?Specify the distrubution name}
PLATFORM=${2:-amd64}
BASENAME=bitnami/minideb
GCR_BASENAME=gcr.io/bitnami-containers/minideb
if [ -n "${DOCKER_PASSWORD:-}" ]; then
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
fi
if [ -n "${GCR_KEY:-}" ]; then
gcloud auth activate-service-account "$GCR_EMAIL" --key-file <(echo "$GCR_KEY")
gcloud auth print-access-token | docker login -u oauth2accesstoken --password-stdin gcr.io
elif [ -n "${GCR_TOKEN:-}" ]; then
echo "${GCR_TOKEN:-}" | docker login -u oauth2accesstoken --password-stdin gcr.io
fi
ENABLE_DOCKER_CONTENT_TRUST=0
if [ -n "${DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE:-}" ] && [ -n "${DOCKER_CONTENT_TRUST_REPOSITORY_KEY:-}" ]; then
tmpdir=$(mktemp -d)
(cd "${tmpdir}" && bash -c 'echo -n "${DOCKER_CONTENT_TRUST_REPOSITORY_KEY}" | base64 -d > key')
chmod 400 "${tmpdir}/key"
docker trust key load "${tmpdir}/key"
rm -rf "${tmpdir}"
export ENABLE_DOCKER_CONTENT_TRUST=1
fi
push() {
local dist="$1"
DOCKER_CONTENT_TRUST=${ENABLE_DOCKER_CONTENT_TRUST} docker push "${BASENAME}:${dist}"
docker push "${GCR_BASENAME}:${dist}"
}
docker tag "${BASENAME}:${DIST}-${PLATFORM}" "${GCR_BASENAME}:${DIST}-${PLATFORM}"
push "$DIST-${PLATFORM}"