From 3d664764d12d24cddcde9bc4b9c999f4ebe1c27d Mon Sep 17 00:00:00 2001 From: JJ-Cronos Date: Thu, 27 Mar 2025 12:12:54 +0200 Subject: [PATCH 1/6] ci: Remove apps list from git --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index e2fca77d..edbc83a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,12 @@ # Environment Variables .env +# Custom Apps +# Custom apps should be set when the image is built +apps.json +apps-test-output.json + + # mounted volume sites From 8312c3f6e0ebb1d0c5944ba19b667f048dcdc226 Mon Sep 17 00:00:00 2001 From: JJ-Cronos Date: Thu, 27 Mar 2025 12:13:09 +0200 Subject: [PATCH 2/6] feat: Update production image --- compose.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index 67f8e06d..84aa9217 100644 --- a/compose.yaml +++ b/compose.yaml @@ -2,7 +2,8 @@ x-customizable-image: &customizable_image # By default the image used only contains the `frappe` and `erpnext` apps. # about using custom images. #TODO Replace Image with Custom Image for production. See https://github.com/frappe/frappe_docker/blob/main/docs/custom-apps.md - image: frappe/erpnext:${ERPNEXT_VERSION:?No ERPNext version set} + image: rafnav/rafnav_bench:1.0 + pull_policy: ${PULL_POLICY:-always} x-depends-on-configurator: &depends_on_configurator depends_on: From 589ebcef4dbf027a33eafd42fda85af53959032f Mon Sep 17 00:00:00 2001 From: JJ-Cronos Date: Thu, 27 Mar 2025 12:14:29 +0200 Subject: [PATCH 3/6] Fix: remove erpnext from env example --- example.env | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/example.env b/example.env index 0cc52a34..8182daf9 100644 --- a/example.env +++ b/example.env @@ -1,7 +1,5 @@ # Reference: https://github.com/frappe/frappe_docker/blob/main/docs/images-and-compose-files.md -ERPNEXT_VERSION=v15.23.1 - DB_PASSWORD=123 # Only if you use external database @@ -13,7 +11,7 @@ REDIS_CACHE= REDIS_QUEUE= # Only with HTTPS override -LETSENCRYPT_EMAIL=mail@example.com +LETSENCRYPT_EMAIL=example@example.com # These environment variables are not required. @@ -46,4 +44,4 @@ CLIENT_MAX_BODY_SIZE= # List of sites for letsencrypt certificates quoted with backtick (`) and separated by comma (,) # More https://doc.traefik.io/traefik/routing/routers/#rule # About acme https://doc.traefik.io/traefik/https/acme/#domain-definition -SITES=`erp.example.com` +SITES= From 42297d6450254ff9add85a699cf6d06e238a0809 Mon Sep 17 00:00:00 2001 From: JJ-Cronos Date: Thu, 27 Mar 2025 12:14:44 +0200 Subject: [PATCH 4/6] fix: Remove custom docker image --- images/custom/Dockerfile | 170 --------------------------------------- 1 file changed, 170 deletions(-) delete mode 100644 images/custom/Dockerfile diff --git a/images/custom/Dockerfile b/images/custom/Dockerfile deleted file mode 100644 index faaec0a2..00000000 --- a/images/custom/Dockerfile +++ /dev/null @@ -1,170 +0,0 @@ -FROM debian:bookworm-slim as bench - -LABEL author=frappé - -ARG GIT_REPO=https://github.com/frappe/bench.git -ARG GIT_BRANCH=v5.x - -RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ - # For frappe framework - git \ - mariadb-client \ - postgresql-client \ - gettext-base \ - wget \ - # for PDF - libssl-dev \ - fonts-cantarell \ - xfonts-75dpi \ - xfonts-base \ - # weasyprint dependencies - libpango-1.0-0 \ - libharfbuzz0b \ - libpangoft2-1.0-0 \ - libpangocairo-1.0-0 \ - # to work inside the container - locales \ - build-essential \ - cron \ - curl \ - vim \ - sudo \ - iputils-ping \ - watch \ - tree \ - nano \ - less \ - software-properties-common \ - bash-completion \ - # For psycopg2 - libpq-dev \ - # Other - libffi-dev \ - liblcms2-dev \ - libldap2-dev \ - libmariadb-dev \ - libsasl2-dev \ - libtiff5-dev \ - libwebp-dev \ - redis-tools \ - rlwrap \ - tk8.6-dev \ - ssh-client \ - # VSCode container requirements - net-tools \ - # For pyenv build dependencies - # https://github.com/frappe/frappe_docker/issues/840#issuecomment-1185206895 - make \ - # For pandas - libbz2-dev \ - # For bench execute - libsqlite3-dev \ - # For other dependencies - zlib1g-dev \ - libreadline-dev \ - llvm \ - libncurses5-dev \ - libncursesw5-dev \ - xz-utils \ - tk-dev \ - liblzma-dev \ - file \ - && 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 \ - && dpkg-reconfigure --frontend=noninteractive locales - -# Detect arch and install wkhtmltopdf -ARG WKHTMLTOPDF_VERSION=0.12.6.1-3 -ARG WKHTMLTOPDF_DISTRO=bookworm -RUN if [ "$(uname -m)" = "aarch64" ]; then export ARCH=arm64; fi \ - && if [ "$(uname -m)" = "x86_64" ]; then export ARCH=amd64; fi \ - && downloaded_file=wkhtmltox_${WKHTMLTOPDF_VERSION}.${WKHTMLTOPDF_DISTRO}_${ARCH}.deb \ - && wget -q https://github.com/wkhtmltopdf/packaging/releases/download/$WKHTMLTOPDF_VERSION/$downloaded_file \ - && dpkg -i $downloaded_file \ - && rm $downloaded_file - -# 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 \ - && useradd --no-log-init -r -m -u 1000 -g 1000 -G sudo frappe \ - && echo "frappe ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers - -USER frappe -WORKDIR /home/frappe - -# Install Python via pyenv -ENV PYTHON_VERSION_V14=3.10.13 -ENV PYTHON_VERSION=3.12.3 -ENV PYENV_ROOT /home/frappe/.pyenv -ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH - -# From https://github.com/pyenv/pyenv#basic-github-checkout -RUN git clone --depth 1 https://github.com/pyenv/pyenv.git .pyenv \ - && pyenv install $PYTHON_VERSION_V14 \ - && pyenv install $PYTHON_VERSION \ - && PYENV_VERSION=$PYTHON_VERSION_V14 pip install --no-cache-dir virtualenv \ - && PYENV_VERSION=$PYTHON_VERSION pip install --no-cache-dir virtualenv \ - && pyenv global $PYTHON_VERSION $PYTHON_VERSION_v14 \ - && sed -Ei -e '/^([^#]|$)/ {a export PYENV_ROOT="/home/frappe/.pyenv" a export PATH="$PYENV_ROOT/bin:$PATH" a ' -e ':a' -e '$!{n;ba};}' ~/.profile \ - && echo 'eval "$(pyenv init --path)"' >>~/.profile \ - && echo 'eval "$(pyenv init -)"' >>~/.bashrc - -# Clone and install bench in the local user home directory -# For development, bench source is located in ~/.bench -ENV PATH /home/frappe/.local/bin:$PATH -# Skip editable-bench warning -# https://github.com/frappe/bench/commit/20560c97c4246b2480d7358c722bc9ad13606138 -RUN git clone ${GIT_REPO} --depth 1 -b ${GIT_BRANCH} .bench \ - && pip install --no-cache-dir --user -e .bench \ - && echo "export PATH=/home/frappe/.local/bin:\$PATH" >>/home/frappe/.bashrc \ - && echo "export BENCH_DEVELOPER=1" >>/home/frappe/.bashrc - -# Install homebrew and wget -RUN /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" \ - && (echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/frappe/.profile \ - && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" \ - && brew install gcc \ - && brew install wget - -# Add aliases -RUN touch $HOME/.bash_aliases \ - && echo "alias py='python'" >> $HOME/.bash_aliases \ - && echo "alias frap-install='py installer.py'" >> $HOME/.bash_aliases - -# Install Node via nvm -ENV NODE_VERSION_STABLE=16.20.2 -ENV NODE_VERSION=20.13.1 -ENV NVM_DIR /home/frappe/.nvm -ENV PATH ${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH} - -RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \ - && . ${NVM_DIR}/nvm.sh \ - && nvm install ${NODE_VERSION_STABLE} \ - && nvm use v${NODE_VERSION_STABLE} \ - && npm install -g yarn \ - && nvm install v${NODE_VERSION} \ - && npm install -g yarn \ - && 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 - -EXPOSE 8000-8005 9000-9005 6787 - -FROM bench as bench-test - -# Print version and verify bashrc is properly sourced so that everything works -# in the interactive shell and Dockerfile - -RUN node --version \ - && npm --version \ - && yarn --version \ - && bench --help - -RUN bash -c "node --version" \ - && bash -c "npm --version" \ - && bash -c "yarn --version" \ - && bash -c "bench --help" From d4fa1c6ef090fd1636e3e3ceb4cec99f19d872dc Mon Sep 17 00:00:00 2001 From: JJ-Cronos Date: Thu, 27 Mar 2025 12:17:38 +0200 Subject: [PATCH 5/6] fix: Update development image - Reogranise docker file - remove depr python & erpnext v14 - update dev alias - bump node to v22.14.0 --- images/{rafnav_bench => development}/Dockerfile | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) rename images/{rafnav_bench => development}/Dockerfile (90%) diff --git a/images/rafnav_bench/Dockerfile b/images/development/Dockerfile similarity index 90% rename from images/rafnav_bench/Dockerfile rename to images/development/Dockerfile index 057fdb50..29206291 100644 --- a/images/rafnav_bench/Dockerfile +++ b/images/development/Dockerfile @@ -96,16 +96,13 @@ USER frappe WORKDIR /home/frappe # Install Python via pyenv -ENV PYTHON_VERSION_V14=3.10.13 ENV PYTHON_VERSION=3.12.3 ENV PYENV_ROOT /home/frappe/.pyenv ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH # From https://github.com/pyenv/pyenv#basic-github-checkout RUN git clone --depth 1 https://github.com/pyenv/pyenv.git .pyenv \ - && pyenv install $PYTHON_VERSION_V14 \ && pyenv install $PYTHON_VERSION \ - && PYENV_VERSION=$PYTHON_VERSION_V14 pip install --no-cache-dir virtualenv \ && PYENV_VERSION=$PYTHON_VERSION pip install --no-cache-dir virtualenv \ && pyenv global $PYTHON_VERSION $PYTHON_VERSION_v14 \ && sed -Ei -e '/^([^#]|$)/ {a export PYENV_ROOT="/home/frappe/.pyenv" a export PATH="$PYENV_ROOT/bin:$PATH" a ' -e ':a' -e '$!{n;ba};}' ~/.profile \ @@ -127,23 +124,20 @@ RUN git clone ${GIT_REPO} --depth 1 -b ${GIT_BRANCH} .bench \ RUN touch ~/.bash_aliases \ && echo 'alias py="python"' >> ~/.bash_aliases \ && echo 'alias frap-install="py installer.py"'>> ~/.bash_aliases \ - && echo 'alias install-rafnav="bench install-app erpnext documentation lending filing matter_management lrms raf_finance rafnav_core"' >> ~/.bash_aliases \ + && echo 'alias install-rafnav="bench install-app documentation filing matter_management raf_finance rafnav_core"' >> ~/.bash_aliases \ && echo 'alias install-site-rafnav="bench new-site rafnav.localhost && bench use rafnav.localhost && install-rafnav"' >> ~/.bash_aliases \ - && echo 'alias start-dev="cd /workspace/development/rafnav_bench && bench start"' >> ~/.bash_aliases + && echo 'alias start-dev="cd /workspace/development/rafnav_bench && bench start && cd apps/matter_management/rafnav_ui && yarn dev"' >> ~/.bash_aliases # Install Node via nvm -ENV NODE_VERSION_STABLE=16.20.2 -ENV NODE_VERSION=20.13.1 +ENV NODE_VERSION=22.14.0 ENV NVM_DIR /home/frappe/.nvm ENV PATH ${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH} RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \ && . ${NVM_DIR}/nvm.sh \ - && nvm install ${NODE_VERSION_STABLE} \ - && nvm use v${NODE_VERSION_STABLE} \ - && npm install -g yarn \ - && nvm install v${NODE_VERSION} \ + && nvm install ${NODE_VERSION} \ + && nvm use v${NODE_VERSION} \ && npm install -g yarn \ && rm -rf ${NVM_DIR}/.cache \ && echo 'export NVM_DIR="/home/frappe/.nvm"' >>~/.bashrc \ From e410c5938f4c07d215eebbf37c17800266a35558 Mon Sep 17 00:00:00 2001 From: JJ-Cronos Date: Thu, 27 Mar 2025 12:20:01 +0200 Subject: [PATCH 6/6] feat: Update production image - Bump python to 3.12.3 - bump node to v22.14.0 - update dependencies from Frappe Docker repo - use custom-apps config from Frappe Docker Repo - Add rafnav apps to image - add prod build cmd to installation script --- images/production/Containerfile | 55 +++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/images/production/Containerfile b/images/production/Containerfile index c4eeff8b..b7a8d00f 100644 --- a/images/production/Containerfile +++ b/images/production/Containerfile @@ -1,12 +1,15 @@ -ARG PYTHON_VERSION=3.11.6 +ARG PYTHON_VERSION=3.12.3 ARG DEBIAN_BASE=bookworm FROM python:${PYTHON_VERSION}-slim-${DEBIAN_BASE} AS base +COPY resources/nginx-template.conf /templates/nginx/frappe.conf.template +COPY resources/nginx-entrypoint.sh /usr/local/bin/nginx-entrypoint.sh + ARG WKHTMLTOPDF_VERSION=0.12.6.1-3 ARG WKHTMLTOPDF_DISTRO=bookworm -ARG NODE_VERSION=18.18.2 +ARG NODE_VERSION=22.14.0 ENV NVM_DIR=/home/frappe/.nvm -ENV PATH ${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH} +ENV PATH=${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH} RUN useradd -ms /bin/bash frappe \ && apt-get update \ @@ -65,10 +68,9 @@ RUN useradd -ms /bin/bash frappe \ && chown -R frappe:frappe /etc/nginx/nginx.conf \ && chown -R frappe:frappe /var/log/nginx \ && chown -R frappe:frappe /var/lib/nginx \ - && chown -R frappe:frappe /run/nginx.pid - -COPY resources/nginx-template.conf /templates/nginx/frappe.conf.template -COPY resources/nginx-entrypoint.sh /usr/local/bin/nginx-entrypoint.sh + && chown -R frappe:frappe /run/nginx.pid \ + && chmod 755 /usr/local/bin/nginx-entrypoint.sh \ + && chmod 644 /templates/nginx/frappe.conf.template FROM base AS builder @@ -76,6 +78,12 @@ RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ # For frappe framework wget \ + #for building arm64 binaries + libcairo2-dev \ + libpango1.0-dev \ + libjpeg-dev \ + libgif-dev \ + librsvg2-dev \ # For psycopg2 libpq-dev \ # Other @@ -86,6 +94,7 @@ RUN apt-get update \ libsasl2-dev \ libtiff5-dev \ libwebp-dev \ + pkg-config \ redis-tools \ rlwrap \ tk8.6-dev \ @@ -96,26 +105,34 @@ RUN apt-get update \ libbz2-dev \ && rm -rf /var/lib/apt/lists/* +# apps.json includes +ARG APPS_JSON_BASE64 +RUN if [ -n "${APPS_JSON_BASE64}" ]; then \ + mkdir /opt/frappe && echo "${APPS_JSON_BASE64}" | base64 -d > /opt/frappe/apps.json; \ + fi + USER frappe ARG FRAPPE_BRANCH=version-15 ARG FRAPPE_PATH=https://github.com/frappe/frappe -ARG ERPNEXT_REPO=https://github.com/frappe/erpnext -ARG ERPNEXT_BRANCH=version-15 -RUN bench init \ - --frappe-branch=${FRAPPE_BRANCH} \ - --frappe-path=${FRAPPE_PATH} \ - --no-procfile \ - --no-backups \ - --skip-redis-config-generation \ - --verbose \ - /home/frappe/frappe-bench && \ +RUN export APP_INSTALL_ARGS="" && \ + if [ -n "${APPS_JSON_BASE64}" ]; then \ + export APP_INSTALL_ARGS="--apps_path=/opt/frappe/apps.json"; \ + fi && \ + bench init ${APP_INSTALL_ARGS}\ + --frappe-branch=${FRAPPE_BRANCH} \ + --frappe-path=${FRAPPE_PATH} \ + --no-procfile \ + --no-backups \ + --skip-redis-config-generation \ + --verbose \ + /home/frappe/frappe-bench && \ cd /home/frappe/frappe-bench && \ - bench get-app --branch=${ERPNEXT_BRANCH} --resolve-deps erpnext ${ERPNEXT_REPO} && \ echo "{}" > sites/common_site_config.json && \ + bench build --production \ find apps -mindepth 1 -path "*/.git" | xargs rm -fr -FROM base as erpnext +FROM base AS backend USER frappe