-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
36 lines (30 loc) · 798 Bytes
/
build.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
#!/bin/bash
echo "build.sh start!"
set -e
set -o pipefail
if [ ! -e "${DOCKER_SOCKET}" ]; then
echo "Docker socket missing at ${DOCKER_SOCKET}"
exit 1
fi
if [ -n "${OUTPUT_IMAGE}" ]; then
TAG="${OUTPUT_REGISTRY}/${OUTPUT_IMAGE}"
fi
# Create the package
echo "git repo cloning start!"
git clone $SOURCE_URI /tmp/src
echo "go build start!"
cd /tmp/src
go build -o go-run
# Create the docker file for the final image
echo "Dockerfile prepare!"
cat > Dockerfile <<- EOF
FROM openshift/origin-base
COPY go-run $HOME/go-run
CMD $HOME/go-run
EOF
echo "Docker build start!"
docker build --rm -t "${TAG}" .
export DOCKER_USR=serviceaccount
export DOCKER_PWD=$(cat /run/secrets/kubernetes.io/serviceaccount/token)
docker login -u $DOCKER_USR -p $DOCKER_PWD 172.30.1.1:5000
docker push "${TAG}"