Skip to content

Instantly share code, notes, and snippets.

@ghuntley
Created June 23, 2019 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghuntley/1ea51f4af5fd8031b3aab209fc4c3c06 to your computer and use it in GitHub Desktop.
Save ghuntley/1ea51f4af5fd8031b3aab209fc4c3c06 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Copyright (c) 2019. All rights reserved.
# SPDX-License-Identifier: Proprietary
#
set -euo pipefail
docker pull codercom/code-server:latest
docker build -f ./Dockerfile -t localcodeserver .
FROM codercom/code-server:latest
EXPOSE 8443
VOLUME [ "${PWD}:/home/coder/project" ]
USER root
# Install the Azure CLI tools
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash
# Install docker
RUN apt-get -y install docker
# Install direnv
RUN apt-get -y install direnv
# 1. Create a fonts, downloads and assets directory for the container.
# 2. Install `git` for SCM, `make` for `curl`, `curl` for downloading files, `unzip` for ZIP files and `fontconfig` for managing fonts.
# 3. This is a simpler version of `nvm`, called `n`, that installs the LTS version of node.
RUN mkdir /home/coder/.fonts /home/coder/downloads /home/coder/assets \
&& apt-get install -y git make curl unzip fontconfig -y
# Font name and location on Google Drive.
# Move to `export GDRIVE_FILENAME=OperatorMonoCollection.zip;` in the script
ARG GDRIVE_FILENAME=OperatorMonoCollection.zip
ARG GDRIVE_FILEID=0B7Nsk2zJ4jK8UG82bHZSRTItYTA
# Download the fonts from Google Drive.
RUN curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=0B7Nsk2zJ4jK8UG82bHZSRTItYTA" > /dev/null \
&& curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=0B7Nsk2zJ4jK8UG82bHZSRTItYTA" -o OperatorMonoCollection.zip \
&& rm -rf ./cookie \
&& mv ${GDRIVE_FILENAME} /home/coder/downloads \
# Unzip the files into the `/home/coder/assets` directory.
&& unzip /home/coder/downloads/${GDRIVE_FILENAME} -d /home/coder/assets \
# Remove the `__MACOSX` surplus/garbage.
&& rm -rf /home/coder/assets/__MACOSX \
# Move all of the "Operator Mono" fonts into the shared `/home/coder/.fonts` directory
&& mv /home/coder/assets/Operator\ Mono\ Collection/Operator\ Mono/OperatorMono-* /home/coder/.fonts \
# Move all of the "Operator Pro" fonts into the shared `/home/coder/.fonts` directory
&& mv /home/coder/assets/Operator\ Mono\ Collection/Operator\ Pro/OperatorPro-* /home/coder/.fonts \
# Move all of the "Operator ScreenSmart" fonts into the shared `/home/coder/.fonts` directory
&& mv /home/coder/assets/Operator\ Mono\ Collection/Operator\ ScreenSmart/OperatorSSm-* /home/coder/.fonts
RUN chown -R coder:coder /home/coder
# Install Nix
RUN addgroup --system nixbld \
&& adduser coder nixbld \
&& mkdir -m 0755 /nix && chown coder /nix \
&& mkdir -p /etc/nix && echo 'sandbox = false' > /etc/nix/nix.conf
# Install Docker
RUN curl -fsSL https://get.docker.com -o get-docker.sh \
&& sudo sh get-docker.sh \
&& usermod -aG docker coder
RUN apt-get update \
&& apt-get install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils \
&& usermod -aG kvm coder \
&& usermod -aG kvm root \
&& usermod -aG libvirt coder \
&& usermod -aG libvirt root
# Install Nix
CMD /bin/bash -l
USER coder
ENV USER coder
WORKDIR /home/coder
RUN touch .bash_profile \
&& curl https://nixos.org/releases/nix/nix-2.2.1/install | sh
RUN echo 'eval "$(direnv hook bash)"' >> /home/coder/.bashrc
RUN echo '. /home/coder/.nix-profile/etc/profile.d/nix.sh' >> /home/coder/.bashrc
RUN echo 'eval `ssh-agent`' >> /home/coder/.bashrc
# Install visual studio code niceities
RUN sudo apt-get install silversearcher-ag
# Reset the font cache
#USER coder
#RUN fc-cache -f -v
#!/usr/bin/env bash
# Copyright (c) 2019. All rights reserved.
# SPDX-License-Identifier: Proprietary
#
#set -euo pipefail
./build.sh
export PID=`docker ps |grep code- | awk {'print $1'}`
docker stop ${PID}
docker rm ${PID}
export CONTAINER_ID=`docker run --privileged=true -d --restart always -it -p 127.0.0.1:8443:8443 -v /var/run/docker.sock:/var/run/docker.sock -v "/home/ghuntley/.gitconfig:/home/coder/.gitconfig" -v "/home/ghuntley/dropbox/:/home/coder/dropbox" localcodeserver --allow-http --no-auth --disable-telemetry`
docker cp ~/.ssh ${CONTAINER_ID}:/home/coder
docker ps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment