2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-12-23 18:48:58 +00:00

Merge pull request #330 from revant/fix-node-sass

fix: add nodejs via nvm
This commit is contained in:
Revant Nandgaonkar 2020-08-07 23:08:43 +05:30 committed by GitHub
commit 9974a63dc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 28 deletions

View File

@ -71,6 +71,10 @@ fi
# Allow user process to create files in logs directory # Allow user process to create files in logs directory
chown -R frappe:frappe /home/frappe/frappe-bench/logs chown -R frappe:frappe /home/frappe/frappe-bench/logs
# symlink node_modules
ln -sfn /home/frappe/frappe-bench/sites/assets/frappe/node_modules \
/home/frappe/frappe-bench/apps/frappe/node_modules
if [ "$1" = 'start' ]; then if [ "$1" = 'start' ]; then
configureEnv configureEnv
checkConnection checkConnection

View File

@ -1,5 +1,18 @@
ARG NODE_IMAGE_TAG=12-prod # This image uses nvm and same base image as the worker image.
FROM bitnami/node:${NODE_IMAGE_TAG} # 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 bitnami/python:3.7-prod
ENV NVM_DIR=/root/.nvm
ENV NODE_VERSION=12.18.3
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
RUN install_packages wget \
&& wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/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 WORKDIR /home/frappe/frappe-bench
RUN mkdir -p /home/frappe/frappe-bench/sites \ RUN mkdir -p /home/frappe/frappe-bench/sites \
@ -12,9 +25,6 @@ RUN mkdir -p apps sites/assets/css \
&& cd apps \ && cd apps \
&& git clone --depth 1 https://github.com/frappe/frappe --branch $GIT_BRANCH && git clone --depth 1 https://github.com/frappe/frappe --branch $GIT_BRANCH
COPY build/frappe-nginx/generate_standard_style_css.js \
/home/frappe/frappe-bench/apps/frappe/generate_standard_style_css.js
COPY build/frappe-nginx/build.sh /build.sh COPY build/frappe-nginx/build.sh /build.sh
RUN /build.sh RUN /build.sh
RUN node --version \ RUN node --version \

View File

@ -8,16 +8,11 @@ function nodeCleanUp() {
cd /home/frappe/frappe-bench/apps/frappe cd /home/frappe/frappe-bench/apps/frappe
yarn yarn
yarn run production yarn run production
yarn add nunjucks -D
if [[ "$GIT_BRANCH" =~ ^(version-12|version-11)$ ]]; then if [[ "$GIT_BRANCH" =~ ^(version-12|version-11)$ ]]; then
nodeCleanUp nodeCleanUp
else else
node generate_standard_style_css.js \
frappe/website/doctype/website_theme/website_theme_template.scss > \
/home/frappe/standard_templates_string
node generate_bootstrap_theme.js \
/home/frappe/frappe-bench/sites/assets/css/standard_style.css \
"$(cat /home/frappe/standard_templates_string)"
nodeCleanUp nodeCleanUp
# remove this when frappe framework moves this to dependencies from devDependencies
yarn add node-sass
fi fi

View File

@ -1,14 +0,0 @@
const nunjucks = require("nunjucks");
const templatePath = process.argv[2];
const pathArray = templatePath.split("/");
const templateFile = pathArray.pop();
const templateDir = pathArray.join("/");
nunjucks.configure(templateDir);
const rendered = nunjucks.render(templateFile, {
button_rounded_corners: true,
font_properties: "300,600",
});
console.log(rendered.replace(/\n/gm, "\\n"));

View File

@ -4,6 +4,9 @@ RUN useradd -ms /bin/bash frappe
ARG GIT_BRANCH=develop ARG GIT_BRANCH=develop
ENV PYTHONUNBUFFERED 1 ENV PYTHONUNBUFFERED 1
ENV NVM_DIR=/home/frappe/.nvm
ENV NODE_VERSION=12.18.3
ENV PATH="/home/frappe/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
# Install dependencies # Install dependencies
WORKDIR /home/frappe/frappe-bench WORKDIR /home/frappe/frappe-bench
@ -27,7 +30,17 @@ RUN install_packages \
libpq-dev \ libpq-dev \
&& wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.buster_amd64.deb \ && wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.buster_amd64.deb \
&& dpkg -i wkhtmltox_0.12.5-1.buster_amd64.deb && rm wkhtmltox_0.12.5-1.buster_amd64.deb \ && dpkg -i wkhtmltox_0.12.5-1.buster_amd64.deb && rm wkhtmltox_0.12.5-1.buster_amd64.deb \
&& apt-get purge -y wget && apt-get autoremove -y && wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh \
&& apt-get purge -y wget && apt-get autoremove -y \
&& chown -R frappe:frappe /home/frappe
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 # Create frappe-bench directories
RUN mkdir -p apps logs commands /home/frappe/backups RUN mkdir -p apps logs commands /home/frappe/backups
@ -39,6 +52,7 @@ RUN python -m venv env \
&& git clone --depth 1 -o upstream https://github.com/frappe/frappe --branch ${GIT_BRANCH} \ && 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 && pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/frappe
USER root
# Copy scripts and templates # Copy scripts and templates
COPY build/common/commands/* /home/frappe/frappe-bench/commands/ COPY build/common/commands/* /home/frappe/frappe-bench/commands/
COPY build/common/common_site_config.json.template /opt/frappe/common_site_config.json.template COPY build/common/common_site_config.json.template /opt/frappe/common_site_config.json.template
@ -52,7 +66,7 @@ RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat
WORKDIR /home/frappe/frappe-bench/sites WORKDIR /home/frappe/frappe-bench/sites
# Set ownership of sites directory # Set ownership of sites directory
RUN chown -R frappe:frappe /home/frappe/frappe-bench/sites /home/frappe/backups RUN chown -R frappe:frappe /home/frappe/frappe-bench/sites
VOLUME [ "/home/frappe/frappe-bench/sites", "/home/frappe/backups" ] VOLUME [ "/home/frappe/frappe-bench/sites", "/home/frappe/backups" ]