From d42530608934838cf0cdebdaae5ef0683bb0370e Mon Sep 17 00:00:00 2001 From: Carlos Gomes Date: Tue, 4 Oct 2022 11:49:28 +0200 Subject: [PATCH] Install NodeJS from package-manager instead of manual download --- Dockerfile | 70 ++++++++++++++++++++++++++++++++---------------------- Makefile | 2 ++ 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/Dockerfile b/Dockerfile index 57a538a..3ebd171 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,9 +3,9 @@ FROM ubuntu:jammy LABEL maintainer="Carlos A. Gomes " RUN \ - apt update \ - && apt upgrade -y \ - && apt install -y --no-install-recommends \ + apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ apt-transport-https \ curl \ default-mysql-client \ @@ -23,9 +23,9 @@ RUN \ xz-utils \ zip \ zsh \ - && apt autoremove -y --purge \ - && apt autoclean -y \ - && apt clean -y \ + && apt-get autoremove -y --purge \ + && apt-get autoclean -y \ + && apt-get clean -y \ && rm -rf /var/cache/debconf/*-old \ && rm -rf /usr/share/doc/* \ && rm -rf /var/lib/apt/lists/* \ @@ -35,7 +35,7 @@ RUN \ ARG PHP_VERSION=8.2 RUN \ LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php \ - && DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ php-pear \ php${PHP_VERSION}-cli \ php${PHP_VERSION}-common \ @@ -45,9 +45,9 @@ RUN \ php${PHP_VERSION}-sqlite3 \ php${PHP_VERSION}-xml \ php${PHP_VERSION}-zip \ - && apt autoremove -y --purge \ - && apt autoclean -y \ - && apt clean -y \ + && apt-get autoremove -y --purge \ + && apt-get autoclean -y \ + && apt-get clean -y \ && rm -rf /var/cache/debconf/*-old \ && rm -rf /usr/share/doc/* \ && rm -rf /var/lib/apt/lists/* \ @@ -74,27 +74,39 @@ RUN \ # https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope -ARG TARGETARCH +# ARG TARGETARCH -# Install node, npm and yarn -ARG NODE_VERSION="v16.17.1" +# # Install node, npm and yarn +# ARG NODE_VERSION="v16.17.1" +# RUN \ +# if [ "${TARGETARCH}" = "amd64" ]; then \ +# ARCHITECTURE=x64; \ +# elif [ "${TARGETARCH}" = "arm" ]; then \ +# ARCHITECTURE=armv7l; \ +# elif [ "${TARGETARCH}" = "arm64" ]; then \ +# ARCHITECTURE=arm64; \ +# else \ +# echo "Unknown TARGETARCH: '${TARGETARCH}'";\ +# exit 1; \ +# fi \ +# && curl -L "https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-${ARCHITECTURE}.tar.xz" \ +# --output node.tar.xz \ +# && tar xJf node.tar.xz -C /usr --strip-components=1 --no-same-owner \ +# && rm node.tar.xz \ +# && npm i -g yarn + +# https://github.com/nodesource/distributions/blob/master/README.md#installation-instructions RUN \ - if [ "${TARGETARCH}" = "amd64" ]; then \ - ARCHITECTURE=x64; \ - elif [ "${TARGETARCH}" = "arm" ]; then \ - ARCHITECTURE=armv7l; \ - elif [ "${TARGETARCH}" = "arm64" ]; then \ - ARCHITECTURE=arm64; \ - else \ - echo "Unknown TARGETARCH: '${TARGETARCH}'";\ - exit 1; \ - fi \ - && curl -L "https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-${ARCHITECTURE}.tar.xz" \ - --output node.tar.xz \ - && tar xJf node.tar.xz -C /usr --strip-components=1 --no-same-owner \ - && rm node.tar.xz \ - && npm i -g yarn - + curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \ + && apt-get install -y nodejs \ + && npm i -g yarn \ + && apt-get autoremove -y --purge \ + && apt-get autoclean -y \ + && apt-get clean -y \ + && rm -rf /var/cache/debconf/*-old \ + && rm -rf /usr/share/doc/* \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /var/cache/apt/* COPY zshrc /root/.zshrc diff --git a/Makefile b/Makefile index 8604669..8322351 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ TARGET=Dockerfile build_8: docker pull $(IMAGE):php8 || true; \ docker buildx build --rm . \ + --load -f $(TARGET) \ -t $(IMAGE):latest \ -t $(IMAGE):php8 @@ -12,6 +13,7 @@ build_8: build_71: docker buildx build --rm . \ -f $(TARGET) \ + --load \ --build-arg=PHP_VERSION="7.1" \ --build-arg=DEPLOYER_VERSION="v6.6.0" \ --build-arg=COMPOSER_VERSION="2.2.18" \