Skip to content

Commit 7f07b8f

Browse files
committed
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.
1 parent faae03d commit 7f07b8f

File tree

2 files changed

+41
-10
lines changed

2 files changed

+41
-10
lines changed

.travis.yml

+4-10
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: "Linux build"
1919
os: linux
2020
dist: trusty
21-
env: TARGET="linux"
21+
env: TARGET="linux" PUSH_DOCKER="true"
2222
if: tag IS blank
2323
script: scripts/ci.bash
2424
- name: "Alpine build"
@@ -31,12 +31,6 @@ jobs:
3131
os: osx
3232
if: tag IS blank
3333
script: travis_wait 40 scripts/ci.bash
34-
- name: "Docker build"
35-
os: linux
36-
dist: trusty
37-
env: DOCKER_BUILD="true"
38-
if: branch == master AND tag IS blank
39-
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 .
4034

4135
git:
4236
depth: 3
@@ -46,7 +40,7 @@ before_deploy:
4640
- git config --local user.name "$USER_NAME"
4741
- git config --local user.email "$USER_EMAIL"
4842
- if ! git tag "$TAG" "$TRAVIS_COMMIT" ; then echo "$TAG already exists"; fi
49-
- if [[ -n "$DOCKER_BUILD" ]] ; then echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin ; fi
43+
- if [[ -n "$PUSH_DOCKER" ]] ; then echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin ; fi
5044

5145
deploy:
5246
- provider: releases
@@ -67,11 +61,11 @@ deploy:
6761

6862
- provider: script
6963
skip_cleanup: true
70-
script: docker push codercom/code-server:"$TAG" ; docker push codercom/code-server:v2
64+
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
7165
on:
7266
repo: cdr/code-server
7367
branch: master
74-
condition: -n "$DOCKER_BUILD"
68+
condition: -n "$PUSH_DOCKER"
7569

7670
cache:
7771
yarn: true

scripts/ci.dockerfile

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# We deploy with ubuntu so that devs have a familiar environment.
2+
FROM ubuntu:18.04
3+
4+
RUN apt-get update && apt-get install -y \
5+
openssl \
6+
net-tools \
7+
git \
8+
locales \
9+
sudo \
10+
dumb-init \
11+
vim \
12+
curl \
13+
wget
14+
15+
RUN locale-gen en_US.UTF-8
16+
# We cannot use update-locale because docker will not use the env variables
17+
# configured in /etc/default/locale so we need to set it manually.
18+
ENV LC_ALL=en_US.UTF-8
19+
20+
RUN adduser --gecos '' --disabled-password coder && \
21+
echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd
22+
23+
USER coder
24+
# We create first instead of just using WORKDIR as when WORKDIR creates, the
25+
# user is root.
26+
RUN mkdir -p /home/coder/project
27+
28+
WORKDIR /home/coder/project
29+
30+
# This ensures we have a volume mounted even if the user forgot to do bind
31+
# mount. So that they do not lose their data if they delete the container.
32+
VOLUME [ "/home/coder/project" ]
33+
34+
COPY ./binaries/code-server* /usr/local/bin/code-server
35+
EXPOSE 8080
36+
37+
ENTRYPOINT ["dumb-init", "code-server", "--host", "0.0.0.0"]

0 commit comments

Comments
 (0)