From 8e7f8b3b716fd7790e50f7adcd91d3b5efbe1ec2 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Wed, 19 Oct 2022 14:22:07 +0530 Subject: [PATCH] fix: install correct nodejs as per frappe version (#970) fixes #967, #969 --- docker-bake.hcl | 3 ++- images/nginx/Dockerfile | 6 +++++- images/worker/Dockerfile | 21 ++++++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/docker-bake.hcl b/docker-bake.hcl index 4196372d..72eb9d9a 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -73,7 +73,8 @@ target "default-args" { BENCH_REPO = "${BENCH_REPO}" FRAPPE_VERSION = "${FRAPPE_VERSION}" ERPNEXT_VERSION = "${ERPNEXT_VERSION}" - PYTHON_VERSION = can(regex("v13", "${ERPNEXT_VERSION}")) ? "3.9" : "3.10" + PYTHON_VERSION = can(regex("v13", "${ERPNEXT_VERSION}")) ? "3.9.9" : "3.10.5" + NODE_VERSION = can(regex("v13", "${FRAPPE_VERSION}")) ? "14.19.3" : "16.18.0" } } diff --git a/images/nginx/Dockerfile b/images/nginx/Dockerfile index bbbed49c..0c8a8603 100644 --- a/images/nginx/Dockerfile +++ b/images/nginx/Dockerfile @@ -2,7 +2,11 @@ FROM frappe/bench:latest as assets_builder ARG FRAPPE_VERSION ARG FRAPPE_REPO=https://github.com/frappe/frappe -RUN bench init --version=${FRAPPE_VERSION} --frappe-path=${FRAPPE_REPO} --skip-redis-config-generation --verbose --skip-assets /home/frappe/frappe-bench +ARG PYTHON_VERSION +ARG NODE_VERSION +ENV NVM_DIR=/home/frappe/.nvm +ENV PATH ${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH} +RUN PYENV_VERSION=${PYTHON_VERSION} bench init --version=${FRAPPE_VERSION} --frappe-path=${FRAPPE_REPO} --skip-redis-config-generation --verbose --skip-assets /home/frappe/frappe-bench WORKDIR /home/frappe/frappe-bench diff --git a/images/worker/Dockerfile b/images/worker/Dockerfile index 71d0ff52..76e281d6 100644 --- a/images/worker/Dockerfile +++ b/images/worker/Dockerfile @@ -65,15 +65,27 @@ RUN --mount=type=cache,target=/root/.cache/pip \ && git clone --depth 1 -b ${ERPNEXT_VERSION} ${ERPNEXT_REPO} apps/erpnext \ && install-app erpnext - FROM base as configured_base ARG WKHTMLTOPDF_VERSION=0.12.6-1 - +ARG NODE_VERSION +ENV NVM_DIR=/home/frappe/.nvm +ENV PATH ${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH} RUN apt-get update \ # Setup Node lists && apt-get install --no-install-recommends -y curl \ - && curl -sL https://deb.nodesource.com/setup_14.x | bash - \ + # NodeJS with NVM + && mkdir -p ${NVM_DIR} \ + && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash \ + && . ${NVM_DIR}/nvm.sh \ + && nvm install ${NODE_VERSION} \ + && nvm use v${NODE_VERSION} \ + && npm install -g yarn \ + && nvm alias default v${NODE_VERSION} \ + && rm -rf ${NVM_DIR}/.cache \ + && echo 'export NVM_DIR="/home/frappe/.nvm"' >>~/.bashrc \ + && echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm' >> ~/.bashrc \ + && echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> ~/.bashrc \ # Install wkhtmltopdf with patched qt && if [ "$(uname -m)" = "aarch64" ]; then export ARCH=arm64; fi \ && if [ "$(uname -m)" = "x86_64" ]; then export ARCH=amd64; fi \ @@ -92,8 +104,7 @@ RUN apt-get update \ # For healthcheck wait-for-it \ jq \ - # other - nodejs \ + # Clean up && rm -rf /var/lib/apt/lists/* COPY pretend-bench.sh /usr/local/bin/bench