fix: set pyenv global versions

This commit is contained in:
Revant Nandgaonkar 2021-11-30 14:52:04 +05:30
parent 527b06d92c
commit 5632316566
2 changed files with 14 additions and 16 deletions

View file

@ -54,8 +54,6 @@ RUN apt-get update \
ssh-client \
# VSCode container requirements
net-tools \
# For version 12
python2 \
&& 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 \
@ -74,21 +72,27 @@ 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
# Set user, workdir and home
USER frappe
WORKDIR /home/frappe
ENV HOME=/home/frappe
# Export python executables for Dockerfile
ENV PATH /home/frappe/.local/bin:$PATH
# Export python executables for interactive shell
RUN echo "export PATH=/home/frappe/.local/bin:\$PATH" >> /home/frappe/.bashrc
# Install pyenv for using multi python setup
RUN git clone --depth=1 https://github.com/pyenv/pyenv.git .pyenv
ENV PYENV_ROOT="${HOME}/.pyenv"
ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"
RUN pyenv install 3.7.12 \
&& pyenv install 2.7.18 \
&& pyenv global system 3.7.12 2.7.18
# Clone and install bench in the local user home directory
# For development, bench source is located in ~/.bench
RUN git clone ${GIT_REPO} --depth 1 -b ${GIT_BRANCH} .bench \
&& pip install --user -e .bench
# Export python executables for Dockerfile
ENV PATH /home/frappe/.local/bin:$PATH
# Export python executables for interactive shell
RUN echo "export PATH=/home/frappe/.local/bin:\$PATH" >> /home/frappe/.bashrc
ENV HOME=/home/frappe
# Install nvm with node
RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash \
&& . ${NVM_DIR}/nvm.sh \
@ -105,12 +109,6 @@ RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh |
&& 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
RUN git clone --depth=1 https://github.com/pyenv/pyenv.git .pyenv
ENV PYENV_ROOT="${HOME}/.pyenv"
ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"
ENV PYTHON_VERSION=3.7.12
RUN pyenv install ${PYTHON_VERSION}
EXPOSE 8000-8005 9000-9005 6787
FROM build as test

View file

@ -62,7 +62,7 @@ bench init --skip-redis-config-generation --frappe-branch version-13 frappe-benc
cd frappe-bench
```
Note: For version 12 use python 3.7 by passing option to `bench init` command, e.g. `bench init --skip-redis-config-generation --frappe-branch version-12 --python ~/.pyenv/versions/3.7.12/bin/python frappe-bench`
Note: For version 12 use python 3.7 by passing option to `bench init` command, e.g. `bench init --skip-redis-config-generation --frappe-branch version-12 --python python3.7 frappe-bench`
### Setup hosts