-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathbuild-app.sh
executable file
·51 lines (40 loc) · 1.26 KB
/
build-app.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
#!/bin/bash
set -eu
# build-app.sh takes a base image tag and app bundle URL / path, and
# builds a docker image for an application similar to how ImageBuilder
# builds it. The output image is tagged with "<repository>:<timestamp>".
# This script is for manual testing only. It's not used anywhere in
# production. This is useful since there's no testing framework set
# yet to verify changes to galaxy-app image.
cd "$(dirname "$0")"
source lib.sh
if [[ "$#" != 3 ]]; then
echo "usage: $0 <base image> <bundle> <repository>" >&2
exit 1
fi
baseimage="$1"
bundle="$2"
repository="$3"
workdir="$(mktemp -dt galaxy-app-build.XXXXXX)"
tag=$(TZ=UTC date +"%Y%m%dT%H%M%SZ")
cd "$workdir"
if [[ "${bundle}" =~ ^(http|https):// ]]; then
echo "Fetching ${bundle}"
curl -s "${bundle}" -O ./bundle.tgz
else
cp "${bundle}" ./bundle.tgz
fi
# Dockerfile template
# Slightly different from embedded template in ImageBuilder,
# to support copying a bundle in local filesystem.
cat << EOF > Dockerfile
FROM ${baseimage}
COPY bundle.tgz /tmp/bundle.tgz
RUN bash -x /app/setup.sh file:///tmp/bundle.tgz
EOF
set -x
docker build -t "${repository}:${tag}" .
set +x
echo "Tag: ${repository}:${tag}"
echo "Run with "
echo "$ docker run --rm -p 3000:3000 -e ROOT_URL=<URL> ${repository}:${tag}"