Skip to content
Snippets Groups Projects
Dockerfile 3.27 KiB
Newer Older
thelamer's avatar
thelamer committed
FROM ghcr.io/linuxserver/baseimage-ubuntu:bionic
aptalca's avatar
aptalca committed

ARG CODE_RELEASE

# environment settings
ENV HOME="/config"

RUN \
Roxedus's avatar
Roxedus committed
  echo "**** install node repo ****" && \
  apt-get update && \
  apt-get install -y \
    gnupg && \
  curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
Roxedus's avatar
Roxedus committed
  echo 'deb https://deb.nodesource.com/node_14.x bionic main' \
Roxedus's avatar
Roxedus committed
    > /etc/apt/sources.list.d/nodesource.list && \
  curl -s https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
  echo 'deb https://dl.yarnpkg.com/debian/ stable main' \
    > /etc/apt/sources.list.d/yarn.list && \
  echo "**** install build dependencies ****" && \
  apt-get update && \
  apt-get install -y \
    build-essential \
    libx11-dev \
    libxkbfile-dev \
    libsecret-1-dev \
    pkg-config && \
  echo "**** install runtime dependencies ****" && \
  apt-get install -y \
    git \
    jq \
    nano \
    net-tools \
    nodejs \
    sudo \
    yarn && \
  echo "**** install code-server ****" && \
  if [ -z ${CODE_RELEASE+x} ]; then \
    CODE_RELEASE=$(curl -sX GET https://registry.yarnpkg.com/code-server \
    | jq -r '."dist-tags".latest' | sed 's|^|v|'); \
  fi && \
  CODE_VERSION=$(echo "$CODE_RELEASE" | awk '{print substr($1,2); }') && \
  yarn config set network-timeout 600000 -g && \
  yarn --production --verbose --frozen-lockfile global add code-server@"$CODE_VERSION" && \
  yarn cache clean && \
  echo "**** clean up ****" && \
  apt-get purge --auto-remove -y \
    build-essential \
    libx11-dev \
    libxkbfile-dev \
    libsecret-1-dev \
    pkg-config && \
  apt-get clean && \
  rm -rf \
    /tmp/* \
    /var/lib/apt/lists/* \
    /var/tmp/*
aptalca's avatar
aptalca committed

# add local files
COPY /root /

# Install on-my-zsh
RUN chsh --shell /bin/zsh abc && \ 
    sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" && \
    git clone --branch master --single-branch --depth 1 \
        "https://github.com/zsh-users/zsh-autosuggestions.git" \
        /config/.oh-my-zsh/plugins/zsh-autosuggestions && \
    echo "source /config/.oh-my-zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" \ 
        >> /config/.zshrc && \
    git clone --branch master --single-branch --depth 1 \
        "https://github.com/zsh-users/zsh-syntax-highlighting.git" \
        /config/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting && \
    sed -i 's/plugins=(.*/plugins=(git vscode)/' /config/.zshrc && \
    echo 'PS1="%B%F{blue}%~:%f%b "'           >>/config/.zshrc

# The SSH key pair is stored in /config
RUN mkdir /root/.ssh && \
    echo "Host gitlab-student.centralesupelec.fr " >  /root/.ssh/config && \
    echo "  PreferredAuthentications publickey"    >> /root/.ssh/config && \
    echo "  IdentityFile /config/.ssh/id_ed25519"  >> /root/.ssh/config && \
    mkdir /config/.ssh

# VSCode extension for Python
RUN /usr/local/bin/code-server --install-extension ms-python.python

# /config will be a docker volume, initially empty
# wrapper_script will do the copy from /init-config
RUN chown -R abc:abc /config && \
    mv /config /init-config && \
    mkdir -p /config/workspace && \
    chown -R abc:abc /config

# Will be entry point
COPY wrapper_script.sh /usr/local/lib/wrapper_script.sh

# launch
ENTRYPOINT ["/bin/bash", "/usr/local/lib/wrapper_script.sh"]

aptalca's avatar
aptalca committed
# ports and volumes
EXPOSE 8443