Commit d40f337e authored by bmustiata's avatar bmustiata Committed by Chris R
Browse files

Custom pypi URL, pyinstaller options, optional requirements.txt (#7)

* WIP to get rid of requirements, required spec file.
* Use an entrypoint to run things.
* Add support for custom index PYPI proxying.
* Allow using a custom pypi server.
* Made the linux machines also use the entrypoint.
* Specify correctly the path to the pip.conf.
parent 27040db3
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -10,6 +10,12 @@ RUN set -x \
    && apt-get install --no-install-recommends -qfy python python-dev python-pip python-setuptools build-essential libmysqlclient-dev \
    && apt-get clean

# PYPI repository location
ENV PYPI_URL=https://pypi.python.org/
# PYPI index location
ENV PYPI_INDEX_URL=https://pypi.python.org/simple


# install pyinstaller
RUN pip install pyinstaller==$PYINSTALLER_VERSION

@@ -17,4 +23,8 @@ RUN mkdir /src/
VOLUME /src/
WORKDIR /src/

CMD pip install -r requirements.txt && pyinstaller --clean -y --dist ./dist/linux --workpath /tmp *.spec
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
+37 −0
Original line number Diff line number Diff line
#!/bin/bash

# Fail on errors.
set -e

#
# In case the user specified a custom URL for PYPI, then use
# that one, instead of the default one.
#
if [[ "$PYPI_URL" != "https://pypi.python.org/" ]] || \
   [[ "$PYPI_INDEX_URL" != "https://pypi.python.org/simple" ]]; then
    # the funky looking regexp just extracts the hostname, excluding port
    # to be used as a trusted-host.
    mkdir -p /root/pip
    echo "[global]" > /root/pip/pip.conf
    echo "index = $PYPI_URL" >> /root/pip/pip.conf
    echo "index-url = $PYPI_INDEX_URL" >> /root/pip/pip.conf
    echo "trusted-host = $(echo $PYPI_URL | perl -pe 's|^.*?://(.*?)(:.*?)?/.*$|$1|')" >> /root/pip/pip.conf

    echo "Using custom pip.conf: "
    cat /root/pip/pip.conf
fi

cd /src

if [ -f requirements.txt ]; then
    pip install -r requirements.txt
fi # [ -f requirements.txt ]

echo "$@"

if [[ "$@" == "" ]]; then
    pyinstaller --clean -y --dist ./dist/linux --workpath /tmp *.spec
else
    $@
fi # [[ "$@" == "" ]]
+5 −1
Original line number Diff line number Diff line
@@ -18,4 +18,8 @@ RUN mkdir /src/
VOLUME /src/
WORKDIR /src/

CMD pip install -r requirements.txt && pyinstaller --clean -y --dist ./dist/linux --workpath /tmp *.spec
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
+37 −0
Original line number Diff line number Diff line
#!/bin/bash

# Fail on errors.
set -e

#
# In case the user specified a custom URL for PYPI, then use
# that one, instead of the default one.
#
if [[ "$PYPI_URL" != "https://pypi.python.org/" ]] || \
   [[ "$PYPI_INDEX_URL" != "https://pypi.python.org/simple" ]]; then
    # the funky looking regexp just extracts the hostname, excluding port
    # to be used as a trusted-host.
    mkdir -p /root/pip
    echo "[global]" > /root/pip/pip.conf
    echo "index = $PYPI_URL" >> /root/pip/pip.conf
    echo "index-url = $PYPI_INDEX_URL" >> /root/pip/pip.conf
    echo "trusted-host = $(echo $PYPI_URL | perl -pe 's|^.*?://(.*?)(:.*?)?/.*$|$1|')" >> /root/pip/pip.conf

    echo "Using custom pip.conf: "
    cat /root/pip/pip.conf
fi

cd /src

if [ -f requirements.txt ]; then
    pip install -r requirements.txt
fi # [ -f requirements.txt ]

echo "$@"

if [[ "$@" == "" ]]; then
    pyinstaller --clean -y --dist ./dist/linux --workpath /tmp *.spec
else
    $@
fi # [[ "$@" == "" ]]
+10 −1
Original line number Diff line number Diff line
@@ -21,6 +21,11 @@ ENV WINEARCH win32
ENV WINEDEBUG fixme-all
ENV WINEPREFIX /wine

# PYPI repository location
ENV PYPI_URL=https://pypi.python.org/
# PYPI index location
ENV PYPI_INDEX_URL=https://pypi.python.org/simple

# install python inside wine
RUN set -x \
    && wget -nv https://www.python.org/ftp/python/$PYTHON_VERSION/python-$PYTHON_VERSION.msi \
@@ -48,4 +53,8 @@ VOLUME /src/
WORKDIR /wine/drive_c/src/
RUN mkdir -p /wine/drive_c/tmp

CMD pip install -r requirements.txt && pyinstaller --clean -y --dist ./dist/windows --workpath /tmp *.spec
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
Loading