Skip to content

Commit

Permalink
Extract workspace-base from workspace-full
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Feb 25, 2021
1 parent 310793c commit 6a8181b
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 141 deletions.
32 changes: 28 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
50 changes: 50 additions & 0 deletions base/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions base/install-packages
Original file line number Diff line number Diff line change
@@ -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/*
12 changes: 3 additions & 9 deletions dart/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/*;
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
4 changes: 2 additions & 2 deletions flutter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ 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"

RUN set -ex; \
flutter channel beta; \
flutter upgrade; \
flutter config --enable-web; \
flutter precache
flutter precache
24 changes: 10 additions & 14 deletions flutter/android.Dockerfile
Original file line number Diff line number Diff line change
@@ -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;
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
4 changes: 1 addition & 3 deletions full-vnc/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
89 changes: 16 additions & 73 deletions full/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 \
Expand All @@ -96,18 +45,16 @@ 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/ \

This comment has been minimized.

Copy link
@apolopena

apolopena Mar 4, 2021

Could this line of code be failing somehow? Perhaps a permission issue? I am trying to find the root cause of an apache bug that just appeared in all my projects.

This comment has been minimized.

Copy link
@aledbf

aledbf Mar 4, 2021

Author Member

@apolopena checking...

&& 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/
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
Expand All @@ -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 ###
Expand Down Expand Up @@ -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; \
Expand All @@ -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 \
Expand Down Expand Up @@ -265,20 +211,17 @@ 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

### Prologue (built across all layers) ###
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 \
Expand Down
Loading

0 comments on commit 6a8181b

Please sign in to comment.