-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dev build to better support multi-os (#1069)
* Update development build * Fixed an issue where the development build could use an incorrect uid / gid * Fix an issue where .python-version is in an incorrect version * Optimize build to install pyenv as the user * Reduce number of layers during build
- Loading branch information
1 parent
3aa9bd9
commit 05b0066
Showing
3 changed files
with
28 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[settings] | ||
known_third_party = PIL,aioconsole,apkutils,bitstring,configargparse,cv2,flask,flask_caching,gevent,google,gpapi,gpxdata,imutils,loguru,mysql,numpy,pkg_resources,psutil,pytesseract,pytest,requests,s2sphere,urllib3,websockets,werkzeug | ||
known_third_party = PIL,aioconsole,apkutils,bitstring,configargparse,cv2,dataclasses,flask,flask_caching,gevent,google,gpapi,gpxdata,imutils,loguru,mysql,numpy,pkg_resources,psutil,pytesseract,pytest,requests,s2sphere,urllib3,websockets,werkzeug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,42 @@ | ||
# Development env | ||
FROM local_mad_production:latest AS dev_test | ||
RUN pip install tox | ||
# Versions of python to install for pyenv. These are used when tox executes specific | ||
# python versions. The correct versions need to be added to tox.ini under tox/envlist | ||
ENV PYTHON_VERSIONS 3.6.0 3.7.0 3.8.0 | ||
COPY requirements-test.txt /usr/src/app/ | ||
# User information related to how to run within the shell | ||
ARG USER_NAME=dockeruser | ||
ARG UID=1000 | ||
ARG GID=1000 | ||
ENV USER $USER_NAME | ||
ENTRYPOINT ["bash"] | ||
|
||
# Need to re-add some required dependencies for tox to compile the new envs | ||
RUN apt-get install -y --no-install-recommends \ | ||
# pyenv | ||
build-essential libssl-dev zlib1g-dev libbz2-dev \ | ||
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \ | ||
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git \ | ||
# python build | ||
libffi-dev libgdbm-dev libsqlite3-dev libssl-dev zlib1g-dev | ||
libffi-dev libgdbm-dev libsqlite3-dev libssl-dev zlib1g-dev && \ | ||
# Create user | ||
groupadd -g $GID $USER_NAME; \ | ||
useradd -l -r -m -u $UID -g $GID $USER_NAME && \ | ||
# Install tox | ||
pip install tox | ||
|
||
# Map the user to avoid perm conflict | ||
ARG USER_NAME=dockeruser | ||
ARG UID=1000 | ||
ARG GID=1000 | ||
RUN groupadd -g $GID $USER_NAME; useradd -l -r -m -u $UID -g $GID $USER_NAME | ||
ENV USER $USER_NAME | ||
# Install pyenv | ||
# @TODO - How to install as a user and not root? | ||
ENV HOME=/home/dockeruser | ||
ENV HOME=/home/${USER} | ||
ENV PYENV_ROOT $HOME/.pyenv | ||
ENV PATH="$PYENV_ROOT/bin:$PATH" | ||
ENV PATH="$PYENV_ROOT/shims:$PATH" | ||
RUN curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash | ||
RUN chown -R dockeruser:dockeruser -R $HOME | ||
RUN for version in $PYTHON_VERSIONS; do \ | ||
ENV PATH="$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH" | ||
WORKDIR ${HOME} | ||
USER $USER_NAME | ||
RUN curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash && \ | ||
for version in $PYTHON_VERSIONS; do \ | ||
pyenv install $version; \ | ||
pyenv local $version; \ | ||
pip install --upgrade setuptools pip; \ | ||
pyenv local --unset; \ | ||
done | ||
RUN echo "pyenv local $PYTHON_VERSIONS" >> ~/.bashrc | ||
RUN pyenv local $PYTHON_VERSIONS | ||
done && \ | ||
echo "pyenv local $PYTHON_VERSIONS" >> ~/.bashrc && \ | ||
pyenv local $PYTHON_VERSIONS | ||
WORKDIR /usr/src/app |