This repository has been archived by the owner on Jul 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
executable file
·65 lines (53 loc) · 2.28 KB
/
entrypoint.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
set -e
AUTH_STRING=$((echo -n oauth2accesstoken:; curl -s -H Metadata-Flavor:Google http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token | jq -r .access_token ) | tr -d '\n' | base64 -w0)
mkdir -p ~/.docker
cat > ~/.docker/config.json <<EOF
{
"auths": {
"https://appengine.gcr.io": {"auth": "$AUTH_STRING", "email": "[email protected]"},
"https://asia-mirror.gcr.io": {"auth": "$AUTH_STRING", "email": "[email protected]"},
"https://asia.gcr.io": {"auth": "$AUTH_STRING", "email": "[email protected]"},
"https://b.gcr.io": {"auth": "$AUTH_STRING", "email": "[email protected]"},
"https://bucket.gcr.io": {"auth": "$AUTH_STRING", "email": "[email protected]"},
"https://eu-mirror.gcr.io": {"auth": "$AUTH_STRING", "email": "[email protected]"},
"https://eu.gcr.io": {"auth": "$AUTH_STRING", "email": "[email protected]"},
"https://gcr.io": {"auth": "$AUTH_STRING", "email": "[email protected]"},
"https://gcr.kubernetes.io": {"auth": "$AUTH_STRING", "email": "[email protected]"},
"https://k8s.gcr.io": {"auth": "$AUTH_STRING", "email": "[email protected]"},
"https://l.gcr.io": {"auth": "$AUTH_STRING", "email": "[email protected]"},
"https://launcher.gcr.io": {"auth": "$AUTH_STRING", "email": "[email protected]"},
"https://mirror.gcr.io": {"auth": "$AUTH_STRING", "email": "[email protected]"},
"https://us-mirror.gcr.io": {"auth": "$AUTH_STRING", "email": "[email protected]"},
"https://us.gcr.io": {"auth": "$AUTH_STRING", "email": "[email protected]"}
}
}
EOF
if [ -z "$PLUGIN_PREFIX" ]; then
echo "Missing argument prefix"
exit 1
fi
if [ -z "$PLUGIN_FLAVOR" ]; then
IMAGE_NAME=$DRONE_REPO_NAME
BUILD_ARGS=""
else
IMAGE_NAME=$DRONE_REPO_NAME/$PLUGIN_FLAVOR
BUILD_ARGS="--build-arg FLAVOR=$PLUGIN_FLAVOR"
fi
if [ -z "$PLUGIN_DIR" ]; then
PLUGIN_DIR=.
fi
if [ -z "$PLUGIN_DOCKERFILE" ]; then
PLUGIN_DOCKERFILE=Dockerfile
fi
cd $PLUGIN_DIR
IMAGE=$PLUGIN_PREFIX/$IMAGE_NAME
echo Building...
docker build -t $IMAGE:$DRONE_COMMIT_SHA -f $PLUGIN_DOCKERFILE $BUILD_ARGS .
echo Pushing $IMAGE:$DRONE_COMMIT_SHA ...
docker push $IMAGE:$DRONE_COMMIT_SHA
if [ "$PLUGIN_TAG_LATEST" = true ] ; then
echo Pushing $IMAGE:latest ...
docker tag $IMAGE:$DRONE_COMMIT_SHA $IMAGE:latest
docker push $IMAGE:latest
fi