diff --git a/.travis.yml b/.travis.yml index a0ed2dc9..ab6047f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ jobs: - name: "Linux build" os: linux dist: trusty - env: TARGET="linux" + env: TARGET="linux" PUSH_DOCKER="true" if: tag IS blank script: scripts/ci.bash - name: "Alpine build" @@ -31,12 +31,6 @@ jobs: os: osx if: tag IS blank script: travis_wait 40 scripts/ci.bash - - name: "Docker build" - os: linux - dist: trusty - env: DOCKER_BUILD="true" - if: branch == master AND tag IS blank - script: docker build --build-arg githubToken="$GITHUB_TOKEN" --build-arg codeServerVersion="$VERSION" --build-arg vscodeVersion="$VSCODE_VERSION" -t codercom/code-server:"$TAG" -t codercom/code-server:v2 . git: depth: 3 @@ -46,7 +40,7 @@ before_deploy: - git config --local user.name "$USER_NAME" - git config --local user.email "$USER_EMAIL" - if ! git tag "$TAG" "$TRAVIS_COMMIT" ; then echo "$TAG already exists"; fi - - if [[ -n "$DOCKER_BUILD" ]] ; then echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin ; fi + - if [[ -n "$PUSH_DOCKER" ]] ; then echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin ; fi deploy: - provider: releases @@ -67,11 +61,11 @@ deploy: - provider: script skip_cleanup: true - script: docker push codercom/code-server:"$TAG" ; docker push codercom/code-server:v2 + script: docker build -f ./scripts/ci.dockerfile --build-arg -t codercom/code-server:"$TAG" -t codercom/code-server:v2 . && docker push codercom/code-server:"$TAG" && docker push codercom/code-server:v2 on: repo: cdr/code-server branch: master - condition: -n "$DOCKER_BUILD" + condition: -n "$PUSH_DOCKER" cache: yarn: true diff --git a/scripts/ci.dockerfile b/scripts/ci.dockerfile new file mode 100644 index 00000000..eba212f8 --- /dev/null +++ b/scripts/ci.dockerfile @@ -0,0 +1,37 @@ +# We deploy with ubuntu so that devs have a familiar environment. +FROM ubuntu:18.04 + +RUN apt-get update && apt-get install -y \ + openssl \ + net-tools \ + git \ + locales \ + sudo \ + dumb-init \ + vim \ + curl \ + wget + +RUN locale-gen en_US.UTF-8 +# We cannot use update-locale because docker will not use the env variables +# configured in /etc/default/locale so we need to set it manually. +ENV LC_ALL=en_US.UTF-8 + +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. +RUN mkdir -p /home/coder/project + +WORKDIR /home/coder/project + +# This ensures we have a volume mounted even if the user forgot to do bind +# mount. So that they do not lose their data if they delete the container. +VOLUME [ "/home/coder/project" ] + +COPY ./binaries/code-server* /usr/local/bin/code-server +EXPOSE 8080 + +ENTRYPOINT ["dumb-init", "code-server", "--host", "0.0.0.0"]