forked from theia-ide/theia-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_container.sh
executable file
·32 lines (26 loc) · 1.32 KB
/
build_container.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
#!/bin/bash
set -e
# this script is called by Travis to build the Docker image
NPM_TAG=$1
IMAGE_NAME=$2
NODEVERSION=$3
# Theia standard port is listening in port 3000 (the common nodejs port), and it is exposed when running the docker
# container (-p 0.0.0.0:4000:3000). But some new applications may need to change it (e.g. theia-https-docker).
# This 4th parameter enables to expose a custom port instead of the common 3000 port. It is set to 3000 as a default
# value if not included, for backward compatiblity
PORT=${4:-3000}
shift
shift
shift
# We know that there are at least 3 parameters. If we shift the 4th parameter and it is not set, shift will fail thus
# failing the script (because of set -e)
[ $# -gt 0 ] && shift
cd "$IMAGE_NAME-docker"
IMAGE="theiaide/$IMAGE_NAME"
IMAGE_TAG="$IMAGE":$(npm view "@theia/core@$NPM_TAG" version)
echo $IMAGE_TAG
docker build --build-arg "version=$NPM_TAG" --build-arg "NODE_VERSION=$NODE_VERSION" --build-arg "GITHUB_TOKEN=$GITHUB_TOKEN" . -t "$IMAGE_TAG" --no-cache
docker tag "$IMAGE_TAG" "$IMAGE:$NPM_TAG"
# Now we allow to pass extra parameters to the docker run command: any extra parameter to build_container.sh is
# interpreted as a parameter to docker run (it is useful for e.g. passing environment variables or volume mappings)
docker run --init -d "$@" -p 0.0.0.0:4000:$PORT "$IMAGE_TAG"