forked from jugatsu/onec-docker
-
Notifications
You must be signed in to change notification settings - Fork 75
/
build-oscript-swarm-agent.sh
executable file
·41 lines (35 loc) · 1.07 KB
/
build-oscript-swarm-agent.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
#!/usr/bin/env bash
set -eo pipefail
if [ -n "${DOCKER_LOGIN}" ] && [ -n "${DOCKER_PASSWORD}" ] && [ -n "${DOCKER_REGISTRY_URL}" ]; then
if ! docker login -u "${DOCKER_LOGIN}" -p "${DOCKER_PASSWORD}" "${DOCKER_REGISTRY_URL}"; then
echo "Docker login failed"
exit 1
fi
else
echo "Skipping Docker login due to missing credentials"
fi
if [ "${DOCKER_SYSTEM_PRUNE}" = 'true' ] ; then
docker system prune -af
fi
last_arg='.'
if [ "${NO_CACHE}" = 'true' ] ; then
last_arg='--no-cache .'
fi
docker build \
--pull \
$no_cache_arg \
--build-arg DOCKER_REGISTRY_URL=library \
--build-arg BASE_IMAGE=eclipse-temurin \
--build-arg BASE_TAG=17 \
-t $DOCKER_REGISTRY_URL/oscript-jdk:latest \
-f oscript/Dockerfile \
$last_arg
docker build \
$no_cache_arg \
--build-arg DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \
--build-arg BASE_IMAGE=oscript-jdk \
--build-arg BASE_TAG=latest \
-t $DOCKER_REGISTRY_URL/oscript-agent:latest \
-f swarm-jenkins-agent/Dockerfile \
$last_arg
docker push $DOCKER_REGISTRY_URL/oscript-agent:latest