Archived
1
0

Push Docker using Linux build

Instead of doing a separate redundant build. The main problem was that
the files weren't being cached. There is probably a better way of
solving this but this seems to be the simplest for now.
This commit is contained in:
Asher 2019-10-22 18:43:21 -05:00
parent faae03da6b
commit 7f07b8f66c
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
2 changed files with 41 additions and 10 deletions

View File

@ -18,7 +18,7 @@ jobs:
- name: "Linux build" - name: "Linux build"
os: linux os: linux
dist: trusty dist: trusty
env: TARGET="linux" env: TARGET="linux" PUSH_DOCKER="true"
if: tag IS blank if: tag IS blank
script: scripts/ci.bash script: scripts/ci.bash
- name: "Alpine build" - name: "Alpine build"
@ -31,12 +31,6 @@ jobs:
os: osx os: osx
if: tag IS blank if: tag IS blank
script: travis_wait 40 scripts/ci.bash 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: git:
depth: 3 depth: 3
@ -46,7 +40,7 @@ before_deploy:
- git config --local user.name "$USER_NAME" - git config --local user.name "$USER_NAME"
- git config --local user.email "$USER_EMAIL" - git config --local user.email "$USER_EMAIL"
- if ! git tag "$TAG" "$TRAVIS_COMMIT" ; then echo "$TAG already exists"; fi - 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: deploy:
- provider: releases - provider: releases
@ -67,11 +61,11 @@ deploy:
- provider: script - provider: script
skip_cleanup: true 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: on:
repo: cdr/code-server repo: cdr/code-server
branch: master branch: master
condition: -n "$DOCKER_BUILD" condition: -n "$PUSH_DOCKER"
cache: cache:
yarn: true yarn: true

37
scripts/ci.dockerfile Normal file
View File

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