Merge pull request #433 from codercom/docker-fixes

Significantly improve the Dockerfile
This commit is contained in:
Anmol Sethi 2019-04-04 18:42:14 -05:00 committed by GitHub
commit 6737d3da18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 8 deletions

View File

@ -16,19 +16,30 @@ COPY . .
RUN yarn && NODE_ENV=production yarn task build:server:binary
# We deploy with ubuntu so that devs have a familiar environment.
FROM ubuntu:18.10
WORKDIR /root/project
COPY --from=0 /src/packages/server/cli-linux-x64 /usr/local/bin/code-server
EXPOSE 8443
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y \
openssl \
net-tools \
git \
locales
locales \
sudo \
dumb-init
RUN locale-gen en_US.UTF-8
# We unfortunately 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 LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
ENTRYPOINT ["code-server"]
RUN adduser --gecos '' --disabled-password coder
RUN 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
COPY --from=0 /src/packages/server/cli-linux-x64 /usr/local/bin/code-server
EXPOSE 8443
ENTRYPOINT ["dumb-init", "code-server"]

View File

@ -9,7 +9,7 @@
Try it out:
```bash
docker run -t -p 127.0.0.1:8443:8443 -v "${PWD}:/root/project" codercom/code-server code-server --allow-http --no-auth
docker run -it -p 127.0.0.1:8443:8443 -v "${PWD}:/home/coder/project" codercom/code-server:1.621 --allow-http --no-auth
```
- Code on your Chromebook, tablet, and laptop with a consistent dev environment.