Remove unused Docker step from CI script

This commit is contained in:
Asher 2020-01-14 15:06:49 -06:00
parent 42bddce21f
commit 174cb2f8a9
No known key found for this signature in database
GPG key ID: D63C1EF81242354A
7 changed files with 40 additions and 87 deletions

View file

@ -9,4 +9,4 @@ doc
LICENSE
README.md
node_modules
release
release

View file

@ -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

View file

@ -35,4 +35,4 @@ cache:
timeout: 1000
yarn: true
directories:
- source/vscode-1.41.1-source
- source

View file

@ -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

2
scripts/cacher.sh Normal file → Executable file
View file

@ -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() {

View file

@ -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 "$@"

View file

@ -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