From 174cb2f8a98f24742eb73ecbedf9fc3e321b0ba0 Mon Sep 17 00:00:00 2001 From: Asher Date: Tue, 14 Jan 2020 15:06:49 -0600 Subject: [PATCH] Remove unused Docker step from CI script --- .dockerignore | 2 +- .drone.yml | 9 ++--- .travis.yml | 2 +- Dockerfile | 17 ++++----- scripts/cacher.sh | 2 +- scripts/ci.bash | 88 +++++++++++-------------------------------- scripts/ci.dockerfile | 7 ++-- 7 files changed, 40 insertions(+), 87 deletions(-) mode change 100644 => 100755 scripts/cacher.sh diff --git a/.dockerignore b/.dockerignore index cbfebc09e..72ce590bf 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,4 +9,4 @@ doc LICENSE README.md node_modules -release \ No newline at end of file +release diff --git a/.drone.yml b/.drone.yml index e59c802ba..8e6e6f19b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -61,8 +61,7 @@ steps: - v2 - ${DRONE_TAG} build_args: - - codeServerVersion=${DRONE_TAG} - - vscodeVersion=1.41.1 + - tag=${DRONE_TAG} when: event: tag @@ -181,8 +180,7 @@ steps: - arm64 - ${DRONE_TAG}-arm64 build_args: - - codeServerVersion=$DRONE_TAG - - vscodeVersion=1.41.1 + - tag=$DRONE_TAG when: event: tag @@ -301,8 +299,7 @@ steps: - arm - ${DRONE_TAG}-arm build_args: - - codeServerVersion=$DRONE_TAG - - vscodeVersion=1.41.1 + - tag=$DRONE_TAG when: event: tag diff --git a/.travis.yml b/.travis.yml index e3a7f6a53..0e7f0309f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,4 +35,4 @@ cache: timeout: 1000 yarn: true directories: - - source/vscode-1.41.1-source + - source diff --git a/Dockerfile b/Dockerfile index 6eb3ff73e..8e3a238da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ FROM node:12.14.0 -ARG codeServerVersion=docker -ARG vscodeVersion +ARG tag ARG githubToken # Install VS Code's deps. These are the only two it seems we need. @@ -12,13 +11,12 @@ WORKDIR /src COPY . . RUN yarn \ - && MINIFY=true GITHUB_TOKEN="${githubToken}" yarn build "${vscodeVersion}" "${codeServerVersion}" \ - && yarn binary "${vscodeVersion}" "${codeServerVersion}" \ - && mv "/src/binaries/code-server${codeServerVersion}-vsc${vscodeVersion}-linux-x86_64" /src/binaries/code-server \ + && DRONE_TAG="$tag" MINIFY=true BINARY=true GITHUB_TOKEN="$githubToken" ./scripts/ci.bash \ + && mv /src/binaries/* /src/binaries/code-server \ && rm -r /src/build \ && rm -r /src/source -# We deploy with ubuntu so that devs have a familiar environment. +# We deploy with Ubuntu so that devs have a familiar environment. FROM ubuntu:18.04 RUN apt-get update && apt-get install -y \ @@ -31,7 +29,7 @@ RUN apt-get update && apt-get install -y \ vim \ curl \ wget \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* RUN locale-gen en_US.UTF-8 # We cannot use update-locale because docker will not use the env variables @@ -43,10 +41,9 @@ RUN adduser --gecos '' --disabled-password coder && \ echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd USER coder -# We create first instead of just using WORKDIR as when WORKDIR creates, the -# user is root. +# Create first so these directories will be owned by coder instead of root +# (workdir and mounting appear to both default to root). RUN mkdir -p /home/coder/project -# To avoid EACCES issues on f.ex Crostini (ChromeOS) RUN mkdir -p /home/coder/.local/share/code-server WORKDIR /home/coder/project diff --git a/scripts/cacher.sh b/scripts/cacher.sh old mode 100644 new mode 100755 index c623e5d6c..0626755a7 --- a/scripts/cacher.sh +++ b/scripts/cacher.sh @@ -23,7 +23,7 @@ restore() { # the cache-upload directory will be uploaded as-is to the code-server bucket. package() { mkdir -p "cache-upload/cache/$1" - tar czfv "cache-upload/cache/$1/$tar.tar.gz" node_modules source/vscode-1.41.1-source + tar czfv "cache-upload/cache/$1/$tar.tar.gz" node_modules source } main() { diff --git a/scripts/ci.bash b/scripts/ci.bash index 078b06fa8..a9413d56f 100755 --- a/scripts/ci.bash +++ b/scripts/ci.bash @@ -1,81 +1,39 @@ #!/bin/bash +# ci.bash -- Build code-server in the CI. + set -euo pipefail -function docker-build() { - local target="${TARGET:-}" - local image="codercom/nbin-${target}" - local token="${GITHUB_TOKEN:-}" - local minify="${MINIFY:-}" - if [[ "${target}" == "linux" ]] ; then - image="codercom/nbin-centos" - fi - - local containerId - # Use a mount so we can cache the results. - containerId=$(docker create --network=host --rm -it -v "$(pwd)":/src "${image}") - docker start "${containerId}" - - # TODO: Might be better to move these dependencies to the images or create new - # ones on top of these. - if [[ "${image}" == "codercom/nbin-alpine" ]] ; then - docker exec "${containerId}" apk add libxkbfile-dev libsecret-dev - else - docker exec "${containerId}" yum install -y libxkbfile-devel libsecret-devel git - fi - - function docker-exec() { - local command="${1}" ; shift - local args="'${vscodeVersion}' '${codeServerVersion}'" - docker exec "${containerId}" \ - bash -c "cd /src && CI=true GITHUB_TOKEN=${token} MINIFY=${minify} yarn ${command} ${args}" - } - - docker-exec build - if [[ -n "${package}" ]] ; then - docker-exec binary - docker-exec package - fi - - docker kill "${containerId}" -} - -function local-build() { - function local-exec() { - local command="${1}" ; shift - CI=true yarn "${command}" "${vscodeVersion}" "${codeServerVersion}" - } - - local-exec build - if [[ -n "${package}" ]] ; then - local-exec binary - local-exec package - fi -} - -# Build code-server in the CI. function main() { cd "$(dirname "${0}")/.." - local codeServerVersion="${VERSION:-}" - local vscodeVersion="${VSCODE_VERSION:-1.41.1}" - local ostype="${OSTYPE:-}" - local package="${PACKAGE:-}" + # Get the version information. If a specific version wasn't set, generate it + # from the tag and VS Code version. + local vscode_version=${VSCODE_VERSION:-1.41.1} + local code_server_version=${VERSION:-2.${TRAVIS_TAG:-${DRONE_TAG:-daily}}-vsc$vscode_version} - if [[ -z "${codeServerVersion}" ]] ; then - codeServerVersion="2.${TRAVIS_TAG:-${DRONE_TAG:-daily}}" + # Remove everything that isn't the current VS Code source for caching + # (otherwise the cache will contain old versions). + if [[ -d "source/vscode-$vscode_version-source" ]] ; then + mv "source/vscode-$vscode_version-source" "vscode-$vscode_version-source" + fi + rm -rf source/vscode-*-source + if [[ -d "vscode-$vscode_version-source" ]] ; then + mv "vscode-$vscode_version-source" "source/vscode-$vscode_version-source" fi - local branch="${TRAVIS_BRANCH:-DRONE_BRANCH}" - if [[ $branch == "master" ]] ; then + # Only minify and package on tags since that's when releases are pushed. + if [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]] ; then export MINIFY="true" export PACKAGE="true" fi - if [[ "${ostype}" == "darwin"* ]]; then - local-build - else - docker-build - fi + function run-yarn() { + yarn "$1" "$vscode_version" "$code_server_version" + } + + run-yarn build + [[ -n ${PACKAGE:-} || -n ${BINARY:-} ]] && run-yarn binary + [[ -n ${PACKAGE:-} ]] && run-yarn package } main "$@" diff --git a/scripts/ci.dockerfile b/scripts/ci.dockerfile index 1b41c735a..dbb146c89 100644 --- a/scripts/ci.dockerfile +++ b/scripts/ci.dockerfile @@ -1,4 +1,4 @@ -# We deploy with ubuntu so that devs have a familiar environment. +# We deploy with Ubuntu so that devs have a familiar environment. FROM ubuntu:18.04 RUN apt-get update && apt-get install -y \ @@ -22,9 +22,10 @@ RUN adduser --gecos '' --disabled-password coder && \ echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd USER coder -# We create first instead of just using WORKDIR as when WORKDIR creates, the -# user is root. +# Create first so these directories will be owned by coder instead of root +# (workdir and mounting appear to both default to root). RUN mkdir -p /home/coder/project +RUN mkdir -p /home/coder/.local/share/code-server WORKDIR /home/coder/project