From d9ff8b9341efc506e1ffb9f503a9168c8d0a3864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 23 Apr 2020 12:34:58 +0200 Subject: [PATCH] Adding Node14 image --- .travis.yml | 2 + Dockerfile.14 | 140 ++++++++++++++++++++++++++ Dockerfile.14-apache | 232 +++++++++++++++++++++++++++++++++++++++++++ README.md | 4 +- orbit.yml | 2 + 5 files changed, 379 insertions(+), 1 deletion(-) create mode 100644 Dockerfile.14 create mode 100644 Dockerfile.14-apache diff --git a/.travis.yml b/.travis.yml index a7b126f..394c52a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,10 +11,12 @@ env: - VARIANT="8" - VARIANT="10" - VARIANT="12" + - VARIANT="14" - VARIANT="6-apache" - VARIANT="8-apache" - VARIANT="10-apache" - VARIANT="12-apache" + - VARIANT="14-apache" script: - BRANCH=$TRAVIS_BRANCH VARIANT=${VARIANT} ./build-and-test.sh # Let's push only if not in a pull request and the branch matches the master format diff --git a/Dockerfile.14 b/Dockerfile.14 new file mode 100644 index 0000000..dbfad9f --- /dev/null +++ b/Dockerfile.14 @@ -0,0 +1,140 @@ +FROM debian:stretch-slim + +LABEL authors="Julien Neuhart , David Négrier " + +# |-------------------------------------------------------------------------- +# | Required libraries +# |-------------------------------------------------------------------------- +# | +# | Installs required libraries. +# | + +RUN apt-get update &&\ + apt-get install -y --no-install-recommends curl git nano sudo ca-certificates procps libfontconfig --no-install-recommends + +# |-------------------------------------------------------------------------- +# | Supercronic +# |-------------------------------------------------------------------------- +# | +# | Supercronic is a drop-in replacement for cron (for containers). +# | + +RUN SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.5/supercronic-linux-amd64 \ + && SUPERCRONIC=supercronic-linux-amd64 \ + && SUPERCRONIC_SHA1SUM=9aeb41e00cc7b71d30d33c57a2333f2c2581a201 \ + && curl -fsSLO "$SUPERCRONIC_URL" \ + && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ + && chmod +x "$SUPERCRONIC" \ + && mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \ + && ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic + + # |-------------------------------------------------------------------------- + # | User + # |-------------------------------------------------------------------------- + # | + # | Define a default user with sudo rights. + # | + + RUN useradd -ms /bin/bash docker && adduser docker sudo + # Users in the sudoers group can sudo as root without password. + RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + + + + +# |-------------------------------------------------------------------------- +# | NodeJS +# |-------------------------------------------------------------------------- +# | +# | Installs NodeJS and npm. +# | + +RUN apt-get update &&\ + apt-get install -y --no-install-recommends gnupg &&\ + curl -sL https://deb.nodesource.com/setup_14.x | bash - &&\ + apt-get update &&\ + apt-get install -y --no-install-recommends nodejs + +# |-------------------------------------------------------------------------- +# | yarn +# |-------------------------------------------------------------------------- +# | +# | Installs yarn. It provides some nice improvements over npm. +# | + +RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &&\ + echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list &&\ + apt-get update &&\ + apt-get install -y --no-install-recommends yarn + +# |-------------------------------------------------------------------------- +# | PATH updating +# |-------------------------------------------------------------------------- +# | +# | Let's add ./node_modules/.bin to the PATH (utility function to use NPM bin easily) +# | + +ENV PATH="$PATH:./node_modules/.bin" +RUN sed -i 's#/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin#/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:./node_modules/.bin#g' /etc/sudoers + +USER docker +# |-------------------------------------------------------------------------- +# | SSH client +# |-------------------------------------------------------------------------- +# | +# | Let's set-up the SSH client (for connections to private git repositories) +# | We create an empty known_host file and we launch the ssh-agent +# | + +RUN mkdir ~/.ssh && touch ~/.ssh/known_hosts && chmod 644 ~/.ssh/known_hosts && eval $(ssh-agent -s) + +# |-------------------------------------------------------------------------- +# | .bashrc updating +# |-------------------------------------------------------------------------- +# | +# | Let's update the .bashrc to add nice aliases +# | +RUN { \ + echo "alias ls='ls --color=auto'"; \ + echo "alias ll='ls --color=auto -alF'"; \ + echo "alias la='ls --color=auto -A'"; \ + echo "alias l='ls --color=auto -CF'"; \ + } >> ~/.bashrc + +USER root + + +# |-------------------------------------------------------------------------- +# | Entrypoint +# |-------------------------------------------------------------------------- +# | +# | Defines the entrypoint. +# | + +ENV NODE_VERSION=14.x + + +RUN mkdir -p /usr/src/app && chown docker:docker /usr/src/app +WORKDIR /usr/src/app + + +# Add Tini (to be able to stop the container with ctrl-c. +# See: https://github.com/krallin/tini +ENV TINI_VERSION v0.16.1 +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +RUN chmod +x /tini + +COPY utils/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh +COPY utils/docker-entrypoint-as-root.sh /usr/local/bin/docker-entrypoint-as-root.sh +COPY utils/startup_commands.js /usr/local/bin/startup_commands.js +COPY utils/generate_cron.js /usr/local/bin/generate_cron.js + + +CMD [ "node" ] + + + + +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] + +USER docker \ No newline at end of file diff --git a/Dockerfile.14-apache b/Dockerfile.14-apache new file mode 100644 index 0000000..29fb9f8 --- /dev/null +++ b/Dockerfile.14-apache @@ -0,0 +1,232 @@ +FROM debian:stretch-slim + +LABEL authors="Julien Neuhart , David Négrier " + +# |-------------------------------------------------------------------------- +# | Required libraries +# |-------------------------------------------------------------------------- +# | +# | Installs required libraries. +# | + +RUN apt-get update &&\ + apt-get install -y --no-install-recommends curl git nano sudo ca-certificates procps libfontconfig --no-install-recommends + +# |-------------------------------------------------------------------------- +# | Supercronic +# |-------------------------------------------------------------------------- +# | +# | Supercronic is a drop-in replacement for cron (for containers). +# | + +RUN SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.5/supercronic-linux-amd64 \ + && SUPERCRONIC=supercronic-linux-amd64 \ + && SUPERCRONIC_SHA1SUM=9aeb41e00cc7b71d30d33c57a2333f2c2581a201 \ + && curl -fsSLO "$SUPERCRONIC_URL" \ + && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ + && chmod +x "$SUPERCRONIC" \ + && mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \ + && ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic + + # |-------------------------------------------------------------------------- + # | User + # |-------------------------------------------------------------------------- + # | + # | Define a default user with sudo rights. + # | + + RUN useradd -ms /bin/bash docker && adduser docker sudo + # Users in the sudoers group can sudo as root without password. + RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + + + +# |-------------------------------------------------------------------------- +# | Apache +# |-------------------------------------------------------------------------- +# | +# | Installs Apache. +# | + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + apache2 \ + && rm -rf /var/lib/apt/lists/* + +ENV APACHE_CONFDIR /etc/apache2 +ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars + +RUN set -ex \ + \ +# generically convert lines like +# export APACHE_RUN_USER=www-data +# into +# : ${APACHE_RUN_USER:=www-data} +# export APACHE_RUN_USER +# so that they can be overridden at runtime ("-e APACHE_RUN_USER=...") + && sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS" \ + \ +# setup directories and permissions + && . "$APACHE_ENVVARS" \ + && for dir in \ + "$APACHE_LOCK_DIR" \ + "$APACHE_RUN_DIR" \ + "$APACHE_LOG_DIR" \ + /var/www/html \ + ; do \ + rm -rvf "$dir" \ + && mkdir -p "$dir" \ + && chown -R "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$dir"; \ + done + +# logs should go to stdout / stderr +RUN set -ex \ + && . "$APACHE_ENVVARS" \ + && ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log" \ + && ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log" \ + && ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log" + +ENV APACHE_DOCUMENT_ROOT / + +RUN { \ + echo 'DirectoryIndex disabled'; \ + echo 'DirectoryIndex index.html'; \ + echo; \ + echo ''; \ + echo '\tOptions -Indexes'; \ + echo '\tAllowOverride All'; \ + echo ''; \ + } | tee "$APACHE_CONFDIR/conf-available/nodejs.conf" \ + && a2enconf nodejs + +RUN sed -ri -e 's!/var/www/html!/var/www/html/${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf +RUN sed -ri -e 's!/var/www/!/var/www/html/${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf + +# |-------------------------------------------------------------------------- +# | Apache mod_rewrite +# |-------------------------------------------------------------------------- +# | +# | Enables Apache mod_rewrite. +# | + +RUN a2enmod rewrite + + +# |-------------------------------------------------------------------------- +# | NodeJS +# |-------------------------------------------------------------------------- +# | +# | Installs NodeJS and npm. +# | + +RUN apt-get update &&\ + apt-get install -y --no-install-recommends gnupg &&\ + curl -sL https://deb.nodesource.com/setup_14.x | bash - &&\ + apt-get update &&\ + apt-get install -y --no-install-recommends nodejs + +# |-------------------------------------------------------------------------- +# | yarn +# |-------------------------------------------------------------------------- +# | +# | Installs yarn. It provides some nice improvements over npm. +# | + +RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &&\ + echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list &&\ + apt-get update &&\ + apt-get install -y --no-install-recommends yarn + +# |-------------------------------------------------------------------------- +# | PATH updating +# |-------------------------------------------------------------------------- +# | +# | Let's add ./node_modules/.bin to the PATH (utility function to use NPM bin easily) +# | + +ENV PATH="$PATH:./node_modules/.bin" +RUN sed -i 's#/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin#/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:./node_modules/.bin#g' /etc/sudoers + +USER docker +# |-------------------------------------------------------------------------- +# | SSH client +# |-------------------------------------------------------------------------- +# | +# | Let's set-up the SSH client (for connections to private git repositories) +# | We create an empty known_host file and we launch the ssh-agent +# | + +RUN mkdir ~/.ssh && touch ~/.ssh/known_hosts && chmod 644 ~/.ssh/known_hosts && eval $(ssh-agent -s) + +# |-------------------------------------------------------------------------- +# | .bashrc updating +# |-------------------------------------------------------------------------- +# | +# | Let's update the .bashrc to add nice aliases +# | +RUN { \ + echo "alias ls='ls --color=auto'"; \ + echo "alias ll='ls --color=auto -alF'"; \ + echo "alias la='ls --color=auto -A'"; \ + echo "alias l='ls --color=auto -CF'"; \ + } >> ~/.bashrc + +USER root + + +# |-------------------------------------------------------------------------- +# | Entrypoint +# |-------------------------------------------------------------------------- +# | +# | Defines the entrypoint. +# | + +ENV NODE_VERSION=14.x + + +RUN mkdir -p /var/www/html && chown docker:docker /var/www/html +WORKDIR /var/www/html + + +# Add Tini (to be able to stop the container with ctrl-c. +# See: https://github.com/krallin/tini +ENV TINI_VERSION v0.16.1 +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +RUN chmod +x /tini + +COPY utils/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh +COPY utils/docker-entrypoint-as-root.sh /usr/local/bin/docker-entrypoint-as-root.sh +COPY utils/startup_commands.js /usr/local/bin/startup_commands.js +COPY utils/generate_cron.js /usr/local/bin/generate_cron.js + + +COPY utils/enable_apache_mods.js /usr/local/bin/enable_apache_mods.js +COPY utils/apache-expose-envvars.sh /usr/local/bin/apache-expose-envvars.sh + +# Let's register a servername to remove the message "apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message" +RUN echo "ServerName localhost" > /etc/apache2/conf-available/servername.conf +RUN a2enconf servername + +EXPOSE 80 + +# |-------------------------------------------------------------------------- +# | Apache user +# |-------------------------------------------------------------------------- +# | +# | Defines Apache user. By default, we switch this to "docker" user. +# | This way, no problem to write from Apache in the current working directory. +# | Important! This should be changed back to www-data in production. +# | + +ENV APACHE_RUN_USER=docker \ + APACHE_RUN_GROUP=docker + +COPY utils/apache2-foreground /usr/local/bin/ +CMD ["apache2-foreground"] + + + + +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] + +USER docker \ No newline at end of file diff --git a/README.md b/README.md index 8ede6de..90c90b1 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,12 @@ This repository contains a set of **fat**, developer-friendly, general purpose N | [thecodingmachine/nodejs:8](https://github.com/thecodingmachine/docker-images-nodejs/blob/master/Dockerfile.8) | `8.x` | standalone | [![](https://images.microbadger.com/badges/image/thecodingmachine/nodejs:8.svg)](https://microbadger.com/images/thecodingmachine/nodejs:8) | | [thecodingmachine/nodejs:10](https://github.com/thecodingmachine/docker-images-nodejs/blob/master/Dockerfile.10) | `10.x` | standalone | [![](https://images.microbadger.com/badges/image/thecodingmachine/nodejs:10.svg)](https://microbadger.com/images/thecodingmachine/nodejs:10) | | [thecodingmachine/nodejs:12](https://github.com/thecodingmachine/docker-images-nodejs/blob/master/Dockerfile.12) | `12.x` | standalone | [![](https://images.microbadger.com/badges/image/thecodingmachine/nodejs:12.svg)](https://microbadger.com/images/thecodingmachine/nodejs:12) | +| [thecodingmachine/nodejs:14](https://github.com/thecodingmachine/docker-images-nodejs/blob/master/Dockerfile.14) | `14.x` | standalone | [![](https://images.microbadger.com/badges/image/thecodingmachine/nodejs:14.svg)](https://microbadger.com/images/thecodingmachine/nodejs:14) | | [thecodingmachine/nodejs:6-apache](https://github.com/thecodingmachine/docker-images-nodejs/blob/master/Dockerfile.6-apache) | `6.x` | apache | [![](https://images.microbadger.com/badges/image/thecodingmachine/nodejs:6-apache.svg)](https://microbadger.com/images/thecodingmachine/nodejs:6-apache) | | [thecodingmachine/nodejs:8-apache](https://github.com/thecodingmachine/docker-images-nodejs/blob/master/Dockerfile.8-apache) | `8.x` | apache | [![](https://images.microbadger.com/badges/image/thecodingmachine/nodejs:8-apache.svg)](https://microbadger.com/images/thecodingmachine/nodejs:8-apache) | | [thecodingmachine/nodejs:10-apache](https://github.com/thecodingmachine/docker-images-nodejs/blob/master/Dockerfile.10-apache) | `10.x` | apache | [![](https://images.microbadger.com/badges/image/thecodingmachine/nodejs:10-apache.svg)](https://microbadger.com/images/thecodingmachine/nodejs:10-apache) | | [thecodingmachine/nodejs:12-apache](https://github.com/thecodingmachine/docker-images-nodejs/blob/master/Dockerfile.12-apache) | `12.x` | apache | [![](https://images.microbadger.com/badges/image/thecodingmachine/nodejs:12-apache.svg)](https://microbadger.com/images/thecodingmachine/nodejs:12-apache) | +| [thecodingmachine/nodejs:14-apache](https://github.com/thecodingmachine/docker-images-nodejs/blob/master/Dockerfile.14-apache) | `14.x` | apache | [![](https://images.microbadger.com/badges/image/thecodingmachine/nodejs:14-apache.svg)](https://microbadger.com/images/thecodingmachine/nodejs:14-apache) | Note: we do not tag minor releases of NodeJS, only major versions. You will find for example an image for NodeJS 6.x, but no tagged image for NodeJS 6.9. This is because NodeJS follows SemVer and we believe you have no valid reason to ask explicitly for 6.1. @@ -286,4 +288,4 @@ You can then test your changes using the `build-and-test.sh` command: ```bash BRANCH=master VARIANT=10 ./build-and-test.sh -``` \ No newline at end of file +``` diff --git a/orbit.yml b/orbit.yml index 93f7543..8241706 100644 --- a/orbit.yml +++ b/orbit.yml @@ -23,7 +23,9 @@ tasks: - orbit generate -f utils/Dockerfile.blueprint -o Dockerfile.8 -p "NodeVersion,8.x;Variant,standalone" - orbit generate -f utils/Dockerfile.blueprint -o Dockerfile.10 -p "NodeVersion,10.x;Variant,standalone" - orbit generate -f utils/Dockerfile.blueprint -o Dockerfile.12 -p "NodeVersion,12.x;Variant,standalone" + - orbit generate -f utils/Dockerfile.blueprint -o Dockerfile.14 -p "NodeVersion,14.x;Variant,standalone" - orbit generate -f utils/Dockerfile.blueprint -o Dockerfile.6-apache -p "NodeVersion,6.x;Variant,apache" - orbit generate -f utils/Dockerfile.blueprint -o Dockerfile.8-apache -p "NodeVersion,8.x;Variant,apache" - orbit generate -f utils/Dockerfile.blueprint -o Dockerfile.10-apache -p "NodeVersion,10.x;Variant,apache" - orbit generate -f utils/Dockerfile.blueprint -o Dockerfile.12-apache -p "NodeVersion,12.x;Variant,apache" + - orbit generate -f utils/Dockerfile.blueprint -o Dockerfile.14-apache -p "NodeVersion,14.x;Variant,apache"