From b4636c46aeb5c8e7911268f85dbc7c35a5557f12 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Wed, 10 Jun 2020 17:35:08 -0600 Subject: [PATCH] Split docker-install.bash into many layers I've been running into trouble where something will fail inscrutably in docker-install.bash or when pushing a large layer or something else of that nature, and those errors really suck when it's just one big layer. This should aid development and deployment both. --- Dockerfile.dev | 30 +- Dockerfile.prod | 34 +- scripts/docker-install-phase1.bash | 35 ++ scripts/docker-install-phase2.bash | 39 +++ scripts/docker-install-phase3a.bash | 63 ++++ scripts/docker-install-phase3b.bash | 70 ++++ scripts/docker-install-phase3c.bash | 70 ++++ scripts/docker-install-phase3d.bash | 64 ++++ scripts/docker-install-phase4.bash | 39 +++ ...nstall.bash => docker-install-phase5.bash} | 326 ------------------ scripts/docker-install-phase6.bash | 19 + 11 files changed, 456 insertions(+), 333 deletions(-) create mode 100755 scripts/docker-install-phase1.bash create mode 100755 scripts/docker-install-phase2.bash create mode 100755 scripts/docker-install-phase3a.bash create mode 100755 scripts/docker-install-phase3b.bash create mode 100755 scripts/docker-install-phase3c.bash create mode 100755 scripts/docker-install-phase3d.bash create mode 100755 scripts/docker-install-phase4.bash rename scripts/{docker-install.bash => docker-install-phase5.bash} (57%) create mode 100644 scripts/docker-install-phase6.bash diff --git a/Dockerfile.dev b/Dockerfile.dev index 93dacb2..aa2536a 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -2,10 +2,34 @@ FROM ubuntu:focal ARG UID -COPY scripts/docker-install.bash /tmp/ -RUN /tmp/docker-install.bash "$UID" +COPY scripts/docker-install-phase1.bash /tmp/ +RUN /tmp/docker-install-phase1.bash -USER $UID +COPY scripts/docker-install-phase2.bash /tmp/ +RUN /tmp/docker-install-phase2.bash + +COPY scripts/docker-install-phase3a.bash /tmp/ +RUN /tmp/docker-install-phase3a.bash + +COPY scripts/docker-install-phase3b.bash /tmp/ +RUN /tmp/docker-install-phase3b.bash + +COPY scripts/docker-install-phase3c.bash /tmp/ +RUN /tmp/docker-install-phase3c.bash + +COPY scripts/docker-install-phase3d.bash /tmp/ +RUN /tmp/docker-install-phase3d.bash + +COPY scripts/docker-install-phase4.bash /tmp/ +RUN /tmp/docker-install-phase4.bash + +COPY scripts/docker-install-phase5.bash /tmp/ +RUN /tmp/docker-install-phase5.bash + +COPY scripts/docker-install-phase6.bash /tmp/ +RUN /tmp/docker-install-phase6.bash "$UID" + +USER docker WORKDIR /home/docker EXPOSE 6119 diff --git a/Dockerfile.prod b/Dockerfile.prod index f49da8f..4f260f1 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -1,11 +1,37 @@ FROM ubuntu:focal +# This is just here so we can reuse the Docker cache between dev and +# prod, it's not actually read by anything. ARG UID -COPY scripts/docker-install.bash /tmp/ -RUN /tmp/docker-install.bash "$UID" +COPY scripts/docker-install-phase1.bash /tmp/ +RUN /tmp/docker-install-phase1.bash -USER $UID +COPY scripts/docker-install-phase2.bash /tmp/ +RUN /tmp/docker-install-phase2.bash + +COPY scripts/docker-install-phase3a.bash /tmp/ +RUN /tmp/docker-install-phase3a.bash + +COPY scripts/docker-install-phase3b.bash /tmp/ +RUN /tmp/docker-install-phase3b.bash + +COPY scripts/docker-install-phase3c.bash /tmp/ +RUN /tmp/docker-install-phase3c.bash + +COPY scripts/docker-install-phase3d.bash /tmp/ +RUN /tmp/docker-install-phase3d.bash + +COPY scripts/docker-install-phase4.bash /tmp/ +RUN /tmp/docker-install-phase4.bash + +COPY scripts/docker-install-phase5.bash /tmp/ +RUN /tmp/docker-install-phase5.bash + +COPY scripts/docker-install-phase6.bash /tmp/ +RUN /tmp/docker-install-phase6.bash + +USER docker WORKDIR /home/docker EXPOSE 6119 @@ -14,7 +40,7 @@ COPY scripts/pid1.bash /usr/local/bin/ RUN sudo deluser docker sudo ADD --chown=docker:docker . /home/docker/src -WORKDIR src +WORKDIR /home/docker/src RUN yarn install RUN yarn run backend RUN yarn run frontend diff --git a/scripts/docker-install-phase1.bash b/scripts/docker-install-phase1.bash new file mode 100755 index 0000000..fa3932b --- /dev/null +++ b/scripts/docker-install-phase1.bash @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +dpkg --add-architecture i386 + +export DEBIAN_FRONTEND=noninteractive +apt-get update +apt-get install -y apt-transport-https curl gnupg lsb-release software-properties-common wget +rm -rf /var/lib/apt/lists/* + +curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - +curl -sSL https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - +curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - +curl -sSL https://keybase.io/crystal/pgp_keys.asc | apt-key add - +apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 + +cd /tmp +wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb +dpkg -i packages-microsoft-prod.deb +rm packages-microsoft-prod.deb + +tee -a /etc/apt/sources.list.d/custom.list >/dev/null <<"EOF" +deb [arch=amd64] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main +deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ +deb https://deb.nodesource.com/node_14.x focal main +deb https://dist.crystal-lang.org/apt crystal main +deb https://dl.yarnpkg.com/debian/ stable main +deb-src https://deb.nodesource.com/node_14.x focal main +EOF + +add-apt-repository -y -n ppa:deadsnakes/ppa + +rm "$0" diff --git a/scripts/docker-install-phase2.bash b/scripts/docker-install-phase2.bash new file mode 100755 index 0000000..5ec38e5 --- /dev/null +++ b/scripts/docker-install-phase2.bash @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +packages=" + +# Needed for project infrastructure +bash +git +make +nodejs +python3-pip +yarn + +# Handy utilities +bsdmainutils +curl +emacs-nox +git +htop +jq +lsof +make +man-db +nano +sudo +tmux +vim +wget + +" + +export DEBIAN_FRONTEND=noninteractive +apt-get update +apt-get install -y $(grep -v "^#" <<< "$packages") +rm -rf /var/lib/apt/lists/* + +rm "$0" diff --git a/scripts/docker-install-phase3a.bash b/scripts/docker-install-phase3a.bash new file mode 100755 index 0000000..770409d --- /dev/null +++ b/scripts/docker-install-phase3a.bash @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +packages=" + +# Ada +gnat + +# Algol +algol68g + +# ARM +gcc-arm-linux-gnueabihf +qemu-user-static + +# ATS +ats2-lang + +# BASIC +bwbasic + +# Bash +bash + +# BrainF +beef + +# C/C++ +clang + +# C# +mono-mcs + +# Clojure +clojure + +# Cmd +wine +wine32 + +# COBOL +gnucobol + +# Common Lisp +rlwrap +sbcl + +# Crystal +crystal + +# Dart +dart + +" + +export DEBIAN_FRONTEND=noninteractive +apt-get update +apt-get install -y $(grep -v "^#" <<< "$packages") +rm -rf /var/lib/apt/lists/* + +rm "$0" diff --git a/scripts/docker-install-phase3b.bash b/scripts/docker-install-phase3b.bash new file mode 100755 index 0000000..38303f3 --- /dev/null +++ b/scripts/docker-install-phase3b.bash @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +packages=" + +# Elixir +elixir + +# Elvish +elvish + +# Emacs Lisp +emacs-nox + +# Erlang +erlang + +# F# +fsharp + +# Fish +fish + +# FORTRAN +flang-7 + +# Forth +gforth + +# Go +golang + +# Groovy +groovy + +# Haskell +cabal-install +ghc + +# INTERCAL +intercal + +# Java +default-jdk + +# Julia +julia + +# Kalyn +haskell-stack + +# Ksh +ksh + +# LOLCODE +cmake + +# Lua +lua5.3 + +" + +export DEBIAN_FRONTEND=noninteractive +apt-get update +apt-get install -y $(grep -v "^#" <<< "$packages") +rm -rf /var/lib/apt/lists/* + +rm "$0" diff --git a/scripts/docker-install-phase3c.bash b/scripts/docker-install-phase3c.bash new file mode 100755 index 0000000..6ca413b --- /dev/null +++ b/scripts/docker-install-phase3c.bash @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +packages=" + +# MIPS +gcc-mips64-linux-gnuabi64 +qemu-user-static + +# MUMPS +fis-gtm + +# Nim +nim + +# Node.js +nodejs +yarn + +# Objective-C +gcc +gnustep-devel + +# Octave +octave + +# Pascal +fpc + +# Perl +perl +perlconsole + +# PHP +php + +# Prolog +swi-prolog + +# Python +python3 +python3-pip +python3-venv + +# R +r-base + +# Racket +racket + +# RISC-V +gcc-riscv64-linux-gnu +qemu-user-static + +# Ruby +ruby + +# Rust +rustc + +" + +export DEBIAN_FRONTEND=noninteractive +apt-get update +apt-get install -y $(grep -v "^#" <<< "$packages") +rm -rf /var/lib/apt/lists/* + +rm "$0" diff --git a/scripts/docker-install-phase3d.bash b/scripts/docker-install-phase3d.bash new file mode 100755 index 0000000..74f09b7 --- /dev/null +++ b/scripts/docker-install-phase3d.bash @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +packages=" + +# Scala +scala + +# Scheme +mit-scheme + +# Sh +posh + +# Smalltalk +gnu-smalltalk + +# SNOBOL +m4 + +# SQLite +sqlite + +# Standard ML +rlwrap +smlnj + +# Swift +libpython2.7 + +# Tcl +tcl + +# Tcsh +tcsh + +# Unlambda +unlambda + +# Vimscript +vim + +# Visual Basic +mono-vbnc + +# Wolfram Language +python3.7 + +# x86 +clang + +# Zsh +zsh + +" + +export DEBIAN_FRONTEND=noninteractive +apt-get update +apt-get install -y $(grep -v "^#" <<< "$packages") +rm -rf /var/lib/apt/lists/* + +rm "$0" diff --git a/scripts/docker-install-phase4.bash b/scripts/docker-install-phase4.bash new file mode 100755 index 0000000..70ba663 --- /dev/null +++ b/scripts/docker-install-phase4.bash @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +npm config set unsafe-perm true +PERL_MM_USE_DEFAULT=1 cpan App::cpanminus + +# Befunge +npm install -g befunge93 prompt-sync + +# ClojureScript +npm install -g lumo-cljs + +# CoffeeScript +npm install -g coffeescript + +# Elm +npm install -g @kachkaev/run-elm + +# Perl +cpanm -n Devel::REPL + +# ReasonML +npm install -g bs-platform + +# Shakespeare +pip3 install shakespearelang + +# TypeScript +npm install -g ts-node typescript + +# Whitespace +pip3 install whitespace + +# Wolfram Language +python3.7 -m pip install mathics + +rm "$0" diff --git a/scripts/docker-install.bash b/scripts/docker-install-phase5.bash similarity index 57% rename from scripts/docker-install.bash rename to scripts/docker-install-phase5.bash index c002340..62fab91 100755 --- a/scripts/docker-install.bash +++ b/scripts/docker-install-phase5.bash @@ -3,314 +3,6 @@ set -e set -o pipefail -if (( $# != 1 )); then - echo "usage: docker-install.bash UID" >&2 - exit 1 -fi - -uid="$1" - -dpkg --add-architecture i386 - -export DEBIAN_FRONTEND=noninteractive -apt-get update -apt-get install -y apt-transport-https curl gnupg lsb-release software-properties-common wget -rm -rf /var/lib/apt/lists/* - -curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - -curl -sSL https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - -curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - -curl -sSL https://keybase.io/crystal/pgp_keys.asc | apt-key add - -apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 - -cd /tmp -wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -dpkg -i packages-microsoft-prod.deb -rm packages-microsoft-prod.deb - -tee -a /etc/apt/sources.list.d/custom.list >/dev/null <<"EOF" -deb [arch=amd64] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main -deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ -deb https://deb.nodesource.com/node_14.x focal main -deb https://dist.crystal-lang.org/apt crystal main -deb https://dl.yarnpkg.com/debian/ stable main -deb-src https://deb.nodesource.com/node_14.x focal main -EOF - -add-apt-repository -y -n ppa:deadsnakes/ppa - -packages=" - -# Needed for project infrastructure -bash -git -make -nodejs -python3-pip -yarn - -# Handy utilities -bsdmainutils -curl -emacs-nox -git -htop -jq -lsof -make -man-db -nano -sudo -tmux -vim -wget - -# Ada -gnat - -# Algol -algol68g - -# ARM -gcc-arm-linux-gnueabihf -qemu-user-static - -# ATS -ats2-lang - -# BASIC -bwbasic - -# Bash -bash - -# BrainF -beef - -# C/C++ -clang - -# C# -mono-mcs - -# Clojure -clojure - -# Cmd -wine -wine32 - -# COBOL -gnucobol - -# Common Lisp -rlwrap -sbcl - -# Crystal -crystal - -# Dart -dart - -# Elixir -elixir - -# Elvish -elvish - -# Emacs Lisp -emacs-nox - -# Erlang -erlang - -# F# -fsharp - -# Fish -fish - -# FORTRAN -flang-7 - -# Forth -gforth - -# Go -golang - -# Groovy -groovy - -# Haskell -cabal-install -ghc - -# INTERCAL -intercal - -# Java -default-jdk - -# Julia -julia - -# Kalyn -haskell-stack - -# Ksh -ksh - -# LOLCODE -cmake - -# Lua -lua5.3 - -# MIPS -gcc-mips64-linux-gnuabi64 -qemu-user-static - -# MUMPS -fis-gtm - -# Nim -nim - -# Node.js -nodejs -yarn - -# Objective-C -gcc -gnustep-devel - -# Octave -octave - -# Pascal -fpc - -# Perl -perl -perlconsole - -# PHP -php - -# Prolog -swi-prolog - -# Python -python3 -python3-pip -python3-venv - -# R -r-base - -# Racket -racket - -# RISC-V -gcc-riscv64-linux-gnu -qemu-user-static - -# Ruby -ruby - -# Rust -rustc - -# Scala -scala - -# Scheme -mit-scheme - -# Sh -posh - -# Smalltalk -gnu-smalltalk - -# SNOBOL -m4 - -# SQLite -sqlite - -# Standard ML -rlwrap -smlnj - -# Swift -libpython2.7 - -# Tcl -tcl - -# Tcsh -tcsh - -# Unlambda -unlambda - -# Vimscript -vim - -# Visual Basic -mono-vbnc - -# Wolfram Language -python3.7 - -# x86 -clang - -# Zsh -zsh - -" - -export DEBIAN_FRONTEND=noninteractive -apt-get update -apt-get install -y $(grep -v "^#" <<< "$packages") -rm -rf /var/lib/apt/lists/* - -npm config set unsafe-perm true - -# Befunge -npm install -g befunge93 prompt-sync - -# ClojureScript -npm install -g lumo-cljs - -# CoffeeScript -npm install -g coffeescript - -# Elm -npm install -g @kachkaev/run-elm - -# Perl -cpan Devel::REPL - -# ReasonML -npm install -g bs-platform - -# Shakespeare -pip3 install shakespearelang - -# TypeScript -npm install -g ts-node typescript - -# Whitespace -pip3 install whitespace - -# Wolfram Language -python3.7 -m pip install mathics - # Needed for project infrastructure cd /tmp wget -nv https://github.com/watchexec/watchexec/releases/download/1.13.1/watchexec-1.13.1-x86_64-unknown-linux-gnu.deb @@ -403,13 +95,6 @@ git clone https://github.com/bipinu/malbolge.git clang malbolge/malbolge.c -o /usr/bin/malbolge rm -rf malbolge -# ActionScript -tee /usr/bin/amxmlc >/dev/null <<"EOF" -#!/bin/sh -exec /opt/actionscript/bin/amxmlc "$@" -EOF -chmod +x /usr/bin/amxmlc - # Befunge tee /usr/bin/befunge-repl >/dev/null <<"EOF" #!/usr/bin/env -S NODE_PATH=/usr/lib/node_modules node @@ -531,15 +216,4 @@ while True: EOF chmod +x /usr/bin/unlambda-repl -if (( "$uid" != 0 )); then - useradd --uid="$uid" --create-home --groups sudo docker - passwd -d docker -else - useradd --create-home --groups sudo docker - passwd -d docker -fi - -touch /home/docker/.zshrc -chown docker:docker /home/docker/.zshrc - rm "$0" diff --git a/scripts/docker-install-phase6.bash b/scripts/docker-install-phase6.bash new file mode 100644 index 0000000..83c3efb --- /dev/null +++ b/scripts/docker-install-phase6.bash @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +uid="$1" + +if [[ -n "$uid" ]] && (( "$uid" != 0 )); then + useradd --uid="$uid" --create-home --groups sudo docker + passwd -d docker +else + useradd --create-home --groups sudo docker + passwd -d docker +fi + +touch /home/docker/.zshrc +chown docker:docker /home/docker/.zshrc + +rm "$0"