question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Looks like now arm64 architecture can be built and pushed to the official docker hub repository.

See original GitHub issue

When building arm64 images it would take more than couple of hours. Main reason, why it was very slow, pandas wheels were being build while docker image was being built.

Looks like that issue is gone. I have managed to build frappe-nginx, frappe-worker, frappe-socketio, erpnext-nginx, erpnext-worker under half an hour, all 5 images combined.

I have built the images from develop branches.

I had to add one line in 2 dockerfiles, for the process to work. Because there are some smaller wheels are still being built while building images, so pip3 was required. I showed the lines that I added/modified below just to explain myself properly.

Dockerfile of frappe-worker


# Add non root user without password
RUN useradd -ms /bin/bash frappe

ARG GIT_REPO=https://github.com/frappe/frappe
ARG GIT_BRANCH=develop
ARG ARCH=amd64
ENV PYTHONUNBUFFERED 1
ENV NVM_DIR=/home/frappe/.nvm
ENV NODE_VERSION=14.17.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 \
    #######################
    python3-pip \  ############  This is the line that I added
    ########################
    # 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.38.0/install.sh \
    && chown -R frappe:frappe /home/frappe

# Setup docker-entrypoint
COPY build/common/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 \
    && pip3 install --upgrade pip \
    && pip3 install gevent \
    && cd apps \
    && git clone --depth 1 -o upstream ${GIT_REPO} --branch ${GIT_BRANCH} \
    && pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/frappe

# Copy scripts and templates
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/worker/install_app.sh /usr/local/bin/install_app
COPY build/common/worker/bench /usr/local/bin/bench
COPY build/common/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"]

Dockerfile of 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

ARG GIT_REPO=https://github.com/frappe/frappe
ARG GIT_BRANCH=develop

ENV NVM_DIR=/root/.nvm
ENV NODE_VERSION=14.17.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 python3-pip -y \########### This is the line I have modified
##################################################################################
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* \
    && wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/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

RUN mkdir -p apps sites/assets/css  \
    && cd apps \
    && git clone --depth 1 ${GIT_REPO} --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 build/common/nginx-default.conf.template /etc/nginx/conf.d/default.conf.template
COPY 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;"]

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:28 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
artykbasarcommented, Jun 28, 2021

OK I will try it today

0reactions
carstenbltcommented, Dec 16, 2022

Hey @carstenblt , can you please elaborate more on this. I mean what did you update in CMD part of redis and how were you able to build the arm64 images for frappe? Thanks!

Building is as simple as

REGISTRY_USER=XXX FRAPPE_VERSION=v14.19.1 ERPNEXT_VERSION=v14.10.1 docker buildx bake -f docker-bake.hcl --progress auto --set "*.platform=linux/arm64" erpnext-worker erpnext-nginx frappe-socketio

As for redis, you just have to change CMD to redis-server --port XXXX. I’m running on AWS ECS, this definition should give you the gist:

"containerDefinitions": [
        {
            "name": "cache",
            "image": "redis:6.2-alpine",
            "portMappings": [
                {
                    "containerPort": 13000,
                    "hostPort": 13000,
                    "protocol": "tcp"
                }
            ],
            "essential": true,
            "command": [
                "redis-server",
                "--port",
                "13000"
            ]
      },
      ...
],
Read more comments on GitHub >

github_iconTop Results From Across the Web

Multi-platform images | Docker Documentation
Using the standard Docker tooling and processes, you can start to build, push, pull, and run images seamlessly on different compute architectures. In...
Read more >
Multi-architecture images - Getting started with Docker
In this section of the guide, we explain multi-architecture containers. Multi-architecture containers support execution as an Arm image or as an x86 image....
Read more >
Creating Lambda container images - AWS Documentation
Lambda does not support functions that use multi-architecture container images. ... For example, you can use the Docker CLI to build, test, and...
Read more >
Building Multi-Architecture Docker Images on ARM 64-bit ...
Developers need to be able to run their CI/CD generated Docker images locally. For the foreseeable future, developer machines will continue to use...
Read more >
Docker image for ARM and other architectures - Padok
Now that your environment is set up, you can successfully build your app for several platforms with the --platforms flag, for example here...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found