Closed lekhnath closed 1 year ago
Errornous Dockerfile
ARG FRAPPE_VERSION
ARG ERPNEXT_VERSION
ARG PYTHON_VERSION
FROM accounting-erp/bench:v5.12.0 as assets
ARG NODE_VERSION=14.18.1
ENV NVM_DIR=/home/frappe/.nvm
ENV PATH ${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH}
ARG FRAPPE_VERSION
# Use 3.9.9 for version 13
# ARG PYTHON_VERSION=3.10.5
ARG PYTHON_VERSION=3.9.9
RUN PYENV_VERSION=${PYTHON_VERSION} bench init --version=${FRAPPE_VERSION} --skip-redis-config-generation --verbose --skip-assets /home/frappe/frappe-bench
WORKDIR /home/frappe/frappe-bench
# Uncomment following if ERPNext is required
ARG ERPNEXT_VERSION
RUN bench get-app --branch=${ERPNEXT_VERSION} --skip-assets --resolve-deps erpnext
COPY --chown=frappe:frappe repos apps
RUN bench setup requirements
RUN export BUILD_OPTS="--production --hard-link" && \
if [ -z "${FRAPPE_BRANCH##*v12*}" ] || [ -z "${FRAPPE_BRANCH##*v13*}" ] \
|| [ "$FRAPPE_BRANCH" = "version-12" ] || [ "$FRAPPE_BRANCH" = "version-13" ]; then \
export BUILD_OPTS="--make-copy"; \
fi && \
FRAPPE_ENV=production bench build --verbose ${BUILD_OPTS}
FROM frappe/frappe-nginx:${FRAPPE_VERSION}
USER root
RUN rm -fr /usr/share/nginx/html/assets
COPY --from=assets /home/frappe/frappe-bench/sites/assets /usr/share/nginx/html/assets
USER 1000
Failing command :
RUN bench setup requirements
What could be the issue?
Why are you using multi image setup? You can migrate to single image setup and try again?
Following worked for me. Adds only ERPNext.
git clone https://github.com/frappe/frappe_docker && cd frappe_docker
export APPS_JSON='[
{
"url": "https://github.com/frappe/erpnext",
"branch": "v13.28.0"
}
]'
export APPS_JSON_BASE64=$(echo ${APPS_JSON} | base64 -w 0)
docker build \
--build-arg=FRAPPE_PATH=https://github.com/frappe/frappe \
--build-arg=FRAPPE_BRANCH=v13.28.0 \
--build-arg=PYTHON_VERSION=3.9.9 \
--build-arg=NODE_VERSION=14.21.3 \
--build-arg=APPS_JSON_BASE64=$APPS_JSON_BASE64 \
--tag=custom/apps:1.0.0 \
--file=images/custom/Containerfile .
You can migrate to single image setup and try again
I am using "multi image" setup because I do not want to migrate to "new and fancy updates" every time. Why do you keep breaking old setup?
Can you suggest something to fix this in "old" setup?
Thank you.
Sorry, I cannot update to a new setup at this moment. I want to deploy in this old setup because this is in my production environment. I have no choice. I cannot take the risk. I hope you understand :)
This is my Dockerfile which creates accounting-erp/bench image.
FROM debian:bullseye-slim as bench
LABEL author=frappΓ©
ARG GIT_REPO=https://github.com/frappe/bench.git
ARG GIT_BRANCH=v5.12.0
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 ERPNext v12
# TODO: Remove after v12 is deprecated
python2 \
# for PDF
libssl-dev \
fonts-cantarell \
xfonts-75dpi \
xfonts-base \
# 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 \
&& 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
ENV WKHTMLTOPDF_VERSION 0.12.6-1
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.buster_${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
# Python 3.7 sits here for ERPNext version-12
# TODO: Remove Python 3.7 when version-12 will not be supported
ENV PYTHON_VERSION_V12=3.7.12
ENV PYTHON_VERSION=3.9.9
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_V12 \
&& pyenv install $PYTHON_VERSION \
&& pyenv global $PYTHON_VERSION $PYTHON_VERSION_V12 \
&& 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 --user -e .bench \
&& echo "export PATH=/home/frappe/.local/bin:\$PATH" >>/home/frappe/.bashrc \
&& echo "export BENCH_DEVELOPER=1" >>/home/frappe/.bashrc
# Install Node via nvm
ENV NODE_VERSION=14.18.1
ENV NODE_VERSION_FRAPPEV11=10.24.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.0/install.sh | bash \
&& . ${NVM_DIR}/nvm.sh \
&& nvm install ${NODE_VERSION_FRAPPEV11} \
&& nvm use v${NODE_VERSION_FRAPPEV11} \
&& npm install -g yarn \
&& nvm install ${NODE_VERSION} \
&& nvm use v${NODE_VERSION} \
&& npm install -g yarn \
&& nvm alias default v${NODE_VERSION} \
&& 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"
Why do you keep breaking old setup?
Nothing changed after merge in Jan.
"new and fancy updates"
New and fancy has improvements over old and deprecated.
I can't help you much, try prefix PYENV_VERSION=${PYTHON_VERSION} bench setup requirements
.
This is not working as of today, I tried to perform same commands you did with one exception which is apps.json
[
{
"url":"https://github.com/frappe/payments",
"branch":"develop"
},
{
"url":"https://github.com/frappe/erpnext",
"branch":"version-14"
},
{
"url":"https://github.com/frappe/hrms",
"branch":"develop"
},
{
"url":"https://github.com/frappe/ecommerce_integrations",
"branch":"main"
}
]
export APPS_JSON_BASE64=$(base64 -w 0 apps.json)
docker build \
--build-arg=FRAPPE_PATH=https://github.com/frappe/frappe \
--build-arg=FRAPPE_BRANCH=v13.28.0 \
--build-arg=PYTHON_VERSION=3.9.9 \
--build-arg=NODE_VERSION=14.21.3 \
--build-arg=APPS_JSON_BASE64=$APPS_JSON_BASE64 \
--tag=munjiz/erpnext:v0.5 \
--file=images/custom/Containerfile .
I see in the build, it reaches erpnext
repo correctly, but later failed
#0 180.5 Installing collected packages: payments
#0 180.5 Running setup.py develop for payments
#0 181.1 Successfully installed payments-0.0.1
#0 181.2 WARN: restart failed: Couldn't find supervisorctl in PATH
#0 181.2 Getting erpnext
#0 181.2 $ git clone https://github.com/frappe/erpnext --branch v14.26.0 --depth 1 --origin upstream
#0 181.2 Cloning into 'erpnext'...
#0 191.8 Note: switching to '69b214b85b84be6656e71da67d952b7563d354ff'.
#0 191.8
#0 191.8 You are in 'detached HEAD' state. You can look around, make experimental
#0 191.8 changes and commit them, and you can discard any commits you make in this
#0 191.8 state without impacting any branches by switching back to a branch.
#0 191.8
#0 191.8 If you want to create a new branch to retain commits you create, you may
#0 191.8 do so (now or later) by using -c with the switch command. Example:
#0 191.8
#0 191.8 git switch -c <new-branch-name>
#0 191.8
#0 191.8 Or undo this operation with:
#0 191.8
#0 191.8 git switch -
#0 191.8
#0 191.8 Turn off this advice by setting config variable advice.detachedHead to false
#0 191.8
#0 192.2 Ignoring dependencies of https://github.com/frappe/erpnext. To install dependencies use --resolve-deps
#0 192.2 Installing erpnext
#0 192.2 $ /home/frappe/frappe-bench/env/bin/python -m pip install --upgrade -e /home/frappe/frappe-bench/apps/erpnext
#0 192.6 Obtaining file:///home/frappe/frappe-bench/apps/erpnext
#0 192.6 Installing build dependencies: started
#0 194.4 Installing build dependencies: finished with status 'done'
#0 194.4 Checking if build backend supports build_editable: started
#0 194.5 Checking if build backend supports build_editable: finished with status 'done'
#0 194.5 Getting requirements to build editable: started
#0 194.6 Getting requirements to build editable: finished with status 'done'
#0 194.6 Preparing editable metadata (pyproject.toml): started
#0 194.7 Preparing editable metadata (pyproject.toml): finished with status 'done'
#0 195.2 Collecting pycountry~=20.7.3 (from erpnext==14.26.0)
#0 195.7 Downloading pycountry-20.7.3.tar.gz (10.1 MB)
#0 196.8 ββββββββββββββββββββββββββββββββββββββββ 10.1/10.1 MB 8.6 MB/s eta 0:00:00
#0 197.3 Preparing metadata (setup.py): started
#0 197.6 Preparing metadata (setup.py): finished with status 'done'
#0 197.7 Collecting python-stdnum~=1.16 (from erpnext==14.26.0)
#0 197.8 Downloading python_stdnum-1.18-py2.py3-none-any.whl (1.0 MB)
#0 198.0 ββββββββββββββββββββββββββββββββββββββββ 1.0/1.0 MB 9.6 MB/s eta 0:00:00
#0 198.1 Collecting Unidecode~=1.2.0 (from erpnext==14.26.0)
#0 198.2 Downloading Unidecode-1.2.0-py2.py3-none-any.whl (241 kB)
#0 198.2 βββββββββββββββββββββββββββββββββββββββ 241.7/241.7 kB 9.4 MB/s eta 0:00:00
#0 198.4 Collecting redisearch~=2.1.0 (from erpnext==14.26.0)
#0 198.5 Downloading redisearch-2.1.1-py3-none-any.whl (26 kB)
#0 198.7 Collecting gocardless-pro~=1.22.0 (from erpnext==14.26.0)
#0 198.8 Downloading gocardless_pro-1.22.0.tar.gz (35 kB)
#0 198.9 Preparing metadata (setup.py): started
#0 199.2 Preparing metadata (setup.py): finished with status 'done'
#0 199.2 Requirement already satisfied: googlemaps in ./env/lib/python3.9/site-packages (from erpnext==14.26.0) (4.4.7)
#0 199.4 Collecting plaid-python~=7.2.1 (from erpnext==14.26.0)
#0 199.5 Downloading plaid-python-7.2.1.tar.gz (18 kB)
#0 199.5 Preparing metadata (setup.py): started
#0 199.8 Preparing metadata (setup.py): finished with status 'done'
#0 199.9 Collecting python-youtube~=0.8.0 (from erpnext==14.26.0)
#0 200.0 Downloading python_youtube-0.8.3-py3-none-any.whl (42 kB)
#0 200.0 ββββββββββββββββββββββββββββββββββββββββ 42.3/42.3 kB 2.8 MB/s eta 0:00:00
#0 200.1 Collecting taxjar~=1.9.2 (from erpnext==14.26.0)
#0 200.2 Downloading taxjar-1.9.2.tar.gz (11 kB)
#0 200.2 Preparing metadata (setup.py): started
#0 200.5 Preparing metadata (setup.py): finished with status 'done'
#0 200.7 Collecting tweepy~=3.10.0 (from erpnext==14.26.0)
#0 200.8 Downloading tweepy-3.10.0-py2.py3-none-any.whl (30 kB)
#0 200.8 INFO: pip is looking at multiple versions of erpnext to determine which version is compatible with other requirements. This could take a while.
#0 200.8 ERROR: Package 'erpnext' requires a different Python: 3.9.9 not in '>=3.10'
#0 202.0 subprocess.CalledProcessError: Command '/home/frappe/frappe-bench/env/bin/python -m pip install --upgrade -e /home/frappe/frappe-bench/apps/erpnext ' returned non-zero exit status 1.
#0 202.0
#0 202.0 The above exception was the direct cause of the following exception:
#0 202.0
#0 202.0 Traceback (most recent call last):
#0 202.0 File "/usr/local/lib/python3.9/site-packages/bench/commands/make.py", line 68, in init
#0 202.0 init(
#0 202.0 File "/usr/local/lib/python3.9/site-packages/bench/utils/render.py", line 105, in wrapper_fn
#0 202.0 return fn(*args, **kwargs)
#0 202.0 File "/usr/local/lib/python3.9/site-packages/bench/utils/system.py", line 90, in init
#0 202.0 install_apps_from_path(apps_path, bench_path=path)
#0 202.0 File "/usr/local/lib/python3.9/site-packages/bench/app.py", line 691, in install_apps_from_path
#0 202.0 get_app(
#0 202.0 File "/usr/local/lib/python3.9/site-packages/bench/app.py", line 444, in get_app
#0 202.0 app.install(verbose=verbose, skip_assets=skip_assets, restart_bench=restart_bench)
#0 202.0 File "/usr/local/lib/python3.9/site-packages/bench/utils/render.py", line 126, in wrapper_fn
#0 202.0 return fn(*args, **kwargs)
#0 202.0 File "/usr/local/lib/python3.9/site-packages/bench/app.py", line 242, in install
#0 202.0 install_app(
#0 202.0 File "/usr/local/lib/python3.9/site-packages/bench/app.py", line 573, in install_app
#0 202.0 bench.run(
#0 202.0 File "/usr/local/lib/python3.9/site-packages/bench/bench.py", line 48, in run
#0 202.0 return exec_cmd(cmd, cwd=cwd or self.cwd, _raise=_raise)
#0 202.0 File "/usr/local/lib/python3.9/site-packages/bench/utils/__init__.py", line 158, in exec_cmd
#0 202.0 raise CommandFailedError from subprocess.CalledProcessError(return_code, cmd)
#0 202.0 bench.exceptions.CommandFailedError
#0 202.0
#0 202.0 ERROR: There was a problem while creating /home/frappe/frappe-bench
#0 202.0 Do you want to rollback these changes? [y/N]: Aborted!
------
Containerfile:106
--------------------
105 | ARG FRAPPE_PATH=https://github.com/frappe/frappe
106 | >>> RUN export APP_INSTALL_ARGS="" && \
107 | >>> if [ -n "${APPS_JSON_BASE64}" ]; then \
108 | >>> export APP_INSTALL_ARGS="--apps_path=/opt/frappe/apps.json"; \
109 | >>> fi && \
110 | >>> bench init ${APP_INSTALL_ARGS}\
111 | >>> --frappe-branch=${FRAPPE_BRANCH} \
112 | >>> --frappe-path=${FRAPPE_PATH} \
113 | >>> --no-procfile \
114 | >>> --no-backups \
115 | >>> --skip-redis-config-generation \
116 | >>> --verbose \
117 | >>> /home/frappe/frappe-bench && \
118 | >>> cd /home/frappe/frappe-bench && \
119 | >>> echo "{}" > sites/common_site_config.json && \
120 | >>> find apps -mindepth 1 -path "*/.git" | xargs rm -fr
121 |
--------------------
ERROR: failed to solve: process "/bin/sh -c 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 && echo \"{}\" > sites/common_site_config.json && find apps -mindepth 1 -path \"*/.git\" | xargs rm -fr" did not complete successfully: exit code: 1
it's failing in 106 in Dockerfile
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 && \
echo "{}" > sites/common_site_config.json && \
find apps -mindepth 1 -path "*/.git" | xargs rm -fr
use updated version of python and base image
https://github.com/frappe/frappe_docker/blob/main/docs/custom-apps.md
https://discuss.frappe.io/t/frappe-erpnext-container-image-now-built-on-debian-bookworm/106530
Cannot build docker images
Bench version : v5.12.0 Erpnext Version: v13.28.0 Frappe Version: v13.28.0
Stacktrace / full error message if available