From 31a4e29c819a34e2ef835a42fb3cb307e461140f Mon Sep 17 00:00:00 2001 From: Daniel Hunsaker Date: Wed, 4 Apr 2018 06:13:11 -0600 Subject: [PATCH] Apply COPY vs ADD best practices Should only use `ADD` for URLs (and even then, `curl` or `wget` are preferred, for numerous reasons, even within this repo) and when extracting archive contents as part of the `ADD` operation; otherwise `COPY` is clearer and (slightly) more efficient. --- aerospike/Dockerfile | 2 +- hhvm/Dockerfile | 2 +- mariadb/Dockerfile | 2 +- mysql/Dockerfile | 2 +- nginx/Dockerfile | 2 +- percona/Dockerfile | 2 +- php-fpm/Dockerfile-56 | 4 ++-- php-fpm/Dockerfile-70 | 4 ++-- php-fpm/Dockerfile-71 | 4 ++-- php-fpm/Dockerfile-72 | 4 ++-- varnish/Dockerfile | 4 ++-- workspace/Dockerfile-56 | 4 ++-- workspace/Dockerfile-70 | 4 ++-- workspace/Dockerfile-71 | 4 ++-- workspace/Dockerfile-72 | 4 ++-- 15 files changed, 24 insertions(+), 24 deletions(-) diff --git a/aerospike/Dockerfile b/aerospike/Dockerfile index e4a6e273..a85bc20c 100644 --- a/aerospike/Dockerfile +++ b/aerospike/Dockerfile @@ -4,4 +4,4 @@ LABEL maintainer="Luciano Jr " RUN rm /etc/aerospike/aerospike.conf -ADD aerospike.conf /etc/aerospike/aerospike.conf +COPY aerospike.conf /etc/aerospike/aerospike.conf diff --git a/hhvm/Dockerfile b/hhvm/Dockerfile index 1b10cded..e1b1f62e 100644 --- a/hhvm/Dockerfile +++ b/hhvm/Dockerfile @@ -15,7 +15,7 @@ RUN apt-get update -y \ RUN mkdir -p /var/www -ADD server.ini /etc/hhvm/server.ini +COPY server.ini /etc/hhvm/server.ini RUN usermod -u 1000 www-data diff --git a/mariadb/Dockerfile b/mariadb/Dockerfile index 05b984f0..0dcb9481 100644 --- a/mariadb/Dockerfile +++ b/mariadb/Dockerfile @@ -2,7 +2,7 @@ FROM mariadb:latest LABEL maintainer="Mahmoud Zalt " -ADD my.cnf /etc/mysql/conf.d/my.cnf +COPY my.cnf /etc/mysql/conf.d/my.cnf CMD ["mysqld"] diff --git a/mysql/Dockerfile b/mysql/Dockerfile index c2811d5d..a3de8863 100644 --- a/mysql/Dockerfile +++ b/mysql/Dockerfile @@ -13,7 +13,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN chown -R mysql:root /var/lib/mysql/ -ADD my.cnf /etc/mysql/conf.d/my.cnf +COPY my.cnf /etc/mysql/conf.d/my.cnf CMD ["mysqld"] diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 5be25543..7af74fc3 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -2,7 +2,7 @@ FROM nginx:alpine LABEL maintainer="Mahmoud Zalt " -ADD nginx.conf /etc/nginx/ +COPY nginx.conf /etc/nginx/ # If you're in China, or you need to change sources, will be set CHANGE_SOURCE to true in .env. diff --git a/percona/Dockerfile b/percona/Dockerfile index 9a8b5c6a..3d3fd6d3 100644 --- a/percona/Dockerfile +++ b/percona/Dockerfile @@ -4,7 +4,7 @@ LABEL maintainer="DTUNES " RUN chown -R mysql:root /var/lib/mysql/ -ADD my.cnf /etc/mysql/conf.d/my.cnf +COPY my.cnf /etc/mysql/conf.d/my.cnf CMD ["mysqld"] diff --git a/php-fpm/Dockerfile-56 b/php-fpm/Dockerfile-56 index 3290ff10..01dbf7c9 100644 --- a/php-fpm/Dockerfile-56 +++ b/php-fpm/Dockerfile-56 @@ -358,8 +358,8 @@ RUN php -v | head -n 1 | grep -q "PHP 5.6." #-------------------------------------------------------------------------- # -ADD ./laravel.ini /usr/local/etc/php/conf.d -ADD ./xlaravel.pool.conf /usr/local/etc/php-fpm.d/ +COPY ./laravel.ini /usr/local/etc/php/conf.d +COPY ./xlaravel.pool.conf /usr/local/etc/php-fpm.d/ #RUN rm -r /var/lib/apt/lists/* diff --git a/php-fpm/Dockerfile-70 b/php-fpm/Dockerfile-70 index 281a64f0..a5337272 100644 --- a/php-fpm/Dockerfile-70 +++ b/php-fpm/Dockerfile-70 @@ -380,8 +380,8 @@ RUN php -v | head -n 1 | grep -q "PHP 7.0." #-------------------------------------------------------------------------- # -ADD ./laravel.ini /usr/local/etc/php/conf.d/ -ADD ./xlaravel.pool.conf /usr/local/etc/php-fpm.d/ +COPY ./laravel.ini /usr/local/etc/php/conf.d/ +COPY ./xlaravel.pool.conf /usr/local/etc/php-fpm.d/ #RUN rm -r /var/lib/apt/lists/* diff --git a/php-fpm/Dockerfile-71 b/php-fpm/Dockerfile-71 index d87584cf..7b84785c 100644 --- a/php-fpm/Dockerfile-71 +++ b/php-fpm/Dockerfile-71 @@ -380,8 +380,8 @@ RUN php -v | head -n 1 | grep -q "PHP 7.1." #-------------------------------------------------------------------------- # -ADD ./laravel.ini /usr/local/etc/php/conf.d -ADD ./xlaravel.pool.conf /usr/local/etc/php-fpm.d/ +COPY ./laravel.ini /usr/local/etc/php/conf.d +COPY ./xlaravel.pool.conf /usr/local/etc/php-fpm.d/ #RUN rm -r /var/lib/apt/lists/* diff --git a/php-fpm/Dockerfile-72 b/php-fpm/Dockerfile-72 index c9ea138c..0d34a9a5 100644 --- a/php-fpm/Dockerfile-72 +++ b/php-fpm/Dockerfile-72 @@ -383,8 +383,8 @@ RUN php -v | head -n 1 | grep -q "PHP 7.2." #-------------------------------------------------------------------------- # -ADD ./laravel.ini /usr/local/etc/php/conf.d -ADD ./xlaravel.pool.conf /usr/local/etc/php-fpm.d/ +COPY ./laravel.ini /usr/local/etc/php/conf.d +COPY ./xlaravel.pool.conf /usr/local/etc/php-fpm.d/ #RUN rm -r /var/lib/apt/lists/* diff --git a/varnish/Dockerfile b/varnish/Dockerfile index 5da88e11..8cc4fbfb 100644 --- a/varnish/Dockerfile +++ b/varnish/Dockerfile @@ -19,8 +19,8 @@ ENV VARNISH_PORT 6081 ENV BACKEND_HOST localhost ENV BACKEND_PORT 80 -ADD default.vcl /etc/varnish/default.vcl -ADD start.sh /etc/varnish/start.sh +COPY default.vcl /etc/varnish/default.vcl +COPY start.sh /etc/varnish/start.sh RUN chmod +x /etc/varnish/start.sh diff --git a/workspace/Dockerfile-56 b/workspace/Dockerfile-56 index f3e1eb49..1c6680c9 100644 --- a/workspace/Dockerfile-56 +++ b/workspace/Dockerfile-56 @@ -209,8 +209,8 @@ RUN if [ ${INSTALL_XDEBUG} = false -a ${INSTALL_BLACKFIRE} = true ]; then \ ARG INSTALL_WORKSPACE_SSH=false ENV INSTALL_WORKSPACE_SSH ${INSTALL_WORKSPACE_SSH} -ADD insecure_id_rsa /tmp/id_rsa -ADD insecure_id_rsa.pub /tmp/id_rsa.pub +COPY insecure_id_rsa /tmp/id_rsa +COPY insecure_id_rsa.pub /tmp/id_rsa.pub RUN if [ ${INSTALL_WORKSPACE_SSH} = true ]; then \ rm -f /etc/service/sshd/down && \ diff --git a/workspace/Dockerfile-70 b/workspace/Dockerfile-70 index a240a1fd..212979fe 100644 --- a/workspace/Dockerfile-70 +++ b/workspace/Dockerfile-70 @@ -206,8 +206,8 @@ RUN if [ ${INSTALL_XDEBUG} = false -a ${INSTALL_BLACKFIRE} = true ]; then \ ARG INSTALL_WORKSPACE_SSH=false ENV INSTALL_WORKSPACE_SSH ${INSTALL_WORKSPACE_SSH} -ADD insecure_id_rsa /tmp/id_rsa -ADD insecure_id_rsa.pub /tmp/id_rsa.pub +COPY insecure_id_rsa /tmp/id_rsa +COPY insecure_id_rsa.pub /tmp/id_rsa.pub RUN if [ ${INSTALL_WORKSPACE_SSH} = true ]; then \ rm -f /etc/service/sshd/down && \ diff --git a/workspace/Dockerfile-71 b/workspace/Dockerfile-71 index 18b42a0b..8e253eb6 100644 --- a/workspace/Dockerfile-71 +++ b/workspace/Dockerfile-71 @@ -202,8 +202,8 @@ RUN if [ ${INSTALL_XDEBUG} = false -a ${INSTALL_BLACKFIRE} = true ]; then \ ARG INSTALL_WORKSPACE_SSH=false ENV INSTALL_WORKSPACE_SSH ${INSTALL_WORKSPACE_SSH} -ADD insecure_id_rsa /tmp/id_rsa -ADD insecure_id_rsa.pub /tmp/id_rsa.pub +COPY insecure_id_rsa /tmp/id_rsa +COPY insecure_id_rsa.pub /tmp/id_rsa.pub RUN if [ ${INSTALL_WORKSPACE_SSH} = true ]; then \ rm -f /etc/service/sshd/down && \ diff --git a/workspace/Dockerfile-72 b/workspace/Dockerfile-72 index 8e3cb9c3..727dc88c 100644 --- a/workspace/Dockerfile-72 +++ b/workspace/Dockerfile-72 @@ -203,8 +203,8 @@ RUN if [ ${INSTALL_XDEBUG} = false -a ${INSTALL_BLACKFIRE} = true ]; then \ ARG INSTALL_WORKSPACE_SSH=false ENV INSTALL_WORKSPACE_SSH ${INSTALL_WORKSPACE_SSH} -ADD insecure_id_rsa /tmp/id_rsa -ADD insecure_id_rsa.pub /tmp/id_rsa.pub +COPY insecure_id_rsa /tmp/id_rsa +COPY insecure_id_rsa.pub /tmp/id_rsa.pub RUN if [ ${INSTALL_WORKSPACE_SSH} = true ]; then \ rm -f /etc/service/sshd/down && \