forked from coder/code-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bash
More file actions
executable file
·55 lines (46 loc) · 1.29 KB
/
Copy pathbuild.bash
File metadata and controls
executable file
·55 lines (46 loc) · 1.29 KB
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
52
53
54
55
#!/bin/bash
set -euxo pipefail
# Build using a Docker container using the specified image and version.
function docker_build() {
local image="${1}" ; shift
local version="${1}" ; shift
local ci=${CI:-}
local containerId
containerId=$(docker create --network=host --rm -it -v "$(pwd)"/.cache:/src/.cache "${image}")
docker start "${containerId}"
docker exec "${containerId}" mkdir -p /src
function docker_exec() {
docker exec "${containerId}" bash -c "$@"
}
docker cp ./. "${containerId}":/src
docker_exec "cd /src && yarn"
docker_exec "cd /src && npm rebuild"
docker_exec "cd /src && VERSION=${version} CI=${ci} yarn build"
docker_exec "cd /src && yarn bundle"
docker_exec "cd /src && yarn package ${version}"
docker cp "${containerId}":/src/release/. ./release/
docker stop "${containerId}"
}
function main() {
local version=${VERSION:-}
local ostype=${OSTYPE:-}
local target=${TARGET:-}
if [[ -z "${version}" ]] ; then
>&2 echo "Must set VERSION environment variable"
exit 1
fi
if [[ "${ostype}" == "darwin"* ]]; then
VERSION="${version}" yarn build
yarn bundle
yarn package "${version}"
else
local image
if [[ "${target}" == "alpine" ]]; then
image="codercom/nbin-alpine"
else
image="codercom/nbin-centos"
fi
docker_build "${image}" "${version}"
fi
}
main "$@"