Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push alpine stuff upstream into an apk package #454

Closed
dazza-codes opened this issue Feb 29, 2020 · 5 comments
Closed

Push alpine stuff upstream into an apk package #454

dazza-codes opened this issue Feb 29, 2020 · 5 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@dazza-codes
Copy link

dazza-codes commented Feb 29, 2020

Is it possible to push all of this into an alpine package:

So the Dockerfile can simply do:

FROM alpine:3.11
RUN apk add python3=3.6
# plus docker-specific stuff for ENV, CMD or whatever

The current alpine package is not working for python 3.6, e.g.

$ docker run --rm -it alpine:latest
/ # apk add python3=3.6
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  python3-3.8.1-r0:
    breaks: world[python3=3.6]

use case

To use docker-in-docker to run tests that need to run docker containers in gitlab, the gitlab-CI needs to use docker:19.03.6, which is based on alpine:3.11. But alpine:3.11 has no python package for 3.6 (please point to one if it exists), so it's not possible to use docker:19.03.6 with python 3.6 (AFAICT), without the project having to provide it's own docker image/build and run all it's tests inside a custom image for the project. Then anything inside that container that needs to run docker needs the same thing - it can't do docker-in-docker-in-docker - it's nuts. That's extra overhead that the project could avoid if apk can install any python 3.x and maybe this project has all the clues about how to contribute back to apk to use any python 3.x package.

@dazza-codes
Copy link
Author

dazza-codes commented Feb 29, 2020

I have no idea how to effectively contribute to apk, but this quick attempt is more trouble than I really have time for now

@dazza-codes
Copy link
Author

dazza-codes commented Mar 1, 2020

Also explored this in https://gitlab.alpinelinux.org/alpine/aports/merge_requests/4846 to use a similar update script to provide all current python versions. This could provide a way to focus efforts on the alpine python builds into the details of the APKBUILD template file and associated sed scripts in the update script. It would help if the community involved in this docker-python project could contribute to that upstream alpine build.

@dazza-codes
Copy link
Author

For practical purposes, I solved my immediate use-case for a gitlab-CI base image using

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Mar 2, 2020
@wglambert
Copy link

wglambert commented Mar 2, 2020

Alpine's package repos only contain the latest version.
Python2 is at 2.7.16-r3 and Python3 is 3.8.2-r0
We install Python from source

&& wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \

with these options
&& ./configure \
--build="$gnuArch" \
--enable-loadable-sqlite-extensions \
--enable-optimizations \
--enable-option-checking=fatal \
--enable-shared \
--with-system-expat \
--with-system-ffi \
--without-ensurepip \
&& make -j "$(nproc)" \

gitlab-CI needs to use docker:19.03.6, which is based on alpine:3.11

You can install it from source as our Dockerfile does or maybe try the dind variant for running the python container?

alpine:3.11 has no python package for 3.6

What about python:3.6-alpine3.11?

$ docker pull python:3.6-alpine3.11
3.6-alpine3.11: Pulling from library/python
Digest: sha256:565c566c317c077fdc520a5dcee8374339bda70ddd9f2dfad9499cde45fb5831
Status: Downloaded newer image for python:3.6-alpine3.11
docker.io/library/python:3.6-alpine3.11

$ docker run -it --rm python:3.6-alpine3.11 ash
/ # python --version
Python 3.6.10

/ # cat /etc/os-release 
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.11.3
PRETTY_NAME="Alpine Linux v3.11"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"

@tianon
Copy link
Member

tianon commented Nov 24, 2020

If the goal is simply to have the Docker client in an Alpine-based Python image, I think going the other way is probably easier -- the Docker client itself is just a static binary, so something like the following should work reasonably well:

FROM python:3.6-alpine3.11
COPY --from=docker:19.03 /usr/local/bin/docker /usr/local/bin/
RUN docker --version
$ docker build --pull .
Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM python:3.6-alpine3.11
3.6-alpine3.11: Pulling from library/python
Digest: sha256:bfd26729964b518c651270064dd54fe122ce0deeb69c43dbefb3176a8bdbb18f
Status: Image is up to date for python:3.6-alpine3.11
 ---> b2bb7dfc2c59
Step 2/3 : COPY --from=docker:19.03 /usr/local/bin/docker /usr/local/bin/
19.03: Pulling from library/docker
Digest: sha256:9170b902404a630a982a2a6473442d3e2cc2342b66345f7a9cf148f8affcf5d3
Status: Image is up to date for docker:19.03
 ---> Using cache
 ---> dd163e21c144
Step 3/3 : RUN docker --version
 ---> Running in d26884bf28d8
Docker version 19.03.13, build 4484c46
Removing intermediate container d26884bf28d8
 ---> e88b81e2f766
Successfully built e88b81e2f766

(Closing, since the original ask is better tracked in https://gitlab.alpinelinux.org/alpine/aports/issues/11265, and isn't something we have any real interest or bandwidth in contributing to.)

@tianon tianon closed this as completed Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

3 participants