-
Notifications
You must be signed in to change notification settings - Fork 135
/
build.sh
executable file
·32 lines (26 loc) · 1.49 KB
/
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
#!/usr/bin/env bash
# Exit on error. Append "|| true" if you expect an error.
set -o errexit
# Exit on error inside any functions or subshells.
set -o errtrace
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
set -o nounset
# Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump |gzip`
set -o pipefail
function finish {
docker rm -f builder
}
trap finish EXIT
# ——— BUILD/TEST CODE —————————————————————————————————————————————————————————
# build/test our code
docker build -t build-img -f Dockerfile.build .
# ——— CREATE A TEMP DIRECTORY —————————————————————————————————————————————————
mkdir -p target
# ——— GET THE JAR OUT —————————————————————————————————————————————————————————
# start a temporary container from our "build-img"
# so we can get to its filesystem
docker create --name builder build-img
docker cp builder:/code/build/libs/docker-olp-0.0.1-SNAPSHOT.jar \
./target/
# ——— BUILD OUR FINAL IMAGE ———————————————————————————————————————————————————
docker build -t final-img -f Dockerfile.final .