From 1a91588c424ec249f8c3c8aef783eea32c3cb6e3 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Tue, 18 Feb 2020 13:06:18 -0500 Subject: [PATCH] Add docker image pushing --- .travis.yml | 12 +++++++++--- ci/image/run.sh | 2 ++ ci/release-image/.gitignore | 1 - ci/release-image/Dockerfile | 2 +- ci/release-image/push.sh | 22 ++++++++++++++++++++++ 5 files changed, 34 insertions(+), 5 deletions(-) delete mode 100644 ci/release-image/.gitignore create mode 100755 ci/release-image/push.sh diff --git a/.travis.yml b/.travis.yml index b67ccc628..603b00a28 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,20 +12,26 @@ jobs: - stage: Release name: Linux Release - script: travis_wait 60 ./ci/image/run.sh "yarn && yarn vscode && ci/release.sh" + script: + - travis_wait 60 ./ci/image/run.sh "yarn && yarn vscode && ci/release.sh" + - ./ci/release-image/push.sh - name: Linux ARM64 Release - script: travis_wait 60 ./ci/image/run.sh "yarn && yarn vscode && ci/release.sh" + script: + - travis_wait 60 ./ci/image/run.sh "yarn && yarn vscode && ci/release.sh" + - ./ci/release-image/push.sh arch: arm64 - name: MacOS Release os: osx language: node_js node_js: 12 script: yarn && yarn vscode && travis_wait 60 ci/release.sh + - name: Docker Release + script: ./ci/release-image/push.sh stages: - name: Code - name: Release - if: $TRAVIS_TAG != "" + if: env(TRAVIS_TAG) IS present deploy: - provider: releases diff --git a/ci/image/run.sh b/ci/image/run.sh index 3ac16e5ab..6dd3f2613 100755 --- a/ci/image/run.sh +++ b/ci/image/run.sh @@ -4,6 +4,8 @@ set -euo pipefail main() { cd "$(dirname "$0")/../.." + + docker build ci/image imageTag="$(docker build -q ci/image)" docker run -t --rm -e CI -e GITHUB_TOKEN -v "$(yarn cache dir):/usr/local/share/.cache/yarn/v6" -v "$PWD:/repo" -w /repo "$imageTag" "$*" } diff --git a/ci/release-image/.gitignore b/ci/release-image/.gitignore deleted file mode 100644 index c9cabf531..000000000 --- a/ci/release-image/.gitignore +++ /dev/null @@ -1 +0,0 @@ -code-server*.tar.gz diff --git a/ci/release-image/Dockerfile b/ci/release-image/Dockerfile index 751230e0f..95d755878 100644 --- a/ci/release-image/Dockerfile +++ b/ci/release-image/Dockerfile @@ -3,7 +3,7 @@ FROM debian:10 RUN apt-get update RUN apt-get install -y curl -COPY code-server*.tar.gz /tmp +COPY release/code-server*.tar.gz /tmp RUN cd /tmp && tar -xzf code-server*.tar.gz && \ cp code-server*/code-server /usr/local/bin/code-server RUN rm -rf /tmp/* diff --git a/ci/release-image/push.sh b/ci/release-image/push.sh new file mode 100755 index 000000000..88924612a --- /dev/null +++ b/ci/release-image/push.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -euo pipefail + +main() { + cd "$(dirname "$0")/../.." + + if [[ ${CI:-} ]]; then + echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + fi + + imageTag="codercom/code-server:$VERSION" + latest="codercom/code-server:latest" + if [[ $TRAVIS_CPU_ARCH == "arm64" ]]; then + imageTag+="-arm64" + latest="codercom/code-server:arm64" + fi + docker build -t "$imageTag" -t "$latest" -f ./ci/release-image/Dockerfile + docker push codercom/code-server +} + +main "$@"