Tobey
January 29, 2021, 9:37pm
1
Hello all… I am new here. I started at new project and using Frappe ERPNext. I have it up and running on AWS ECS Fargate using AWS Service Discovery. I used the Docker Hub Images “Version-12” for all the services. Everything seem seems to running fine. When trying to add a custom theme under Website and I add Custom CSS into to the Theme field. I get an error Module Not Found for node-sass. I found this issue: Can not update Website_Theme, Missing Node... · Issue #229 · frappe/frappe_docker · GitHub it says it was merged but yet I am still getting this error. What am I doing wrong??
Also what node is doing the action? nginx or worker?
Thank you for your time.
erpnext 12.17.0
frappe 12.14.0
internal/modules/cjs/loader.js:818
throw err;
^
Error: Cannot find module ‘node-sass’
Require stack:
/home/frappe/frappe-bench/apps/frappe/generate_bootstrap_theme.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/home/frappe/frappe-bench/apps/frappe/generate_bootstrap_theme.js:1:14)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
code: ‘MODULE_NOT_FOUND’,
requireStack: [
‘/home/frappe/frappe-bench/apps/frappe/generate_bootstrap_theme.js’
]
}
Works in PWD and on my k8s cluster.
erpnext-nginx and erpnext-python containers mount 2 volumes
nginx container copies node_modules from self to assets-vol
python container copies node_modules from assets-vol to sites/assets
This makes node-sass available for python container.
Make sure volumes are mounted.
Tobey
January 30, 2021, 12:56pm
3
After looking a the commit to fix the node-sass, I went in and looked at the Docker images. (fix(erpnext-nginx): add node-sass as production dependency by revant · Pull Request #341 · frappe/frappe_docker · GitHub ) I don’t see where yarn add node-sass is in the install_app.sh file like it says in . I added it and did a build on the image. I then deployed the updated image and cycled all the tasks and I am still seeing this issue. Should I be on the edge ver for production?
Thank you.
That is not required anymore, node-sass is now added as dependency instead of devDependencies.
Also this is available in v13 beta and edge. Not on v12
Tobey
January 31, 2021, 7:21pm
5
@revant_one thank you for the time. This helped me out a lot I had to move up to edge. I am happy I found this before we started to build the apps. Thank you agin…
Hi Tobey, how did you fix this?
Tobey
August 21, 2021, 4:10pm
7
Hi Regren… I upgraded to Frappe V13 fixed the devDependencies… I have it working fine in production.
1 Like
I having the same problem with v13. What else do you think I should do? I’m using frappe_docker by the way, and my deployment is failing during installation because I’ve got fixtures with Website Theme.
Tobey
August 22, 2021, 1:58pm
9
I am running on AWS. Using ECS Fargate. I have it broken down into Services based on the Frappe Docker GITHUB . Below is my current running Frappe Cluster Dockerfiles. The ECS Cluster tasks are based on the Docker-Compose file in the same Frappe Docker GITHUB. The Frappe Worker Docker image is reused for every service but nginx and socketio . I hope this is helpful.
Dockerfile Frappe Nginx:
# This image uses nvm and same base image as the worker image.
# This is done to ensures that node-sass binary remains common.
# node-sass is required to enable website theme feature used
# by Website Manager role in Frappe Framework
FROM python:3.7-slim-buster
ENV NVM_DIR=/root/.nvm
ENV NODE_VERSION=12.20.0
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
RUN apt-get update -y \
&& apt-get install wget python2 git build-essential -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh \
&& chmod +x install.sh \
&& ./install.sh \
&& . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} \
&& nvm use v${NODE_VERSION} && npm install -g yarn
WORKDIR /home/frappe/frappe-bench
RUN mkdir -p /home/frappe/frappe-bench/sites \
&& echo "frappe" > /home/frappe/frappe-bench/sites/apps.txt
ARG GIT_BRANCH=version-13
RUN mkdir -p apps sites/assets/css \
&& cd apps \
&& git clone --depth 1 https://github.com/frappe/frappe --branch $GIT_BRANCH
RUN cd /home/frappe/frappe-bench/apps/frappe \
&& yarn \
&& yarn run production \
&& yarn install --production=true
RUN node --version \
&& npm --version \
&& yarn --version
RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \
&& mkdir -p /var/www/error_pages \
&& cp -r /tmp/bench/bench/config/templates /var/www/error_pages
RUN mkdir -p /home/frappe/frappe-bench/sites/assets/frappe/ \
&& cp -R /home/frappe/frappe-bench/apps/frappe/frappe/public/* /home/frappe/frappe-bench/sites/assets/frappe \
&& cp -R /home/frappe/frappe-bench/apps/frappe/node_modules /home/frappe/frappe-bench/sites/assets/frappe/
FROM nginx:latest
COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/
COPY --from=0 /var/www/error_pages /var/www/
COPY ${PWD}/build/frappe-nginx/nginx-default.conf.template /etc/nginx/conf.d/default.conf.template
COPY ${PWD}/build/frappe-nginx/docker-entrypoint.sh /
RUN apt-get update && apt-get install -y rsync && apt-get clean \
&& echo "#!/bin/bash" > /rsync \
&& chmod +x /rsync
VOLUME [ "/assets" ]
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
Dockerfile Frappe Socketio:
FROM node:buster-slim
# Add frappe user
RUN useradd -ms /bin/bash frappe
# Create bench directories and set ownership
RUN mkdir -p /home/frappe/frappe-bench/sites /home/frappe/frappe-bench/apps/frappe \
&& chown -R frappe:frappe /home/frappe
# Download socketio and purge curl package
COPY ${PWD}/build/frappe-socketio/package.json /home/frappe/frappe-bench/apps/frappe
ARG GIT_BRANCH=version-13
RUN apt-get update && apt-get install -y curl \
&& cd /home/frappe/frappe-bench/apps/frappe \
&& curl "https://raw.githubusercontent.com/frappe/frappe/$GIT_BRANCH/socketio.js" \
--output /home/frappe/frappe-bench/apps/frappe/socketio.js \
&& curl "https://raw.githubusercontent.com/frappe/frappe/$GIT_BRANCH/node_utils.js" \
--output /home/frappe/frappe-bench/apps/frappe/node_utils.js \
&& apt-get purge -y curl && apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*
RUN cd /home/frappe/frappe-bench/apps/frappe \
&& npm install --only=production \
&& node --version \
&& npm --version
# Setup docker-entrypoint
COPY ${PWD}/build/frappe-socketio/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat
USER frappe
WORKDIR /home/frappe/frappe-bench/sites
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["start"]
Dockerfile Frappe Worker / Python:
FROM python:3.7-slim-buster
# Add non root user without password
RUN useradd -ms /bin/bash frappe
ARG GIT_BRANCH=version-13
ARG ARCH=amd64
ENV PYTHONUNBUFFERED 1
ENV NVM_DIR=/home/frappe/.nvm
ENV NODE_VERSION=12.20.0
ENV PATH="/home/frappe/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
# Install dependencies
WORKDIR /home/frappe/frappe-bench
RUN apt-get update -y && apt-get install \
# for frappe framework
git \
mariadb-client \
postgresql-client \
gettext-base \
wget \
wait-for-it \
# for PDF
libjpeg62-turbo \
libx11-6 \
libxcb1 \
libxext6 \
libxrender1 \
libssl-dev \
fonts-cantarell \
xfonts-75dpi \
xfonts-base \
libxml2 \
libffi-dev \
libjpeg-dev \
zlib1g-dev \
# For psycopg2
libpq-dev \
# For arm64 python wheel builds
gcc \
g++ -y \
# Detect arch, download and install wkhtmltox
&& if [ `uname -m` = 'aarch64' ]; then export ARCH=arm64; fi \
&& if [ `uname -m` = 'x86_64' ]; then export ARCH=amd64; fi \
&& wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_${ARCH}.deb \
&& dpkg -i wkhtmltox_0.12.6-1.buster_${ARCH}.deb && rm wkhtmltox_0.12.6-1.buster_${ARCH}.deb \
&& wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh \
&& chown -R frappe:frappe /home/frappe
# Setup docker-entrypoint
COPY ${PWD}/build/frappe-worker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat
USER frappe
# Install nvm with node
RUN bash install.sh \
&& . "$NVM_DIR/nvm.sh" \
&& nvm install ${NODE_VERSION} \
&& nvm use v${NODE_VERSION} \
&& nvm alias default v${NODE_VERSION}
# Create frappe-bench directories
RUN mkdir -p apps logs commands sites /home/frappe/backups
# Setup python environment
RUN python -m venv env \
&& . env/bin/activate \
&& cd apps \
&& git clone --depth 1 -o upstream https://github.com/frappe/frappe --branch ${GIT_BRANCH} \
&& pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/frappe
# Copy scripts and templates
COPY ${PWD}/build/frappe-worker/commands/* /home/frappe/frappe-bench/commands/
COPY ${PWD}/build/frappe-worker/common_site_config.json.template /opt/frappe/common_site_config.json.template
COPY ${PWD}/build/frappe-worker/install_app.sh /usr/local/bin/install_app
COPY ${PWD}/build/frappe-worker/bench /usr/local/bin/bench
COPY ${PWD}/build/frappe-worker/healthcheck.sh /usr/local/bin/healthcheck.sh
# Use sites volume as working directory
WORKDIR /home/frappe/frappe-bench/sites
VOLUME [ "/home/frappe/frappe-bench/sites", "/home/frappe/backups", "/home/frappe/frappe-bench/logs" ]
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["start"]
2 Likes