Giter Club home page Giter Club logo

alpine-python's Introduction

alpine-python

Docker Stars Docker Pulls Build Status

A small Python Docker image based on Alpine Linux.

Supported tags

NOTES:

  • onbuild images install the requirements.txt of your project from the get go. This allows you to cache your requirements right in the build. Make sure you are in the same directory of your requirements.txt file.

Why?

The default docker python images are too big, much larger than they need to be. Hence I built this simple image based on docker-alpine, that has everything needed for the most common python projects - including python-dev (which is not common in most minimal alpine python packages).

REPOSITORY TAG SIZE
jfloff/alpine-python 2.7-slim 60MB
python 2.7-slim 120MB
python 2.7-alpine 61.2MB
jfloff/alpine-python 2.7 235MB
python 2.7 912MB
jfloff/alpine-python 3.6-slim 76.3MB
python 3.6-slim 138MB
python 3.6-alpine 79MB
jfloff/alpine-python 3.6 252MB
python 3.6 922MB
jfloff/alpine-python 3.7-slim 80.4MB
python 3.7-slim 86.7MB
python 3.7-alpine 143MB
jfloff/alpine-python 3.7 256MB
python 3.7 927MB

Perhaps this could be even smaller, but I'm not an Alpine guru. Feel free to post a PR.

Details

  • Installs build-base and python-dev, allowing the use of more advanced packages such as gevent
  • Installs bash allowing interaction with the container
  • Just like the main python docker image, it creates useful symlinks that are expected to exist, e.g. python3 > python, pip2.7 > pip, etc.)
  • Added testing and community repositories to Alpine's /etc/apk/repositories file

Usage

This image runs python command on docker run. You can either specify your own command, e.g:

docker run --rm -ti jfloff/alpine-python python hello.py

You can also access bash inside the container:

docker run --rm -ti jfloff/alpine-python bash

Usage of onbuild images

These images can be used to bake your dependencies into an image by extending the plain python images. To do so, create a custom Dockerfile like this:

FROM jfloff/alpine-python:3.6-onbuild

# for a flask server
EXPOSE 5000
CMD python manage.py runserver

Don't forget to build that Dockerfile:

docker build --rm=true -t jfloff/app .

docker run --rm -t jfloff/app

Personally, I build an extended Dockerfile version (like shown above), and mount my specific application inside the container:

docker run --rm -v "$(pwd)":/home/app -w /home/app -p 5000:5000 -ti jfloff/app

Usage of slim images

These images are very small to download, and can install requirements at run-time via flags. The install only happens the first time the container is run, and dependencies can be baked in (see Creating Images).

Via docker run

These images can be run in multiple ways. With no arguments, it will run python interactively:

docker run --rm -ti jfloff/alpine-python:2.7-slim

If you specify a command, they will run that:

docker run --rm -ti jfloff/alpine-python:2.7-slim python hello.py

Pip Dependencies

Pip dependencies can be installed by the -p switch, or a requirements.txt file.

If the file is at /requirements.txt it will be automatically read for dependencies. If not, use the -P or -r switch to specify a file.

# This runs interactive Python with 'simplejson' and 'requests' installed
docker run --rm -ti jfloff/alpine-python:2.7-slim -p simplejson -p requests

# Don't forget to add '--' after your dependencies to run a custom command:
docker run --rm -ti jfloff/alpine-python:2.7-slim -p simplejson -p requests -- python hello.py

# This accomplishes the same thing by mounting a requirements.txt in:
echo 'simplejson' > requirements.txt
echo 'requests' > requirements.txt
docker run --rm -ti \
  -v requirements.txt:/requirements.txt \
  jfloff/alpine-python:2.7-slim python hello.py

# This does too, but with the file somewhere else:
echo 'simplejson requests' > myapp/requirements.txt
docker run --rm -ti \
  -v myapp:/usr/src/app \
  jfloff/alpine-python:2.7-slim \
    -r /usr/src/app/requirements.txt \
    -- python /usr/src/app/hello.py

Run-Time Dependencies

Alpine package dependencies can be installed by the -a switch, or an apk-requirements.txt file.

If the file is at /apk-requirements.txt it will be automatically read for dependencies. If not, use the -A switch to specify a file.

You can also try installing some Python modules via this method, but it is possible for Pip to interfere if it detects a version problem.

# Unknown why you'd need to do this, but you can!
docker run --rm -ti jfloff/alpine-python:2.7-slim -a openssl -- python hello.py

# This installs libxml2 module faster than via Pip, but then Pip reinstalls it because Ajenti's dependencies make it think it's the wrong version.
docker run --rm -ti jfloff/alpine-python:2.7-slim -a py-libxml2 -p ajenti

Build-Time Dependencies

Build-time Alpine package dependencies (such as compile headers) can be installed by the -b switch, or a build-requirements.txt file. They will be removed after the dependencies are installed to save space.

If the file is at /build-requirements.txt it will be automatically read for dependencies. If not, use the -B switch to specify a file.

build-base, linux-headers and python-dev are always build dependencies, you don't need to include them.

docker run --rm -ti jfloff/alpine-python:2.7-slim \
  -p gevent \
  -p libxml2 \
  -b libxslt-dev \
  -b libxml-dev \
  -- python hello.py

Creating Images

Similar to the onbuild images, dependencies can be baked into a new image by using a custom Dockerfile, e.g:

FROM jfloff/alpine-python:2.7-slim
RUN /entrypoint.sh \
  -p ajenti-panel \
  -p ajenti.plugin.dashboard \
  -p ajenti.plugin.settings \
  -p ajenti.plugin.plugins \
  -b libxml2-dev \
  -b libxslt-dev \
  -b libffi-dev \
  -b openssl-dev \
&& echo
CMD ["ajenti-panel"]
# you won't be able to add more dependencies later though-- see 'Debugging'

Debugging

The /entrypoint.sh script that manages dependencies in the slim images creates an empty file, /requirements.installed, telling the script not to install any dependencies after the container's first run. Removing this file will allow the script to work again if it is needed.

You can use the -x flag to see everything the /entrypoint.sh script is doing.

You can also access bash inside the container:

docker run --rm -ti jfloff/alpine-python:2.7-slim bash

Additional Arguments

-q: silences output from /entrypoint.sh -x: turns on Bash debugging, making the output very verbose.

Ecosystem

These are some of the images that use jfloff/alpine-python as base image. If you have another image that uses this as base image, please submit an issue or PR for it to be added. Image has to be published on Docker Hub.

  • jfloff/alscipy Docker Stars Docker Pulls : image with common packages for Science in Alpine Python.
  • jfloff/pywfm Docker Stars Docker Pulls : image from the python wrapper for Steffen Rendle's factorization machines library libFM.
  • bismuthfoundation/Bismuth-Docker Docker Stars Docker Pulls : node and associated services, from scratch crypto-currency with Python codebase.

Contribution

Feel free to contribute with whatever you feel like this image is missing. There is also some changes that happen often like, updating Alpine or Python versions. Do not forget that this repo folders mirror Python version and not Alpine versions.

License

The code in this repository, unless otherwise noted, is MIT licensed. See the LICENSE file in this repository.

alpine-python's People

Contributors

andresgottlieb avatar danielporto avatar galindro avatar hosamaly avatar jfloff avatar qudongfang avatar satur9 avatar slowr avatar tprobinson avatar tsal avatar xhochn avatar ykshatroff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alpine-python's Issues

PYTHON not found in PATH - build 3.8

Here is my docker file:

FROM jfloff/alpine-python:3.8-onbuild
  
# Build stage
FROM node:lts-alpine as build

RUN apk update; \
  apk add git;
WORKDIR /tmp
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# Release stage
FROM node:lts-alpine as release

RUN apk update; \
  apk add git;

VOLUME /parse-server/cloud /parse-server/config

WORKDIR /parse-server

COPY package*.json ./

RUN npm ci --production --ignore-scripts

COPY bin bin
COPY public_html public_html
COPY views views
COPY --from=build /tmp/lib lib
RUN mkdir -p logs && chown -R node: logs

ENV PORT=80
USER node
EXPOSE $PORT

ENTRYPOINT ["node", "./bin/parse-server"]

docker build throws a path error.
PYTHON, PYTHON2, PYTHON3 not found in path

I have copied the entrypoint.sh in the same dir and my requirements.txt is empty as I dont have any package dependencies. 

Can't install openblas because hacky repository replacement

I was trying to use this to create an image for a Python-sci container using slim's command line as follows:

docker run --rm -ti jfloff/alpine-python:recent-slim \
-a libstdc++ \
-a g++ \
-a gfortran \
-a openblas-dev \
-a openblas \
-p Flask==0.12.2 \
-p gevent==1.2.2 \
-p gunicorn==19.7.1 \
-p pandas==0.22.0 \
-p scikit-learn==0.19.1

but it didn't take too long to get an error.

fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  openblas (missing):
    required by: world[openblas]
  openblas-dev (missing):
    required by: world[openblas-dev]

After forking and tweaking a little, I realized that the following part was the problem:

  && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \
  && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
  && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \

  # Add the packages, with a CDN-breakage fallback if needed
  && apk add --no-cache $PACKAGES || \
    (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \

  # turn back the clock -- so hacky!
  && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \
  # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
  # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
  # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \

My solution was to turn off the "turn back the clock" entirely.

As I don't know too much about docker, I can't give any improvement suggestions right now. I just wanted to point the problem here to let people (and you) about it.

Thanks!

Unable to install MySQL-python package in alpine-python:2.7-slim

Hi, I am trying to install python package MySQL-python==1.2.3rc1 in plain untouched image of alpine-python:2.7-slim. However I am not able to do the same. This happens for both jfloff/alpine-python:2.7 and jfloff/alpine-python:2.7-slim. Please find below errorlogs for more details about it.

[root@mysystem work]# docker run --rm -ti jfloff/alpine-python:2.7-slim -p MySQL-python==1.2.3rc1
First run, checking for any requirements...
Installing all APK requirements...
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
(1/27) Upgrading musl (1.1.18-r2 -> 1.1.18-r3)
(2/27) Installing binutils-libs (2.30-r1)
(3/27) Installing binutils (2.30-r1)
(4/27) Installing gmp (6.1.2-r1)
(5/27) Installing isl (0.18-r0)
(6/27) Installing libgomp (6.4.0-r5)
(7/27) Installing libatomic (6.4.0-r5)
(8/27) Installing libgcc (6.4.0-r5)
(9/27) Installing mpfr3 (3.1.5-r1)
(10/27) Installing mpc1 (1.0.3-r1)
(11/27) Installing libstdc++ (6.4.0-r5)
(12/27) Installing gcc (6.4.0-r5)
(13/27) Installing musl-dev (1.1.18-r3)
(14/27) Installing libc-dev (0.7.1-r0)
(15/27) Installing g++ (6.4.0-r5)
(16/27) Installing make (4.2.1-r0)
(17/27) Installing fortify-headers (0.9-r0)
(18/27) Installing build-base (0.5-r0)
(19/27) Installing libssh2 (1.8.0-r2)
(20/27) Installing libcurl (7.61.1-r0)
(21/27) Installing pcre2 (10.30-r0)
(22/27) Installing git (2.15.2-r0)
(23/27) Upgrading musl-utils (1.1.18-r2 -> 1.1.18-r3)
(24/27) Installing libc6-compat (1.1.18-r3)
(25/27) Installing linux-headers (4.4.6-r2)
(26/27) Upgrading python2 (2.7.14-r2 -> 2.7.15-r2)
(27/27) Installing python2-dev (2.7.15-r2)
Executing busybox-1.27.2-r7.trigger
OK: 240 MiB in 50 packages
Upgrading Pip...
Collecting pip
  Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
    100% |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 1.3MB 5.2MB/s 
Installing collected packages: pip
  Found existing installation: pip 10.0.1
    Uninstalling pip-10.0.1:
      Successfully uninstalled pip-10.0.1
Successfully installed pip-18.1
Installing all Pip requirements...
Collecting MySQL-python==1.2.3rc1 (from -r /tmp/requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/c8/8f/aedf47a2e973a2d2f225ac98537472fc928ad61b9647fb370870404c594b/MySQL-python-1.2.3c1.tar.gz (89kB)
    100% |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 92kB 293kB/s 
    Complete output from command python setup.py egg_info:
    sh: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-kmGDud/MySQL-python/setup.py", line 15, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 24, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-kmGDud/MySQL-python/
[root@mysystem work]# docker run --rm -ti jfloff/alpine-python:2.7 bash
bash-4.4# pip install MySQL-python
Collecting MySQL-python
  Downloading https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
    100% |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 112kB 378kB/s 
    Complete output from command python setup.py egg_info:
    sh: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-P5QZtR/MySQL-python/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 25, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-P5QZtR/MySQL-python/
You are using pip version 9.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
bash-4.4# exit
[root@mysystem work]#

Any hint will be great help!

getting error with tzdata and apscheduler library

Trying to use the python apscheduler library with your 3.7 image and getting this error.

I've manually added tzdata to the docker image, but I'm having no luck. Any ideas?

raise pytz.UnknownTimeZoneError('Can not find any timezone configuration')
pytz.exceptions.UnknownTimeZoneError: 'Can not find any timezone configuration'

Request: add --enable-shared for pyenv python installations

Hi there, first off, thanks a lot for creating these images. We're using them over at carbondoomsday since a while now and they've really made things easier to get small application images out the door quickly.

So, one issue I am seeing now, when running a pipenv install of my dependencies is:

...
ython3.6.a -lcrypt
    gcc: error: /usr/lib/python3.6.5/lib/python3.6/config-3.6m/libpython3.6.a: No such file or directory
    *** error linking uWSGI ***

The internet seems to think that --enable-shared should be passed when compiling the python:

This seems to be possible with pyenv, from their documentation:

https://github.com/pyenv/pyenv/wiki#how-to-build-cpython-with---enable-shared

So, would you accept a pull request with --enable-shared tacked onto the pyenv install?

๐Ÿ‘

Gevent doesn't install

Just a heads up, since gevent is specifically mentioned in the readme as a package that should be installable. Probably the same issue as with the wait-for-it.sh, the build just hangs:

Dockerfile

from jfloff/alpine-python:2.7

RUN pip install gevent

Shell

$ docker build .
Sending build context to Docker daemon  2.048kB
Step 1/2 : from jfloff/alpine-python:2.7
 ---> e96b6ec2e90a
Step 2/2 : RUN pip install gevent
 ---> Running in 63bfde9be37e
Collecting gevent
  Downloading gevent-1.2.2.tar.gz (3.1MB)
Collecting greenlet>=0.4.10 (from gevent)
  Downloading greenlet-0.4.12.tar.gz (57kB)
Installing collected packages: greenlet, gevent
  Running setup.py install for greenlet: started
    Running setup.py install for greenlet: finished with status 'done'
  Running setup.py install for gevent: started

The process just hangs here eternally.

I don't know if this is an alpine linux thingy or if it's caused by something installed in this repo. Also don't know who to talk to about fixing this.

Usage text is never printed

When I run a jfloff/alpine-python image with wrong arguments, the usage text is never printed. This is due to using echo <<EOF instead of cat <<EOF, as the former command discards the standard input that is passed to it by the <<EOF construct.

3.7 and 3.7-slim command 'gcc' failed.

Hi,

I need a lightweight docker image with Python installed and I came across this project. However, the issue I am having with both 3.7 and 3.7-slim is that I receive the following error when building a setup.py file.

  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for cryptography

I try installing gcc as well as the dependencies recommended from #49 but the build still fails. Any advice?

Many Thanks.

Here is the dockerfile I am using:

# Or 3.7-slim
FROM jfloff/alpine-python:3.7

RUN apk update && apk upgrade && apk add git gcc musl libc6-compat linux-headers build-base git libssl1.0 libffi-dev

WORKDIR ~
RUN git clone https://github.com/datacenter/acitoolkit.git
# Build the ACI Toolkit.
WORKDIR "acitoolkit"
RUN python setup.py install
RUN pip install \ 
    netmiko \
    paramiko

how to install mysqlclient?

I use 2.7-onbuild to make a Dockerfile and mysqlclient is in my requirements, but it faild to install mysqlclient, this is the logs

Collecting mysqlclient==1.3.9 (from -r requirements.txt (line 2))
Downloading mysqlclient-1.3.9.tar.gz (81kB)
Complete output from command python setup.py egg_info:
sh: 1: mysql_config: not found
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-zQwRaV/mysqlclient/setup.py", line 17, in
metadata, options = get_config()
File "setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 26, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found

Should I install some dependences first?

Guidelines for multiple requirement files using onbuild image

Can you provide an example of using multiple requirement files eg. /requirements and /module/requirements as part of onbuild.
tried

FROM jfloff/alpine-python:2.7-onbuild
ENV PIP_REQUIREMENTS "requirements.txt nlp_submodule/requirements.txt"
ENV PORT 7000
EXPOSE 7000
ENTRYPOINT ["python"]
CMD ["run_service.py"]

But its not pulling up both the requirement files

[BUG] Incorrect path for python binaries

We are using the python3.6 container and until yesterday everything was running fine.

Now installing pip packages that have binaries like gunicorn no longer works.

Before:

bash-4.4# pip install gunicorn
...
Successfully installed gunicorn-19.9.0
bash-4.4# which gunicorn
/usr/local/bin/gunicorn
bash-4.4#

After:

bash-4.4# pip install gunicorn
...
Successfully installed gunicorn-19.9.0
bash-4.4# which gunicorn
bash-4.4#

/bin/sh: /entrypoint.sh: not found 3.7 tag.

Using the 3.7 tag, I am recieveing the following error:

/bin/sh: /entrypoint.sh: not found 
The command '/bin/sh -c /entrypoint.sh -x -r ./BUCSS_Bot/requirements.txt' returned a non-zero code: 127

Quay Support

Would it be possible, to switch to quay or douplicate the build?
The clair container scanning feature is something what i really missing.

Skipping python installation?

Hello, novice question here...
Given the following Dockerfile, can I assure that Python won't be installed on each docker build run? That is, that after its first-time installation it should suffice to not be repeated again and again?

In general, I'd like to add python to this Docker image, but just the bare-minimum that is needed, in order to preserve the smallest image size possible... it seems that the below installs quite a lot?

FROM node:6.9.4-alpine

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install python
RUN apk add --update \
    python \
    python-dev \
    py-pip \
    build-base \
    && pip install virtualenv \
    && rm -rf /var/cache/apk/*

# Use .npmrc 
COPY ./.npmrc /usr/src/app
ARG NPM_TOKEN  

# Will prevent npm install if nothing has changed
COPY ./package.json /usr/src/app
RUN cd /usr/src/app && npm install

# Bundle app source
COPY . /usr/src/app
 
EXPOSE 8080
CMD [ "npm", "start" ]

jfloff/alpine-python:2.7-slim increased from 58.8MB to 96.9MB

I rebuilt one of my Docker image and I saw the new size of the 2.7-slim increased a lot.

jfloff/alpine-python 2.7-slim 7a1fffbf1673 11 hours ago 96.9MB

Is it a problem or will it be the new optimized size?

Do you think it's possible to add an ID to the Docker image tag? Just to know at which Github commit the Docker image has been built.

Tensorflow not supported for jfloff/alpine-python:3.6-onbuild ?

Hi,
Thanks for this project it's pretty awesome !
I got this error when i put tensorflow on my requirements.txt file..

Sending build context to Docker daemon  1.462MB
Step 1/12 : FROM jfloff/alpine-python:3.6-onbuild
3.6-onbuild: Pulling from jfloff/alpine-python
c87736221ed0: Already exists 
98cb40a20131: Pull complete 
6044b556a057: Pull complete 
Digest: sha256:4599cd72b51d93616efbc12813412721d50157466d852b432ac37d8c50a02f5b
Status: Downloaded newer image for jfloff/alpine-python:3.6-onbuild
# Executing 3 build triggers
 ---> Running in 759ea9827709
First run, checking for any requirements...
Installing all APK requirements...
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
OK: 200 MiB in 63 packages
Pip requirements file detected!
Upgrading Pip...
Collecting pip
  Downloading https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl (1.4MB)
Installing collected packages: pip
  Found existing installation: pip 18.1
    Uninstalling pip-18.1:
      Successfully uninstalled pip-18.1
Successfully installed pip-19.1.1
Installing all Pip requirements...
Collecting Flask==0.12.1 (from -r /tmp/requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/f4/43/fb2d5fb1d10e1d0402dd57836cf9a78b7f69c8b5f76a04b6e6113d0d7c5a/Flask-0.12.1-py2.py3-none-any.whl (82kB)
Collecting gensim==3.4.0 (from -r /tmp/requirements.txt (line 2))
  Downloading https://files.pythonhosted.org/packages/04/a6/82ee7b14c204b82ec00e91fc6b67331cc7b28460ad72b2214384abd0e0a3/gensim-3.4.0.tar.gz (22.2MB)
Collecting pandas==0.23.0 (from -r /tmp/requirements.txt (line 3))
  Downloading https://files.pythonhosted.org/packages/45/12/1e1ba99fb65df9f7f3724d3232feef35cc044d18604d57492d561e90219f/pandas-0.23.0.tar.gz (13.1MB)
Collecting spacy==2.0.11 (from -r /tmp/requirements.txt (line 4))
  Downloading https://files.pythonhosted.org/packages/3c/31/e60f88751e48851b002f78a35221d12300783d5a43d4ef12fbf10cca96c3/spacy-2.0.11.tar.gz (17.6MB)
Collecting nltk==3.3 (from -r /tmp/requirements.txt (line 5))
  Downloading https://files.pythonhosted.org/packages/50/09/3b1755d528ad9156ee7243d52aa5cd2b809ef053a0f31b53d92853dd653a/nltk-3.3.0.zip (1.4MB)
Collecting sklearn==0.0 (from -r /tmp/requirements.txt (line 6))
  Downloading https://files.pythonhosted.org/packages/1e/7a/dbb3be0ce9bd5c8b7e3d87328e79063f8b263b2b1bfa4774cb1147bfcd3f/sklearn-0.0.tar.gz
Collecting scikit-learn==0.19.1 (from -r /tmp/requirements.txt (line 7))
  Downloading https://files.pythonhosted.org/packages/f5/2c/5edf2488897cad4fb8c4ace86369833552615bf264460ae4ef6e1f258982/scikit-learn-0.19.1.tar.gz (9.5MB)
Collecting lime==0.1.1.31 (from -r /tmp/requirements.txt (line 8))
  Downloading https://files.pythonhosted.org/packages/9e/99/83b41852ccd4a61b5bae114c5f920db12b1eb527a5eb1632f9bdd1fcf756/lime-0.1.1.31.tar.gz (264kB)
Collecting Keras==2.2.0 (from -r /tmp/requirements.txt (line 9))
  Downloading https://files.pythonhosted.org/packages/68/12/4cabc5c01451eb3b413d19ea151f36e33026fc0efb932bf51bcaf54acbf5/Keras-2.2.0-py2.py3-none-any.whl (300kB)
Collecting tensorflow==1.8.0 (from -r /tmp/requirements.txt (line 10))
  ERROR: Could not find a version that satisfies the requirement tensorflow==1.8.0 (from -r /tmp/requirements.txt (line 10)) (from versions: none)
ERROR: No matching distribution found for tensorflow==1.8.0 (from -r /tmp/requirements.txt (line 10))
The command '/bin/sh -c /entrypoint.sh -r /tmp/requirements.txt' returned a non-zero code: 1

My dockerfile:

FROM jfloff/alpine-python:3.6-onbuild

RUN mkdir app/
COPY requirements.txt app/
WORKDIR app/
RUN pip install --upgrade setuptools
RUN pip install -r requirements.txt
RUN python3 -m spacy download fr

COPY *.py /app/
COPY model.pk .

EXPOSE 1808

CMD ["gunicorn", "--bind", "0.0.0.0:1808", "main"]

My requirements.txt file:

Flask==0.12.1
gensim==3.4.0
pandas==0.23.0
spacy==2.0.11
nltk==3.3
sklearn==0.0
scikit-learn==0.19.1
lime==0.1.1.31
Keras==2.2.0
tensorflow==1.8.0
gunicorn

Any idea ?

Unable to install postgresql-dev since last update

Hello there,

We are unable to install the postgresql-dev package at version 9.5.4-r0 since the last version of your image. The error it gives:

ERROR: unsatisfiable constraints:
  postgresql-dev-9.6.0-r1:
    breaks: world[postgresql-dev=9.5.4-r0]

It's probably because you replace the default repositories with the edge ones?

The Dockerfile

update DIR to 3.8

Good job on this!

I looked at the Dockerfile. It uses alpine:3.8 but it's parent directory's parent is 3.6
IMHO, you should update these directorys names :)

Cheers!

screen shot 2018-12-14 at 11 18 50 am

Travis CI runs out of memory since latest docker image update (17-11-2017)

Hey there,

I see in the commit history that the latest change to this repo was 6 months ago, however according to dockerhub the latest build was done last friday. Since that time our CI has been broken with stalled builds. After debugging it turned out that we run out of memory.

Do you have any idea what could cause this? And how to fix this?

Thanks in advance

Unable to use python sqlite3

Trying to use peewee package with sqlite3 in jfloff/alpine-python:2.7.

Error:

peewee.ImproperlyConfigured: pysqlite or sqlite3 must be installed.

If import sqlite3 directly:

>>> import sqlite3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7.15/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
    from dbapi2 import *
  File "/usr/lib/python2.7.15/lib/python2.7/sqlite3/dbapi2.py", line 28, in <module>
    from _sqlite3 import *
ImportError: Error loading shared library libsqlite3.so.0: No such file or directory (needed by /usr/lib/python2.7.15/lib/python2.7/lib-dynload/_sqlite3.so)

More logging

Hi,

Thanks for this awesome project!

Could we add more logging when those files are detected?

apt-requirements.txt
build-requirements.txt
requirements.txt

Regards

requirements.txt installation fails.

I am generating my requirements.txtwith checksums, ie:

cryptography==2.1.4 --hash=sha256:69285f5615507b6625f89ea1048addd1d9218585fb886eb90bdebb1d2b2d26f5  --hash=sha256:6cb1224da391fa90f1be524eafb375b62baf8d3df9690b32e8cc475ccfccee5e  

which requires that the file is loaded via pip install -r โ€ฆ not by catting and adding it to the pip argument list. What is the rationale for reading the requirements file instead of just passing it to pip?

currently (Nov 2016) creating child image is not possible because of conflict

I got the following error:
which seems caused by http://bugs.alpinelinux.org/issues/6375 (especially as the date of your last commit and the date of this bug seems related I wouldn't be precised if the issue has appeared a little after your last image push)

Step 7 : RUN /entrypoint.sh   -b git && echo
 ---> Running in 76aeceda709c
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  musl-1.1.14-r12:
    breaks: musl-dev-1.1.14-r14[musl=1.1.14-r14]
    satisfies:
               musl-utils-1.1.14-r12[musl=1.1.14-r12]
               musl-utils-1.1.14-r12[so:libc.musl-x86_64.so.1]
               pkgconf-1.0.1-r0[so:libc.musl-x86_64.so.1]
               gcc-5.3.0-r0[so:libc.musl-x86_64.so.1]
               binutils-libs-2.26-r0[so:libc.musl-x86_64.so.1]
               libcrypto1.0-1.0.2j-r0[so:libc.musl-x86_64.so.1]
               g++-5.3.0-r0[so:libc.musl-x86_64.so.1]
               readline-6.3.008-r4[so:libc.musl-x86_64.so.1]
               sqlite-libs-3.15.0-r0[so:libc.musl-x86_64.so.1]
               mpfr3-3.1.2-r0[so:libc.musl-x86_64.so.1]
               ncurses-libs-6.0-r7[so:libc.musl-x86_64.so.1]
               python3-3.5.2-r4[so:libc.musl-x86_64.so.1]
               gdbm-1.12-r0[so:libc.musl-x86_64.so.1]
               libstdc++-5.3.0-r0[so:libc.musl-x86_64.so.1]
               libbz2-1.0.6-r5[so:libc.musl-x86_64.so.1]
               bash-4.3.46-r3[so:libc.musl-x86_64.so.1]
               isl-0.14.1-r0[so:libc.musl-x86_64.so.1]
               libcurl-7.51.0-r0[so:libc.musl-x86_64.so.1]
               mpc1-1.0.3-r0[so:libc.musl-x86_64.so.1]
               libressl2.4-libcrypto-2.4.3-r1[so:libc.musl-x86_64.so.1]
               git-2.8.3-r0[so:libc.musl-x86_64.so.1]
               pcre-8.38-r1[so:libc.musl-x86_64.so.1]
               libressl2.4-libssl-2.4.3-r1[so:libc.musl-x86_64.so.1]
               libffi-3.2.1-r2[so:libc.musl-x86_64.so.1]
               zlib-1.2.8-r2[so:libc.musl-x86_64.so.1]
               libgomp-5.3.0-r0[so:libc.musl-x86_64.so.1]
               apk-tools-2.6.7-r0[so:libc.musl-x86_64.so.1]
               libssh2-1.7.0-r0[so:libc.musl-x86_64.so.1]
               libgcc-5.3.0-r0[so:libc.musl-x86_64.so.1]
               make-4.1-r1[so:libc.musl-x86_64.so.1]
               alpine-baselayout-3.0.3-r0[so:libc.musl-x86_64.so.1]
               libatomic-5.3.0-r0[so:libc.musl-x86_64.so.1]
               xz-libs-5.2.2-r1[so:libc.musl-x86_64.so.1]
               ca-certificates-20160104-r6[so:libc.musl-x86_64.so.1]
               gmp-6.1.0-r0[so:libc.musl-x86_64.so.1]
               busybox-1.24.2-r11[so:libc.musl-x86_64.so.1]
               scanelf-1.1.6-r0[so:libc.musl-x86_64.so.1]
               libressl-2.4.3-r1[so:libc.musl-x86_64.so.1]
               expat-2.2.0-r0[so:libc.musl-x86_64.so.1]
               binutils-2.26-r0[so:libc.musl-x86_64.so.1]
               libssl1.0-1.0.2j-r0[so:libc.musl-x86_64.so.1]
  pkgconf-1.0.1-r0:
    conflicts: pkgconfig-0.25-r1[pkgconfig=1]
    satisfies: pkgconfig-0.25-r1[pkgconf]
               gcc-5.3.0-r0[pkgconfig]
               python3-dev-3.5.2-r4[pkgconfig]
  pkgconfig-0.25-r1:
    conflicts: pkgconf-1.0.1-r0
    satisfies: gcc-5.3.0-r0[pkgconfig]
               python3-dev-3.5.2-r4[pkgconfig]
The command '/bin/sh -c /entrypoint.sh   -b git && echo' returned a non-zero code: 47

gcc no file or dir

I am using locust for flood testing some api end points and when trying to install my requirements

locust
requests
requests_http_signature
cryptography

I am getting the follow error

Collecting locust (from -r requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/46/2e/18d4e363e76ec8f407ed018594f474d5669b3bca3977c4c664940fff95d5/locust-0.0.tar.gz
Collecting requests (from -r requirements.txt (line 2))
  Downloading https://files.pythonhosted.org/packages/7d/e3/20f3d364d6c8e5d2353c72a67778eb189176f08e873c9900e10c0287b84b/requests-2.21.0-py2.py3-none-any.whl (57kB)
Collecting requests_http_signature (from -r requirements.txt (line 3))
  Downloading https://files.pythonhosted.org/packages/45/c2/dd86e89f8f4fb6cc0028793f725bd536757b630c5734621f72b94b55ef53/requests_http_signature-0.1.0-py2.py3-none-any.whl
Collecting cryptography (from -r requirements.txt (line 4))
  Downloading https://files.pythonhosted.org/packages/07/ca/bc827c5e55918ad223d59d299fff92f3563476c3b00d0a9157d9c0217449/cryptography-2.6.1.tar.gz (491kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'error'
  Complete output from command /usr/local/lib/pyenv/versions/3.7.2/bin/python3.7 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-z3m77ig2 --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools>=18.5 wheel "cffi>=1.8,!=1.11.3; python_implementation != 'PyPy'":
  Collecting setuptools>=18.5
    Downloading https://files.pythonhosted.org/packages/d1/6a/4b2fcefd2ea0868810e92d519dacac1ddc64a2e53ba9e3422c3b62b378a6/setuptools-40.8.0-py2.py3-none-any.whl (575kB)
  Collecting wheel
    Downloading https://files.pythonhosted.org/packages/96/ba/a4702cbb6a3a485239fbe9525443446203f00771af9ac000fa3ef2788201/wheel-0.33.1-py2.py3-none-any.whl
  Collecting cffi!=1.11.3,>=1.8
    Downloading https://files.pythonhosted.org/packages/64/7c/27367b38e6cc3e1f49f193deb761fe75cda9f95da37b67b422e62281fcac/cffi-1.12.2.tar.gz (453kB)
  Collecting pycparser (from cffi!=1.11.3,>=1.8)
    Downloading https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz (158kB)
  Installing collected packages: setuptools, wheel, pycparser, cffi
    Running setup.py install for pycparser: started
      Running setup.py install for pycparser: finished with status 'done'
    Running setup.py install for cffi: started
      Running setup.py install for cffi: finished with status 'error'
      Complete output from command /usr/local/lib/pyenv/versions/3.7.2/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-nnzr2qwm/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-hg6d1qvl/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-z3m77ig2 --compile:
      unable to execute 'gcc': No such file or directory
      unable to execute 'gcc': No such file or directory
  
          No working compiler found, or bogus compiler options passed to
          the compiler from Python's standard "distutils" module.  See
          the error messages above.  Likely, the problem is not related
          to CFFI but generic to the setup.py of any Python package that
          tries to compile C code.  (Hints: on OS/X 10.8, for errors about
          -mno-fused-madd see http://stackoverflow.com/questions/22313407/
          Otherwise, see https://wiki.python.org/moin/CompLangPython or
          the IRC channel #python on irc.freenode.net.)
  
          Trying to continue anyway.  If you are trying to install CFFI from
          a build done in a different context, you can ignore this warning.
  
      running install
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.7
      creating build/lib.linux-x86_64-3.7/cffi
      copying cffi/cparser.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/recompiler.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/verifier.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/api.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/lock.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/commontypes.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/model.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/error.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/__init__.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/pkgconfig.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/_embedding.h -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.7/cffi
      running build_ext
      building '_cffi_backend' extension
      creating build/temp.linux-x86_64-3.7
      creating build/temp.linux-x86_64-3.7/c
      gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include/ffi -I/usr/include/libffi -I/usr/local/lib/pyenv/versions/3.7.2/include/python3.7m -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.7/c/_cffi_backend.o
      unable to execute 'gcc': No such file or directory
      error: command 'gcc' failed with exit status 1
  
      ----------------------------------------
  Command "/usr/local/lib/pyenv/versions/3.7.2/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-nnzr2qwm/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-hg6d1qvl/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-z3m77ig2 --compile" failed with error code 1 in /tmp/pip-install-nnzr2qwm/cffi/
  You are using pip version 18.1, however version 19.0.3 is available.
  You should consider upgrading via the 'pip install --upgrade pip' command.

dockerfile

FROM jfloff/alpine-python:latest-slim
ARG HOST
ADD requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
ADD locustfile.py locustfile.py
CMD [ "locust", "--host=${HOST}"]

python2-dev missing when instantiating alpine-python:2.7-slim

This happens when I try to instantiate an alpine-python:2.7-slim image:

> docker run --rm -ti jfloff/alpine-python:2.7-slim bash
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  python2-dev (missing):
    required by: world[python2-dev]

Am I using the image incorrectly or is this a bug?

more information about where the python console error and out go

my docker image is built on yours, and runs a long running python script

here's my docker file

FROM jfloff/alpine-python:3.7

WORKDIR /

COPY requirements.txt ./
RUN apk update && apk add postgresql-dev gcc python3-dev musl-dev tzdata
RUN ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime
RUN pip3 install --no-cache-dir -r requirements.txt

COPY . .

CMD [ "python", "./bmschecks/validateServers.py" ]

Unlike the default python docker image the console out doesn't seem to be returned to the command line/standard docker logs. Can you add some information to the README describing how to access standard out?

pip errors on latest alpine-python:3.6 image

Using the latest alpine-python:3.6 image produces SSL errors when using pip:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting awscli
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/awscli/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/awscli/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/awscli/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/awscli/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/awscli/
  Could not fetch URL https://pypi.org/simple/awscli/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/awscli/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping
  Could not find a version that satisfies the requirement awscli (from versions: )
No matching distribution found for awscli
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping

the attempt the reinstall the pip installation produces the same error:

(1/1) Installing curl (7.61.1-r0)
Executing busybox-1.28.4-r1.trigger
OK: 194 MiB in 48 packages
/ # curl https://bootstrap.pypa.io/get-pip.py | python3
 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                Dload  Upload   Total   Spent    Left  Speed
100 1622k  100 1622k    0     0  1244k      0  0:00:01  0:00:01 --:--:-- 1244k
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting pip
 Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
 Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
 Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
 Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
 Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
 Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping
 Could not find a version that satisfies the requirement pip (from versions: )
No matching distribution found for pip
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping

It would seem to be a difference in the libressl-dev and openssl-dev packages on the alpine image, as swapping to the libressl-dev package does not produce the issue. I'm still trying to figure out the difference that would cause this.

alpine-python:3.4 images currently contain 3.5

Repro:
$ docker rmi jfloff/alpine-python:3.4; docker pull jfloff/alpine-python:3.4 (force re-download the newest image if it's already cached)
$ docker run --rm jfloff/alpine-python:3.4 python --version

Expected:
Python 3.4.x

Actual:
"Python 3.5.2"

The issue seems to be that the Dockerfile just runs "apk add python3", and Alpine 3.4 is currently shlpping 3.5.2. I can confirm this with "docker run --rm -it alpine:3.4 sh" then "apk add --no-cache python3" which installs 3.5.2-r0.

Build deps removal dilemma

This is not a bug on its own, but rather a question of efficiency.

If I add some python library that requires binary objects to be built or run (examples: lxml requires libxml2 and libxslt, postgres psycopg2 requires libpq to run and postgresql-dev to build, etc) then I would have to essentially repeat all the installation and removal rituals in my descendant image. At the same time it would be more efficient to just have a custom dockerfile with the cleanup done once in the last stage of the build, and just docker-squash the resulting image.

Currently I see several ways out of this dilemma:

  • provide template dockerfiles for that particular approach, where you could edit the dockerfile, adding the necessary libraries between the build tools installation command and the cleanup, and let the user squash the image after build;
  • add an ARG so that the installed tools would be controlled (added) by this build time argument, and this would not even require squashing the image.

There might be other ways of doing it, any ideas/suggestions?

Fails to build image - unable to find entrypoint.sh

Pulling the tag 3.4-onbuild appears to not work.

FROM jfloff/alpine-python:3.4-onbuild

results in

Sending build context to Docker daemon 52.74 kB
Step 1 : FROM jfloff/alpine-python:3.4-onbuild
3.4-onbuild: Pulling from jfloff/alpine-python

c0cb142e4345: Pull complete
9220b57f4f62: Pull complete
Digest: sha256:833747868f7c9da014e1906f2a7197e40267d8fa5a9601d328a6a670247e419a
Status: Downloaded newer image for jfloff/alpine-python:3.4-onbuild

Executing 3 build triggers...

Step 1 : COPY requirements.txt /tmp/requirements.txt
Step 1 : RUN /entrypoint.sh -r /tmp/requirements.txt
---> Running in 024892bbb802
/bin/sh: /entrypoint.sh: not found
The command '/bin/sh -c /entrypoint.sh -r /tmp/requirements.txt' returned a non-zero code: 127

I may be doing something wrong but when I switch to 3.4-slim it works as expected which leads me to suspect a missing file in the image tag.

Shared libraries not found since last commit

After 3f0751f all pip packages that use c libraries are broken.

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip._internal import main
  File "/usr/local/lib/pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_internal/__init__.py", line 40, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/local/lib/pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/local/lib/pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_internal/cli/main_parser.py", line 12, in <module>
    from pip._internal.commands import (
  File "/usr/local/lib/pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_internal/commands/__init__.py", line 6, in <module>
    from pip._internal.commands.completion import CompletionCommand
  File "/usr/local/lib/pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_internal/commands/completion.py", line 6, in <module>
    from pip._internal.cli.base_command import Command
  File "/usr/local/lib/pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 18, in <module>
    from pip._internal.download import PipSession
  File "/usr/local/lib/pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_internal/download.py", line 38, in <module>
    from pip._internal.utils.glibc import libc_ver
  File "/usr/local/lib/pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_internal/utils/glibc.py", line 3, in <module>
    import ctypes
  File "/usr/local/lib/pyenv/versions/3.6.8/lib/python3.6/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ImportError: Error loading shared library libffi.so.6: No such file or directory (needed by /usr/local/lib/pyenv/versions/3.6.8/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so)

Building the container behind a proxy

Hi

One interesting question... How to build a container behind a proxy?

When running pip to install the dependencies, it cant resolve the host, so you need to add a proxy in the docker file

While using a ubuntu image, exporting the proxy is easy (ENV http_proxy .....), using alpine or python templates doesnt work

Any idea on how to solve this problem?

daemonic processes are not allowed to have children

Hi, I got below error while using multiprocessing

Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/lib64/python2.7/site-packages/flask_restful/__init__.py", line 273, in error_router
    return original_handler(e)
  File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib64/python2.7/site-packages/flask_restful/__init__.py", line 273, in error_router
    return original_handler(e)
  File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/data/bid/pipeline/app.py", line 121, in task_create
    run_task(config)
  File "/data/bid/pipeline/tasks.py", line 66, in run_task
    run_in_subprocess(_run_task, config)
  File "/data/bid/pipeline/tasks.py", line 27, in run_in_subprocess
    thread.start()
  File "/usr/lib64/python2.7/multiprocessing/process.py", line 124, in start
    'daemonic processes are not allowed to have children'
AssertionError: daemonic processes are not allowed to have children

relevant code:

def run_in_subprocess(func, *args, **kwargs):
    from multiprocessing import Process
    thread = Process(target=func, args=args, kwargs=kwargs)
    thread.daemon = True
    thread.start()
    return thread

This error not show in python:2.7 image.

handling multiple pythons

Just throwing an idea out there, as far as handling arbitrary python versions - you could install pyenv in the container, which would give access to a really nice version management system (and not just python, but pypy, anaconda, and friends). You could put pyenv in the container itself, or just use it to grab the right version of python during the build process. What do you think?

It also looks like the official python alpine images you linked to in the readme (link is broken now) provide multiple 3.x versions of python: https://github.com/docker-library/python - but that's much less fine-grained than pyenv.

Update to Alpine 3.11 on 2.7 python images with same tag

Hello, when you upgrade version of alpine, main repository changes:

before

apk update -q && apk add --no-cache nodejs curl unzip bash npm
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
(1/7) Installing curl (7.61.1-r3)
(2/7) Installing c-ares (1.14.0-r0)
(3/7) Installing http-parser (2.8.1-r0)
(4/7) Installing libuv (1.20.2-r0)
(5/7) Installing nodejs (8.14.0-r0)
(6/7) Installing npm (8.14.0-r0)
(7/7) Installing unzip (6.0-r6)
Executing busybox-1.28.4-r3.trigger
OK: 250 MiB in 70 packages

after

apk update -q && apk add --no-cache nodejs curl unzip bash npm
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
(1/6) Installing curl (7.67.0-r0)
(2/6) Installing c-ares (1.15.0-r0)
(3/6) Installing libuv (1.34.0-r0)
(4/6) Installing nodejs (12.15.0-r1)
(5/6) Installing npm (12.15.0-r1)
(6/6) Installing unzip (6.0-r6)
Executing busybox-1.31.1-r9.trigger
OK: 284 MiB in 70 packages

as a result, many dependencies collapse. Changing the tag without replacing the old one would solve this problem

Python 2.7 slim broken?

I'm trying to use your image for a build on a custom Gitlab server. There seems to be an issue in a requirements.txt file.

  on docker-python27 79ee53a0
Using Docker executor with image jfloff/alpine-python:2.7-slim ...
Pulling docker image jfloff/alpine-python:2.7-slim ...
Using docker image sha256:92838a7ae9595ca7b6928a8285b8c036c9189c6990ce7b953f6001c07c03b169 for jfloff/alpine-python:2.7-slim ...
Running on runner-79ee53a0-project-18-concurrent-0 via triton...
Fetching changes...
Removing .venv/
HEAD is now at 064e209 Attempt at docker CI
From http://192.168.1.70/XXX/YYY
   064e209..5a25dad  RevD-docker-ci -> origin/RevD-docker-ci
Checking out 5a25dadd as RevD-docker-ci...
Skipping Git submodules setup
First run, checking for any requirements...
Installing all APK requirements...
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
(1/27) Upgrading musl (1.1.18-r2 -> 1.1.18-r3)
(2/27) Installing binutils-libs (2.30-r1)
(3/27) Installing binutils (2.30-r1)
(4/27) Installing gmp (6.1.2-r1)
(5/27) Installing isl (0.18-r0)
(6/27) Installing libgomp (6.4.0-r5)
(7/27) Installing libatomic (6.4.0-r5)
(8/27) Installing libgcc (6.4.0-r5)
(9/27) Installing mpfr3 (3.1.5-r1)
(10/27) Installing mpc1 (1.0.3-r1)
(11/27) Installing libstdc++ (6.4.0-r5)
(12/27) Installing gcc (6.4.0-r5)
(13/27) Installing musl-dev (1.1.18-r3)
(14/27) Installing libc-dev (0.7.1-r0)
(15/27) Installing g++ (6.4.0-r5)
(16/27) Installing make (4.2.1-r0)
(17/27) Installing fortify-headers (0.9-r0)
(18/27) Installing build-base (0.5-r0)
(19/27) Installing libssh2 (1.8.0-r2)
(20/27) Installing libcurl (7.61.1-r0)
(21/27) Installing pcre2 (10.30-r0)
(22/27) Installing git (2.15.2-r0)
(23/27) Upgrading musl-utils (1.1.18-r2 -> 1.1.18-r3)
(24/27) Installing libc6-compat (1.1.18-r3)
(25/27) Installing linux-headers (4.4.6-r2)
(26/27) Upgrading python2 (2.7.14-r2 -> 2.7.15-r2)
(27/27) Installing python2-dev (2.7.15-r2)
Executing busybox-1.27.2-r7.trigger
OK: 240 MiB in 50 packages
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
(1/24) Purging build-base (0.5-r0)
(2/24) Purging g++ (6.4.0-r5)
(3/24) Purging gcc (6.4.0-r5)
(4/24) Purging binutils (2.30-r1)
(5/24) Purging libatomic (6.4.0-r5)
(6/24) Purging libgomp (6.4.0-r5)
(7/24) Purging libstdc++ (6.4.0-r5)
(8/24) Purging make (4.2.1-r0)
(9/24) Purging libc-dev (0.7.1-r0)
(10/24) Purging musl-dev (1.1.18-r3)
(11/24) Purging fortify-headers (0.9-r0)
(12/24) Purging git (2.15.2-r0)
(13/24) Purging libc6-compat (1.1.18-r3)
(14/24) Purging linux-headers (4.4.6-r2)
(15/24) Purging python2-dev (2.7.15-r2)
(16/24) Purging binutils-libs (2.30-r1)
(17/24) Purging mpc1 (1.0.3-r1)
(18/24) Purging mpfr3 (3.1.5-r1)
(19/24) Purging isl (0.18-r0)
(20/24) Purging gmp (6.1.2-r1)
(21/24) Purging libgcc (6.4.0-r5)
(22/24) Purging libcurl (7.61.1-r0)
(23/24) Purging libssh2 (1.8.0-r2)
(24/24) Purging pcre2 (10.30-r0)
Executing busybox-1.27.2-r7.trigger
OK: 56 MiB in 26 packages
[: line 1: syntax error: unexpected end of file (expecting "then")
/requirements.installed file exists-- skipping requirements installs.
[: line 1: syntax error: unexpected end of file (expecting "then")
ERROR: Job failed: exit code 2```

Packages purging

Hi,

Upon building the image and making a first run, the initial script seems to be purging git and other packages which I require.

I believe it might be something to do with this line in entrypoint.sh:

# Remove packages that were only required for build.
  apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}"

ERROR: unsatisfiable constraints

I'm not sure if I'm doing something wrong here, but I continue to receive this error.

โžœ  blog docker run --rm -ti jfloff/alpine-python:2.7-slim /bin/bash
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  readline-7.0.003-r0:
    conflicts: readline-6.3.008-r5
    satisfies: bash-4.4.12-r1[so:libreadline.so.7]
  readline-6.3.008-r5:
    conflicts: readline-7.0.003-r0
    satisfies: python2-2.7.13-r1[so:libreadline.so.6]

I'm forking squidfunk/mkdocs-material and want to use nginx for hosting locally instead of the built in development mkdocs server, but am having trouble even getting this to run on its own. Am I doing something wrong?

libffi / ffi.h issue on alpine-python:3.6-onbuild

I could be doing something wrong but I get the following with a fairly simple requirements.txt and alpine-python:3.6-onbuild. This could be just an issue with upstream pip however?

Short summary

  Installing build dependencies: finished with status 'error'
  Complete output from command /usr/lib/python3.6.6/bin/python3.6 /usr/lib/python3.6.6/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-c3okpqft/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel "cffi>=1.4.1; python_implementation != 'PyPy'":

Full log

      Running setup.py install for cffi: finished with status 'error'
      Complete output from command /usr/lib/python3.6.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-labi968q/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-t4nbxvbv/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-r9ugyqb3/overlay --compile:
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      Package 'libffi', required by 'virtual:world', not found
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      Package 'libffi', required by 'virtual:world', not found
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      Package 'libffi', required by 'virtual:world', not found
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      Package 'libffi', required by 'virtual:world', not found
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      Package 'libffi', required by 'virtual:world', not found
      running install
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.6
      creating build/lib.linux-x86_64-3.6/cffi
      copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/model.py -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/commontypes.py -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/error.py -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/cparser.py -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/pkgconfig.py -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/api.py -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/lock.py -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/__init__.py -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/verifier.py -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/recompiler.py -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/_embedding.h -> build/lib.linux-x86_64-3.6/cffi
      copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.6/cffi
      running build_ext
      building '_cffi_backend' extension
      creating build/temp.linux-x86_64-3.6
      creating build/temp.linux-x86_64-3.6/c
      gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/lib/python3.6.6/include/python3.6m -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.6/c/_cffi_backend.o
      c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
       #include <ffi.h>
                       ^
      compilation terminated.
      error: command 'gcc' failed with exit status 1
  
      ----------------------------------------
  Command "/usr/lib/python3.6.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-labi968q/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-t4nbxvbv/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-r9ugyqb3/overlay --compile" failed with error code 1 in /tmp/pip-install-labi968q/cffi/

Here's my requirements.txt

cherrypy
pyyaml
mongoengine
requests
ipdb
python-wordpress-xmlrpc
python-git
flake8
paramiko
pexpect

Here's my Dockerfile

FROM jfloff/alpine-python:3.6-onbuild

RUN apk upgrade --update
RUN apk add git
WORKDIR /opt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.