From 6a8181b1c37f99b68aed2046abbe7c6381249187 Mon Sep 17 00:00:00 2001 From: Manuel Alejandro de Brito Fontes Date: Thu, 25 Feb 2021 12:26:20 -0300 Subject: [PATCH] Extract workspace-base from workspace-full --- .circleci/config.yml | 32 ++++++++++++-- base/Dockerfile | 50 +++++++++++++++++++++ base/install-packages | 30 +++++++++++++ dart/Dockerfile | 12 ++--- flutter/Dockerfile | 4 +- flutter/android.Dockerfile | 24 +++++----- full-vnc/Dockerfile | 4 +- full/Dockerfile | 89 +++++++------------------------------- mysql/Dockerfile | 8 ++-- postgres/Dockerfile | 5 +-- rethinkdb/Dockerfile | 26 ----------- wasm/Dockerfile | 2 +- 12 files changed, 145 insertions(+), 141 deletions(-) create mode 100644 base/Dockerfile create mode 100755 base/install-packages delete mode 100644 rethinkdb/Dockerfile diff --git a/.circleci/config.yml b/.circleci/config.yml index 054bacdaf..91c5bd14c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,14 +1,35 @@ version: 2.0 jobs: + workspace-base: + docker: + - image: docker:stable + steps: + - checkout + - setup_remote_docker + - attach_workspace: + at: . + - run: + command: | + ./.circleci/build_image.sh base/Dockerfile gitpod/workspace-base + docker save gitpod/workspace-base -o workspace-base.tar + no_output_timeout: 20m + - persist_to_workspace: + root: . + paths: + - workspace-base.tar + workspace-full: docker: - image: csweichel/dazzle:latest steps: - checkout - setup_remote_docker + - attach_workspace: + at: . - run: command: | + docker load -i workspace-base.tar ./.circleci/dazzle_build_image.sh full/Dockerfile gitpod/workspace-full workspace-full.tar no_output_timeout: 30m - run: @@ -172,7 +193,10 @@ workflows: version: 2 build-and-deploy: jobs: - - workspace-full + - workspace-base + - workspace-full: + requires: + - workspace-base - workspace-full-vnc: requires: - workspace-full @@ -193,13 +217,13 @@ workflows: - workspace-full - workspace-mongodb: requires: - - workspace-full + - workspace-full - workspace-flutter: requires: - - workspace-full + - workspace-full - workspace-gecko: requires: - workspace-full-vnc - workspace-wasm: requires: - - workspace-full + - workspace-full diff --git a/base/Dockerfile b/base/Dockerfile new file mode 100644 index 000000000..77db9c0c6 --- /dev/null +++ b/base/Dockerfile @@ -0,0 +1,50 @@ +FROM buildpack-deps:focal + +COPY install-packages /usr/bin + +### base ### +RUN yes | unminimize \ + && install-packages \ + zip \ + unzip \ + bash-completion \ + build-essential \ + ninja-build \ + htop \ + jq \ + less \ + locales \ + man-db \ + nano \ + software-properties-common \ + sudo \ + time \ + vim \ + multitail \ + lsof \ + ssl-cert \ + && locale-gen en_US.UTF-8 + +ENV LANG=en_US.UTF-8 + +### Git ### +RUN add-apt-repository -y ppa:git-core/ppa \ + && install-packages git + +### Gitpod user ### +# '-l': see https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user +RUN useradd -l -u 33333 -G sudo -md /home/gitpod -s /bin/bash -p gitpod gitpod \ + # passwordless sudo for users in the 'sudo' group + && sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers +ENV HOME=/home/gitpod +WORKDIR $HOME +# custom Bash prompt +RUN { echo && echo "PS1='\[\e]0;\u \w\a\]\[\033[01;32m\]\u\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\] \\\$ '" ; } >> .bashrc + +### Gitpod user (2) ### +USER gitpod +# use sudo so that user does not get sudo usage info on (the first) login +RUN sudo echo "Running 'sudo' for Gitpod: success" && \ + # create .bashrc.d folder and source it in the bashrc + mkdir /home/gitpod/.bashrc.d && \ + (echo; echo "for i in \$(ls \$HOME/.bashrc.d/*); do source \$i; done"; echo) >> /home/gitpod/.bashrc diff --git a/base/install-packages b/base/install-packages new file mode 100755 index 000000000..75e7e5fb3 --- /dev/null +++ b/base/install-packages @@ -0,0 +1,30 @@ +#!/bin/sh + +set -o errexit + +if [ $# = 0 ]; then + echo >&2 "No packages specified" + exit 1 +fi + +DEBIAN_FRONTEND=noninteractive + +DAZZLE_MARKS="/var/lib/apt/dazzle-marks/" +TIMESTAMP=$(date +%s) + +if [ ! -d "${DAZZLE_MARKS}" ]; then + mkdir -p "${DAZZLE_MARKS}" +fi + +apt-get update +apt-get install -yq --no-install-recommends $@ + +cp /var/lib/dpkg/status "${DAZZLE_MARKS}/${TIMESTAMP}.status" + +apt-get clean -y + +rm -rf \ + /var/cache/debconf/* \ + /var/lib/apt/lists/* \ + /tmp/* \ + /var/tmp/* diff --git a/dart/Dockerfile b/dart/Dockerfile index cec9b3ba5..a9b8b99f5 100644 --- a/dart/Dockerfile +++ b/dart/Dockerfile @@ -1,15 +1,9 @@ FROM gitpod/workspace-full - ENV PATH=/usr/lib/dart/bin:$PATH USER root -RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ - curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list && \ - apt-get update && \ - apt-get -y install build-essential dart libkrb5-dev gcc make && \ - apt-get clean && \ - apt-get -y autoremove && \ - apt-get -y clean && \ - rm -rf /var/lib/apt/lists/*; \ No newline at end of file +RUN curl -fsSL https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ + && curl -fsSL https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list \ + && install-packages build-essential dart libkrb5-dev gcc make diff --git a/flutter/Dockerfile b/flutter/Dockerfile index 741816ddb..fe53ac4f1 100644 --- a/flutter/Dockerfile +++ b/flutter/Dockerfile @@ -12,7 +12,7 @@ RUN set -ex; \ RUN set -ex; \ mkdir ~/development; \ cd ~/development; \ - git clone --depth 1 https://github.com/flutter/flutter.git -b stable + git clone --depth 1 https://github.com/flutter/flutter.git -b stable --no-single-branch ENV PATH="$PATH:/home/gitpod/development/flutter/bin" @@ -20,4 +20,4 @@ RUN set -ex; \ flutter channel beta; \ flutter upgrade; \ flutter config --enable-web; \ - flutter precache \ No newline at end of file + flutter precache diff --git a/flutter/android.Dockerfile b/flutter/android.Dockerfile index 608be37cb..8b896264e 100644 --- a/flutter/android.Dockerfile +++ b/flutter/android.Dockerfile @@ -1,25 +1,21 @@ FROM gitpod/workspace-full-vnc - ENV ANDROID_HOME=/home/gitpod/android-sdk-linux \ FLUTTER_HOME=/home/gitpod/flutter \ PATH=/usr/lib/dart/bin:$FLUTTER_HOME/bin:$ANDROID_HOME/tools:$PATH USER root -RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ - curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list && \ - apt-get update && \ - apt-get -y install build-essential dart libkrb5-dev gcc make gradle android-tools-adb android-tools-fastboot && \ - apt-get clean && \ - apt-get -y autoremove && \ - apt-get -y clean && \ - rm -rf /var/lib/apt/lists/*; +RUN curl -fsSL https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ + && curl -fsSL https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list \ + && install-packages build-essential dart libkrb5-dev gcc make gradle android-tools-adb android-tools-fastboot USER gitpod -RUN cd /home/gitpod && wget -qO flutter_sdk.tar.xz https://storage.googleapis.com/flutter_infra/releases/stable/linux/flutter_linux_v1.0.0-stable.tar.xz \ - && tar -xvf flutter_sdk.tar.xz && rm flutter_sdk.tar.xz && \ - wget -qO android_studio.zip https://dl.google.com/dl/android/studio/ide-zips/3.3.0.20/android-studio-ide-182.5199772-linux.zip && \ - unzip android_studio.zip && rm -f android_studio.zip && \ - wget --output-document=android-sdk.tgz --quiet http://dl.google.com/android/android-sdk_r26.1.1-linux.tgz && tar -xvf android-sdk.tgz && rm android-sdk.tgz; \ No newline at end of file +RUN cd /home/gitpod \ + && wget -qO flutter_sdk.tar.xz https://storage.googleapis.com/flutter_infra/releases/stable/linux/flutter_linux_v1.0.0-stable.tar.xz \ + && tar -xvf flutter_sdk.tar.xz && rm flutter_sdk.tar.xz \ + && wget -qO android_studio.zip https://dl.google.com/dl/android/studio/ide-zips/3.3.0.20/android-studio-ide-182.5199772-linux.zip \ + && unzip android_studio.zip && rm -f android_studio.zip \ + && wget --output-document=android-sdk.tgz --quiet http://dl.google.com/android/android-sdk_r26.1.1-linux.tgz \ + && tar -xvf android-sdk.tgz && rm android-sdk.tgz diff --git a/full-vnc/Dockerfile b/full-vnc/Dockerfile index ffa85885f..d208c08ab 100644 --- a/full-vnc/Dockerfile +++ b/full-vnc/Dockerfile @@ -1,9 +1,7 @@ FROM gitpod/workspace-full:latest # Install Xvfb, JavaFX-helpers and Openbox window manager -RUN sudo apt-get update && \ - sudo apt-get install -yq xvfb x11vnc xterm openjfx libopenjfx-java openbox && \ - sudo rm -rf /var/lib/apt/lists/* +RUN sudo install-packages xvfb x11vnc xterm openjfx libopenjfx-java openbox # Overwrite this env variable to use a different window manager ENV WINDOW_MANAGER="openbox" diff --git a/full/Dockerfile b/full/Dockerfile index 753f0bd8d..3d91399b5 100644 --- a/full/Dockerfile +++ b/full/Dockerfile @@ -1,54 +1,6 @@ -FROM buildpack-deps:focal +FROM gitpod/workspace-base:latest -### base ### -RUN yes | unminimize \ - && apt-get install -yq \ - zip \ - unzip \ - bash-completion \ - build-essential \ - ninja-build \ - htop \ - jq \ - less \ - locales \ - man-db \ - nano \ - software-properties-common \ - sudo \ - time \ - vim \ - multitail \ - lsof \ - ssl-cert \ - && locale-gen en_US.UTF-8 \ - && mkdir /var/lib/apt/dazzle-marks \ - && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* - -ENV LANG=en_US.UTF-8 - -### Git ### -RUN add-apt-repository -y ppa:git-core/ppa \ - && apt-get install -yq git \ - && rm -rf /var/lib/apt/lists/* - -### Gitpod user ### -# '-l': see https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user -RUN useradd -l -u 33333 -G sudo -md /home/gitpod -s /bin/bash -p gitpod gitpod \ - # passwordless sudo for users in the 'sudo' group - && sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers -ENV HOME=/home/gitpod -WORKDIR $HOME -# custom Bash prompt -RUN { echo && echo "PS1='\[\e]0;\u \w\a\]\[\033[01;32m\]\u\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\] \\\$ '" ; } >> .bashrc - -### Gitpod user (2) ### -USER gitpod -# use sudo so that user does not get sudo usage info on (the first) login -RUN sudo echo "Running 'sudo' for Gitpod: success" && \ - # create .bashrc.d folder and source it in the bashrc - mkdir /home/gitpod/.bashrc.d && \ - (echo; echo "for i in \$(ls \$HOME/.bashrc.d/*); do source \$i; done"; echo) >> /home/gitpod/.bashrc +RUN echo "ws full starts" ### Install C/C++ compiler and associated tools ### LABEL dazzle/layer=lang-c @@ -59,22 +11,19 @@ ENV TRIGGER_REBUILD=3 RUN curl -o /var/lib/apt/dazzle-marks/llvm.gpg -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key \ && apt-key add /var/lib/apt/dazzle-marks/llvm.gpg \ && echo "deb https://apt.llvm.org/focal/ llvm-toolchain-focal main" >> /etc/apt/sources.list.d/llvm.list \ - && apt-get update \ - && apt-get install -yq \ + && install-packages \ clang \ clangd \ clang-format \ clang-tidy \ gdb \ - lld \ - && cp /var/lib/dpkg/status /var/lib/apt/dazzle-marks/lang-c.status \ - && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* + lld ### Apache, PHP and Nginx ### LABEL dazzle/layer=tool-nginx LABEL dazzle/test=tests/lang-php.yaml USER root -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq \ +RUN install-packages \ apache2 \ nginx \ nginx-extras \ @@ -96,9 +45,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq \ php-tokenizer \ php-xml \ php-zip \ - && cp /var/lib/dpkg/status /var/lib/apt/dazzle-marks/tool-nginx.status \ - && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* \ - && mkdir /var/run/nginx \ + && mkdir -p /var/run/nginx /var/log/apache2 /var/log/nginx/ \ && ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load \ && chown -R gitpod:gitpod /etc/apache2 /var/run/apache2 /var/lock/apache2 /var/log/apache2 \ && chown -R gitpod:gitpod /etc/nginx /var/run/nginx /var/lib/nginx/ /var/log/nginx/ @@ -106,8 +53,8 @@ COPY --chown=gitpod:gitpod apache2/ /etc/apache2/ COPY --chown=gitpod:gitpod nginx /etc/nginx/ ## The directory relative to your git repository that will be served by Apache / Nginx -ENV APACHE_DOCROOT_IN_REPO="public" \ - NGINX_DOCROOT_IN_REPO="public" +ENV APACHE_DOCROOT_IN_REPO="public" +ENV NGINX_DOCROOT_IN_REPO="public" ### Homebrew ### LABEL dazzle/layer=tool-brew @@ -120,7 +67,7 @@ ENV PATH="$PATH:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin/" MANPATH="$MANPATH:/home/linuxbrew/.linuxbrew/share/man" \ INFOPATH="$INFOPATH:/home/linuxbrew/.linuxbrew/share/info" \ HOMEBREW_NO_AUTO_UPDATE=1 -RUN sudo apt-get remove -y cmake \ +RUN sudo apt remove -y cmake \ && brew install cmake ### Go ### @@ -202,9 +149,8 @@ ENV PATH=$PATH:/home/gitpod/.nvm/versions/node/v${NODE_VERSION}/bin LABEL dazzle/layer=lang-python LABEL dazzle/test=tests/lang-python.yaml USER gitpod -RUN sudo apt-get update && \ - sudo apt-get install -y python3-pip && \ - sudo rm -rf /var/lib/apt/lists/* +RUN sudo install-packages python3-pip + ENV PATH=$HOME/.pyenv/bin:$HOME/.pyenv/shims:$PATH RUN curl -fsSL https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash \ && { echo; \ @@ -227,8 +173,8 @@ RUN curl -fsSL https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-ins LABEL dazzle/layer=lang-ruby LABEL dazzle/test=tests/lang-ruby.yaml USER gitpod -RUN curl -sSL https://rvm.io/mpapis.asc | gpg --import - \ - && curl -sSL https://rvm.io/pkuczynski.asc | gpg --import - \ +RUN curl -fsSL https://rvm.io/mpapis.asc | gpg --import - \ + && curl -fsSL https://rvm.io/pkuczynski.asc | gpg --import - \ && curl -fsSL https://get.rvm.io | bash -s stable \ && bash -lc " \ rvm requirements \ @@ -265,12 +211,9 @@ USER root RUN curl -o /var/lib/apt/dazzle-marks/docker.gpg -fsSL https://download.docker.com/linux/ubuntu/gpg \ && apt-key add /var/lib/apt/dazzle-marks/docker.gpg \ && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \ - && apt-get update \ - && apt-get install -y docker-ce docker-ce-cli containerd.io slirp4netns docker-compose \ - && cp /var/lib/dpkg/status /var/lib/apt/dazzle-marks/tool-docker.status \ - && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* + && install-packages docker-ce=5:19.03.15~3-0~ubuntu-focal docker-ce-cli=5:19.03.15~3-0~ubuntu-focal containerd.io slirp4netns docker-compose # https://github.com/wagoodman/dive -RUN curl -o /tmp/dive.deb -L https://github.com/wagoodman/dive/releases/download/v0.9.2/dive_0.9.2_linux_amd64.deb \ +RUN curl -o /tmp/dive.deb -fsSL https://github.com/wagoodman/dive/releases/download/v0.9.2/dive_0.9.2_linux_amd64.deb \ && apt install /tmp/dive.deb \ && rm /tmp/dive.deb @@ -278,7 +221,7 @@ RUN curl -o /tmp/dive.deb -L https://github.com/wagoodman/dive/releases/download LABEL dazzle/layer=dazzle-prologue LABEL dazzle/test=tests/prologue.yaml USER root -RUN curl -o /usr/bin/dazzle-util -L https://github.com/csweichel/dazzle/releases/download/v0.0.3/dazzle-util_0.0.3_Linux_x86_64 \ +RUN curl -o /usr/bin/dazzle-util -fsSL https://github.com/csweichel/dazzle/releases/download/v0.0.3/dazzle-util_0.0.3_Linux_x86_64 \ && chmod +x /usr/bin/dazzle-util # merge dpkg status files RUN cp /var/lib/dpkg/status /tmp/dpkg-status \ diff --git a/mysql/Dockerfile b/mysql/Dockerfile index 6659a0300..e084a45d1 100644 --- a/mysql/Dockerfile +++ b/mysql/Dockerfile @@ -3,10 +3,8 @@ FROM gitpod/workspace-full:latest USER root # Install MySQL -RUN apt-get update \ - && apt-get install -y mysql-server \ - && apt-get clean && rm -rf /var/cache/apt/* /var/lib/apt/lists/* /tmp/* \ - && mkdir /var/run/mysqld \ +RUN install-packages mysql-server \ + && mkdir -p /var/run/mysqld /var/log/mysql \ && chown -R gitpod:gitpod /etc/mysql /var/run/mysqld /var/log/mysql /var/lib/mysql /var/lib/mysql-files /var/lib/mysql-keyring /var/lib/mysql-upgrade # Install our own MySQL config @@ -19,4 +17,4 @@ COPY mysql-bashrc-launch.sh /etc/mysql/mysql-bashrc-launch.sh USER gitpod -RUN echo "/etc/mysql/mysql-bashrc-launch.sh" >> ~/.bashrc \ No newline at end of file +RUN echo "/etc/mysql/mysql-bashrc-launch.sh" >> ~/.bashrc diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 84a783e24..2839a9f86 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -1,10 +1,7 @@ FROM gitpod/workspace-full:latest # Install PostgreSQL -RUN sudo apt-get update \ - && sudo apt-get install -y postgresql-12 postgresql-contrib-12 \ - && sudo apt-get clean \ - && sudo rm -rf /var/cache/apt/* /var/lib/apt/lists/* /tmp/* +RUN sudo install-packages postgresql-12 postgresql-contrib-12 # Setup PostgreSQL server for user gitpod ENV PATH="$PATH:/usr/lib/postgresql/12/bin" diff --git a/rethinkdb/Dockerfile b/rethinkdb/Dockerfile deleted file mode 100644 index 58aa59da5..000000000 --- a/rethinkdb/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -# DEPRECATED - -FROM gitpod/workspace-full - -# Install RethinkDB build dependencies. -# Source: https://rethinkdb.com/docs/install/ubuntu/#compile-from-source -RUN sudo apt-get update \ - && sudo apt-get install -y \ - protobuf-compiler \ - libprotobuf-dev \ - libboost-all-dev \ - libncurses5-dev \ - libjemalloc-dev \ - libssl1.0-dev \ - && sudo rm -rf /var/lib/apt/lists/* - -# Build and install RethinkDB from source. -RUN mkdir -p /tmp/rethinkdb \ - && cd /tmp/rethinkdb \ - && wget -qOrethinkdb.tgz https://download.rethinkdb.com/dist/rethinkdb-2.3.6.tgz \ - && tar xf rethinkdb.tgz \ - && cd rethinkdb-* \ - && ./configure --allow-fetch CXX=clang++-10 \ - && make -j`nproc` \ - && sudo make install \ - && sudo rm -rf /tmp/rethinkdb diff --git a/wasm/Dockerfile b/wasm/Dockerfile index edc681888..035b77108 100644 --- a/wasm/Dockerfile +++ b/wasm/Dockerfile @@ -1,7 +1,7 @@ FROM gitpod/workspace-full RUN bash -cl "cargo install wasm-pack cargo-wasm cargo-generate \ - && curl \"https://wasmtime.dev/install.sh\" -sSf | bash; \ + && curl -fsSL https://wasmtime.dev/install.sh | bash; \ rustup target add wasm32-wasi" RUN mkdir /tmp/wasm-sdk \