Skip to content

Commit 5e2ca66

Browse files
committed
Docker optimisations :
* Allow to change related repository with ARG * Allow to suffix tag with ARG * Allow to change FROM_IMAGE with ARG (to allow some optimisation in docker bake with precedences) * Use ARG instead of `Dockerfile.${VARIANT}.node{10,12,14,16}` files * Use `SHELL ["/bin/bash", "-o", "pipefail", "-c"]` mode for Dockerfile * Specify version of Dockerfile avec v1 `#syntax=docker/dockerfile-upstream:1` * Reduce `RUN` steps * Upgrade tini to v0.19 * Fix supercronic installation * Fix npm version built in slim mode * Add .dockerignore to optimise build time and memory
1 parent 780f42c commit 5e2ca66

25 files changed

+701
-748
lines changed

.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/.git*
2+
/docker-bake.hcl
3+
/Dockerfile.*
4+
/Makefile
5+
/*.md
6+
/LICENSE
7+
/orbit*
8+
/test*
9+
/utils/*.blueprint.*
10+
/utils/*.blueprint

Dockerfile.apache

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
#syntax=docker/dockerfile-upstream:1
12
# DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint)
23
ARG INSTALL_CRON=1
34
ARG INSTALL_COMPOSER=1
45
ARG PHP_VERSION
56
ARG GLOBAL_VERSION
7+
ARG REPO="thecodingmachine/php"
8+
ARG TAG_PREFIX=""
69

7-
FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-slim-apache as baseapp
10+
ARG FROM_IMAGE="${REPO}:${TAG_PREFIX}${PHP_VERSION}-${GLOBAL_VERSION}-slim-apache"
11+
FROM $FROM_IMAGE
812
LABEL authors="Julien Neuhart <[email protected]>, David Négrier <[email protected]>"
13+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
914

1015
ARG TARGETOS
1116
ARG TARGETARCH

Dockerfile.apache.node14 renamed to Dockerfile.apache.node

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
1+
#syntax=docker/dockerfile-upstream:1
12
# DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint)
2-
FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-apache as baseapp
3+
ARG REPO="thecodingmachine/php"
4+
ARG TAG_PREFIX=""
5+
ARG FROM_IMAGE="${REPO}:${TAG_PREFIX}:${PHP_VERSION}-${GLOBAL_VERSION}-apache"
6+
FROM $FROM_IMAGE
37
LABEL authors="Julien Neuhart <[email protected]>, David Négrier <[email protected]>"
8+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
49

510
ARG TARGETOS
611
ARG TARGETARCH
712
ARG BLACKFIRE_VERSION=1
13+
ARG NODE_VERSION=16
814

915
USER root
1016

1117
ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION}
1218

1319
RUN apt-get update && \
1420
apt-get install -y --no-install-recommends gnupg && \
15-
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
21+
curl -sL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - && \
1622
apt-get update && \
1723
apt-get install -y --no-install-recommends nodejs && \
1824
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
1925
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
2026
apt-get update && \
2127
apt-get install -y --no-install-recommends yarn && \
22-
npm install -g npm && \
28+
if [[ "${NODE_VERSION}" == "10" ]]; then npm install -g npm@^6.14; else npm install -g npm; fi && \
2329
apt-get clean && \
2430
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
2531

Dockerfile.apache.node16

Lines changed: 0 additions & 26 deletions
This file was deleted.

Dockerfile.cli

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
#syntax=docker/dockerfile-upstream:1
12
# DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint)
23
ARG INSTALL_CRON=1
34
ARG INSTALL_COMPOSER=1
45
ARG PHP_VERSION
56
ARG GLOBAL_VERSION
7+
ARG REPO="thecodingmachine/php"
8+
ARG TAG_PREFIX=""
69

7-
FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-slim-cli as baseapp
10+
ARG FROM_IMAGE="${REPO}:${TAG_PREFIX}${PHP_VERSION}-${GLOBAL_VERSION}-slim-cli"
11+
FROM $FROM_IMAGE
812
LABEL authors="Julien Neuhart <[email protected]>, David Négrier <[email protected]>"
13+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
914

1015
ARG TARGETOS
1116
ARG TARGETARCH

Dockerfile.apache.node10 renamed to Dockerfile.cli.node

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
1+
#syntax=docker/dockerfile-upstream:1
12
# DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint)
2-
FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-apache as baseapp
3+
ARG REPO="thecodingmachine/php"
4+
ARG TAG_PREFIX=""
5+
ARG FROM_IMAGE="${REPO}:${TAG_PREFIX}:${PHP_VERSION}-${GLOBAL_VERSION}-cli"
6+
FROM $FROM_IMAGE
37
LABEL authors="Julien Neuhart <[email protected]>, David Négrier <[email protected]>"
8+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
49

510
ARG TARGETOS
611
ARG TARGETARCH
712
ARG BLACKFIRE_VERSION=1
13+
ARG NODE_VERSION=16
814

915
USER root
1016

1117
ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION}
1218

1319
RUN apt-get update && \
1420
apt-get install -y --no-install-recommends gnupg && \
15-
curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
21+
curl -sL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - && \
1622
apt-get update && \
1723
apt-get install -y --no-install-recommends nodejs && \
1824
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
1925
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
2026
apt-get update && \
2127
apt-get install -y --no-install-recommends yarn && \
22-
npm install -g npm@^6.14 && \
28+
if [[ "${NODE_VERSION}" == "10" ]]; then npm install -g npm@^6.14; else npm install -g npm; fi && \
2329
apt-get clean && \
2430
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
2531

Dockerfile.cli.node10

Lines changed: 0 additions & 26 deletions
This file was deleted.

Dockerfile.cli.node12

Lines changed: 0 additions & 26 deletions
This file was deleted.

Dockerfile.cli.node14

Lines changed: 0 additions & 26 deletions
This file was deleted.

Dockerfile.cli.node16

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)