2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-11-09 23:00:56 +00:00

feat: make images arm64 compatible

This commit is contained in:
Revant Nandgaonkar 2021-01-08 17:45:22 +05:30
parent 823f960364
commit c90783d6be
7 changed files with 48 additions and 32 deletions

View File

@ -1,8 +1,8 @@
# Frappe Bench Dockerfile # Frappe Bench Dockerfile
FROM bitnami/minideb:latest FROM debian:buster-slim
LABEL author=frappé LABEL author=frappé
RUN install_packages \ RUN apt-get update -y && apt-get install \
git \ git \
wkhtmltopdf \ wkhtmltopdf \
mariadb-client \ mariadb-client \
@ -49,14 +49,18 @@ RUN install_packages \
python3-setuptools \ python3-setuptools \
python3-tk \ python3-tk \
python-virtualenv \ python-virtualenv \
less less -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
&& dpkg-reconfigure --frontend=noninteractive locales && dpkg-reconfigure --frontend=noninteractive locales
# Install wkhtmltox correctly # Detect arch, download and install wkhtmltox
RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.buster_amd64.deb RUN if [ `uname -m` = 'aarch64' ]; then export ARCH=arm64; fi \
RUN dpkg -i wkhtmltox_0.12.5-1.buster_amd64.deb && rm wkhtmltox_0.12.5-1.buster_amd64.deb && 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
# Create new user with home directory, improve docker compatibility with UID/GID 1000, add user to sudo group, allow passwordless sudo, switch to that user and change directory to user home directory # Create new user with home directory, improve docker compatibility with UID/GID 1000, add user to sudo group, allow passwordless sudo, switch to that user and change directory to user home directory
RUN groupadd -g 1000 frappe RUN groupadd -g 1000 frappe
@ -89,7 +93,7 @@ ENV NODE_VERSION=12.20.0
ENV NODE_VERSION_FRAPPEV11=10.23.0 ENV NODE_VERSION_FRAPPEV11=10.23.0
# Install nvm with node # Install nvm with node
RUN wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh RUN wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh
RUN chmod +x install.sh RUN chmod +x install.sh
RUN ./install.sh RUN ./install.sh
ENV NVM_DIR=/home/frappe/.nvm ENV NVM_DIR=/home/frappe/.nvm

View File

@ -1,13 +1,19 @@
ARG NODE_IMAGE_TAG=12-prod ARG NODE_IMAGE_TAG=12-buster-slim
ARG GIT_BRANCH=develop ARG GIT_BRANCH=develop
FROM bitnami/node:${NODE_IMAGE_TAG} ARG DOCKER_REGISTRY_PREFIX=frappe
FROM node:${NODE_IMAGE_TAG}
ARG GIT_BRANCH ARG GIT_BRANCH
COPY build/erpnext-nginx/install_app.sh /install_app COPY build/erpnext-nginx/install_app.sh /install_app
RUN chmod +x /install_app && \
apt-get update -y && \
apt-get install build-essential git python2 -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN /install_app erpnext https://github.com/frappe/erpnext ${GIT_BRANCH} RUN /install_app erpnext https://github.com/frappe/erpnext ${GIT_BRANCH}
FROM frappe/frappe-nginx:${GIT_BRANCH} FROM ${DOCKER_REGISTRY_PREFIX}/frappe-nginx:${GIT_BRANCH}
COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/ COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/
COPY --from=0 /rsync /rsync COPY --from=0 /rsync /rsync

View File

@ -10,8 +10,6 @@ mkdir -p /home/frappe/frappe-bench/sites/assets
cd /home/frappe/frappe-bench cd /home/frappe/frappe-bench
echo -e "frappe\n${APP_NAME}" > /home/frappe/frappe-bench/sites/apps.txt echo -e "frappe\n${APP_NAME}" > /home/frappe/frappe-bench/sites/apps.txt
install_packages git python2
mkdir -p apps mkdir -p apps
cd apps cd apps
git clone --depth 1 https://github.com/frappe/frappe ${BRANCH} git clone --depth 1 https://github.com/frappe/frappe ${BRANCH}
@ -20,9 +18,7 @@ git clone --depth 1 ${APP_REPO} ${BRANCH} ${APP_NAME}
cd /home/frappe/frappe-bench/apps/frappe cd /home/frappe/frappe-bench/apps/frappe
yarn yarn
yarn production --app ${APP_NAME} yarn production --app ${APP_NAME}
rm -fr node_modules
yarn install --production=true yarn install --production=true
yarn add node-sass
mkdir -p /home/frappe/frappe-bench/sites/assets/${APP_NAME} mkdir -p /home/frappe/frappe-bench/sites/assets/${APP_NAME}
cp -R /home/frappe/frappe-bench/apps/${APP_NAME}/${APP_NAME}/public/* /home/frappe/frappe-bench/sites/assets/${APP_NAME} cp -R /home/frappe/frappe-bench/apps/${APP_NAME}/${APP_NAME}/public/* /home/frappe/frappe-bench/sites/assets/${APP_NAME}

View File

@ -1,5 +1,6 @@
ARG GIT_BRANCH=develop ARG GIT_BRANCH=develop
FROM frappe/frappe-worker:${GIT_BRANCH} ARG DOCKER_REGISTRY_PREFIX=frappe
FROM ${DOCKER_REGISTRY_PREFIX}/frappe-worker:${GIT_BRANCH}
ARG GIT_BRANCH ARG GIT_BRANCH
RUN install_app erpnext https://github.com/frappe/erpnext ${GIT_BRANCH} RUN install_app erpnext https://github.com/frappe/erpnext ${GIT_BRANCH}

View File

@ -2,13 +2,16 @@
# This is done to ensures that node-sass binary remains common. # This is done to ensures that node-sass binary remains common.
# node-sass is required to enable website theme feature used # node-sass is required to enable website theme feature used
# by Website Manager role in Frappe Framework # by Website Manager role in Frappe Framework
FROM bitnami/python:3.7-prod FROM python:3.7-slim-buster
ENV NVM_DIR=/root/.nvm ENV NVM_DIR=/root/.nvm
ENV NODE_VERSION=12.20.0 ENV NODE_VERSION=12.20.0
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}" ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
RUN install_packages wget \ RUN apt-get update -y \
&& wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh \ && 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 \ && chmod +x install.sh \
&& ./install.sh \ && ./install.sh \
&& . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} \ && . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} \
@ -18,8 +21,6 @@ WORKDIR /home/frappe/frappe-bench
RUN mkdir -p /home/frappe/frappe-bench/sites \ RUN mkdir -p /home/frappe/frappe-bench/sites \
&& echo "frappe" > /home/frappe/frappe-bench/sites/apps.txt && echo "frappe" > /home/frappe/frappe-bench/sites/apps.txt
RUN install_packages git
ARG GIT_BRANCH=develop ARG GIT_BRANCH=develop
RUN mkdir -p apps sites/assets/css \ RUN mkdir -p apps sites/assets/css \
&& cd apps \ && cd apps \
@ -28,7 +29,6 @@ RUN mkdir -p apps sites/assets/css \
RUN cd /home/frappe/frappe-bench/apps/frappe \ RUN cd /home/frappe/frappe-bench/apps/frappe \
&& yarn \ && yarn \
&& yarn run production \ && yarn run production \
&& rm -fr node_modules \
&& yarn install --production=true && yarn install --production=true
RUN node --version \ RUN node --version \

View File

@ -1,4 +1,4 @@
FROM node:slim FROM node:buster-slim
# Add frappe user # Add frappe user
RUN useradd -ms /bin/bash frappe RUN useradd -ms /bin/bash frappe

View File

@ -1,11 +1,10 @@
FROM bitnami/python:3.7-prod FROM python:3.7-slim-buster
# Add non root user without password # Add non root user without password
RUN sed -i 's/^PASS_MAX_DAYS.*/PASS_MAX_DAYS -1/' /etc/login.defs \ RUN useradd -ms /bin/bash frappe
&& sed -i 's/^PASS_MIN_DAYS.*/PASS_MIN_DAYS -1/' /etc/login.defs \
&& useradd -ms /bin/bash frappe
ARG GIT_BRANCH=develop ARG GIT_BRANCH=develop
ARG ARCH=amd64
ENV PYTHONUNBUFFERED 1 ENV PYTHONUNBUFFERED 1
ENV NVM_DIR=/home/frappe/.nvm ENV NVM_DIR=/home/frappe/.nvm
ENV NODE_VERSION=12.20.0 ENV NODE_VERSION=12.20.0
@ -13,12 +12,14 @@ 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
RUN install_packages \ RUN apt-get update -y && apt-get install \
# for frappe framework
git \ git \
mariadb-client \ mariadb-client \
postgresql-client \ postgresql-client \
gettext-base \ gettext-base \
wget \ wget \
wait-for-it \
# for PDF # for PDF
libjpeg62-turbo \ libjpeg62-turbo \
libx11-6 \ libx11-6 \
@ -29,13 +30,21 @@ RUN install_packages \
fonts-cantarell \ fonts-cantarell \
xfonts-75dpi \ xfonts-75dpi \
xfonts-base \ xfonts-base \
libxml2 \
libffi-dev \
libjpeg-dev \
zlib1g-dev \
# For psycopg2 # For psycopg2
libpq-dev \ libpq-dev \
wait-for-it \ # For arm64 python wheel builds
&& wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.buster_amd64.deb \ gcc \
&& dpkg -i wkhtmltox_0.12.5-1.buster_amd64.deb && rm wkhtmltox_0.12.5-1.buster_amd64.deb \ g++ -y \
&& wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh \ # Detect arch, download and install wkhtmltox
&& apt-get purge -y wget && apt-get autoremove -y \ && 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 && chown -R frappe:frappe /home/frappe
USER frappe USER frappe