2019-07-03 08:10:17 +08:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
2019-07-11 07:10:39 +08:00
|
|
|
# Build using a Docker container.
|
2019-07-03 08:10:17 +08:00
|
|
|
function docker-build() {
|
2019-08-06 00:03:47 +08:00
|
|
|
local target="${TARGET:-}"
|
2019-07-12 06:12:52 +08:00
|
|
|
local image="codercom/nbin-${target}"
|
|
|
|
if [[ "${target}" == "linux" ]] ; then
|
|
|
|
image="codercom/nbin-centos"
|
|
|
|
fi
|
|
|
|
|
2019-07-03 08:10:17 +08:00
|
|
|
local containerId
|
|
|
|
containerId=$(docker create --network=host --rm -it -v "$(pwd)"/.cache:/src/.cache "${image}")
|
|
|
|
docker start "${containerId}"
|
|
|
|
docker exec "${containerId}" mkdir -p /src
|
|
|
|
|
2019-07-12 06:12:52 +08:00
|
|
|
# TODO: temporary as long as we are rebuilding modules.
|
|
|
|
if [[ "${image}" == "codercom/nbin-alpine" ]] ; then
|
|
|
|
docker exec "${containerId}" apk add libxkbfile-dev libsecret-dev
|
2019-07-16 02:23:29 +08:00
|
|
|
else
|
2019-07-26 06:39:43 +08:00
|
|
|
# TODO: at some point git existed but it seems to have disappeared.
|
2019-07-25 00:23:00 +08:00
|
|
|
docker exec "${containerId}" yum install -y libxkbfile-devel libsecret-devel git
|
2019-07-12 06:12:52 +08:00
|
|
|
fi
|
|
|
|
|
2019-07-03 08:10:17 +08:00
|
|
|
function docker-exec() {
|
2019-07-11 07:10:39 +08:00
|
|
|
local command="${1}" ; shift
|
2019-08-06 00:03:47 +08:00
|
|
|
local args="'${vscodeVersion}' '${codeServerVersion}' '${target}'"
|
2019-07-11 07:10:39 +08:00
|
|
|
docker exec "${containerId}" \
|
|
|
|
bash -c "cd /src && CI=true yarn ${command} ${args}"
|
2019-07-03 08:10:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
docker cp ./. "${containerId}":/src
|
2019-07-11 07:10:39 +08:00
|
|
|
docker-exec build
|
|
|
|
docker-exec binary
|
|
|
|
docker-exec package
|
2019-07-03 08:10:17 +08:00
|
|
|
docker cp "${containerId}":/src/release/. ./release/
|
|
|
|
|
|
|
|
docker stop "${containerId}"
|
|
|
|
}
|
|
|
|
|
2019-07-11 07:10:39 +08:00
|
|
|
# Build locally.
|
|
|
|
function local-build() {
|
|
|
|
function local-exec() {
|
|
|
|
local command="${1}" ; shift
|
2019-08-03 08:26:41 +08:00
|
|
|
CI=true yarn "${command}" "${vscodeVersion}" "${codeServerVersion}"
|
2019-07-11 07:10:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
local-exec build
|
|
|
|
local-exec binary
|
|
|
|
local-exec package
|
|
|
|
}
|
|
|
|
|
2019-07-03 08:10:17 +08:00
|
|
|
# Build code-server in the CI.
|
|
|
|
function main() {
|
2019-07-11 07:10:39 +08:00
|
|
|
local codeServerVersion="${VERSION:-}"
|
2019-07-03 08:10:17 +08:00
|
|
|
local vscodeVersion="${VSCODE_VERSION:-}"
|
|
|
|
local ostype="${OSTYPE:-}"
|
|
|
|
|
2019-07-11 07:10:39 +08:00
|
|
|
if [[ -z "${codeServerVersion}" ]] ; then
|
2019-07-03 08:10:17 +08:00
|
|
|
>&2 echo "Must set VERSION environment variable"; exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "${vscodeVersion}" ]] ; then
|
|
|
|
>&2 echo "Must set VSCODE_VERSION environment variable"; exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "${ostype}" == "darwin"* ]]; then
|
2019-07-11 07:10:39 +08:00
|
|
|
local-build
|
2019-07-03 08:10:17 +08:00
|
|
|
else
|
2019-07-11 07:10:39 +08:00
|
|
|
docker-build
|
2019-07-03 08:10:17 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|