├── .github └── workflows │ └── build-and-push.yaml ├── Dockerfile ├── LICENSE └── README.md /.github/workflows/build-and-push.yaml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: 4 | push: 5 | branches: 6 | - 'master' 7 | schedule: 8 | # Daily 9 | - cron: '0 4 * * *' 10 | workflow_dispatch: 11 | 12 | env: 13 | DOCKERHUB_REPO: frolvlad/alpine-python3 14 | 15 | jobs: 16 | build: 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | include: 21 | - platform: linux/amd64 22 | os: ubuntu-24.04 23 | - platform: linux/arm64 24 | os: ubuntu-24.04-arm 25 | runs-on: ${{ matrix.os }} 26 | steps: 27 | - name: Prepare 28 | run: | 29 | platform=${{ matrix.platform }} 30 | echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV 31 | 32 | - name: Docker meta 33 | id: meta 34 | uses: docker/metadata-action@v5 35 | with: 36 | images: | 37 | ${{ env.DOCKERHUB_REPO }} 38 | labels: | 39 | org.opencontainers.image.created={{commit_date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'}} 40 | 41 | - name: Login to Docker Hub 42 | uses: docker/login-action@v3 43 | with: 44 | username: ${{ vars.DOCKERHUB_USERNAME }} 45 | password: ${{ secrets.DOCKERHUB_TOKEN }} 46 | 47 | - name: Set up Docker Buildx 48 | uses: docker/setup-buildx-action@v3 49 | 50 | - name: Build and push by digest 51 | id: build 52 | uses: docker/build-push-action@v6 53 | with: 54 | platforms: ${{ matrix.platform }} 55 | labels: ${{ steps.meta.outputs.labels }} 56 | provenance: false 57 | outputs: type=image,"name=${{ env.DOCKERHUB_REPO }}",push-by-digest=true,name-canonical=true,push=true 58 | push: true 59 | cache-from: type=registry,ref=${{ env.DOCKERHUB_REPO }}:buildcache-${{ env.PLATFORM_PAIR }} 60 | cache-to: type=registry,ref=${{ env.DOCKERHUB_REPO }}:buildcache-${{ env.PLATFORM_PAIR }},mode=max 61 | 62 | - name: Export digest 63 | run: | 64 | mkdir -p ${{ runner.temp }}/digests 65 | digest="${{ steps.build.outputs.digest }}" 66 | touch "${{ runner.temp }}/digests/${digest#sha256:}" 67 | 68 | - name: Upload digest 69 | uses: actions/upload-artifact@v4 70 | with: 71 | name: digests-${{ env.PLATFORM_PAIR }} 72 | path: ${{ runner.temp }}/digests/* 73 | if-no-files-found: error 74 | retention-days: 1 75 | 76 | merge: 77 | runs-on: ubuntu-latest 78 | needs: 79 | - build 80 | steps: 81 | - name: Download digests 82 | uses: actions/download-artifact@v4 83 | with: 84 | path: ${{ runner.temp }}/digests 85 | pattern: digests-* 86 | merge-multiple: true 87 | 88 | - name: Login to Docker Hub 89 | uses: docker/login-action@v3 90 | with: 91 | username: ${{ vars.DOCKERHUB_USERNAME }} 92 | password: ${{ secrets.DOCKERHUB_TOKEN }} 93 | 94 | - name: Set up Docker Buildx 95 | uses: docker/setup-buildx-action@v3 96 | 97 | - name: Create manifest list and push 98 | working-directory: ${{ runner.temp }}/digests 99 | run: | 100 | docker buildx imagetools create \ 101 | -t ${{ env.DOCKERHUB_REPO }}:latest \ 102 | $(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *) 103 | 104 | - name: Inspect image 105 | run: | 106 | docker buildx imagetools inspect ${{ env.DOCKERHUB_REPO }}:latest 107 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.21 2 | 3 | # This hack is widely applied to avoid python printing issues in docker containers. 4 | # See: https://github.com/Docker-Hub-frolvlad/docker-alpine-python3/pull/13 5 | ENV PYTHONUNBUFFERED=1 6 | 7 | RUN echo "**** install Python ****" && \ 8 | apk add --no-cache python3 && \ 9 | if [ ! -e /usr/bin/python ]; then ln -sf python3 /usr/bin/python ; fi && \ 10 | \ 11 | echo "**** install pip ****" && \ 12 | rm /usr/lib/python3.12/EXTERNALLY-MANAGED && \ 13 | python -m ensurepip && \ 14 | rm -r /usr/lib/python*/ensurepip && \ 15 | if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \ 16 | pip install --no-cache --upgrade pip setuptools wheel 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Vlad 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Docker Stars](https://img.shields.io/docker/stars/frolvlad/alpine-python3.svg?style=flat-square)](https://hub.docker.com/r/frolvlad/alpine-python3/) 2 | [![Docker Pulls](https://img.shields.io/docker/pulls/frolvlad/alpine-python3.svg?style=flat-square)](https://hub.docker.com/r/frolvlad/alpine-python3/) 3 | 4 | 5 | Python 3.12 Docker image 6 | ======================== 7 | 8 | This image is based on Alpine Linux image, which is only a 5MB image, and contains 9 | [Python 3.x](https://www.python.org/). 10 | 11 | This image is only 71MB on disk. 12 | 13 | 14 | Usage Example 15 | ------------- 16 | 17 | ```bash 18 | $ docker run --rm frolvlad/alpine-python3 python3 -c 'print("Hello World")' 19 | ``` 20 | 21 | Once you have run this command you will get printed 'Hello World' from Python! Or use it interactivelly: 22 | 23 | ```bash 24 | $ docker run -it --rm frolvlad/alpine-python3 python3 25 | ``` 26 | 27 | 28 | NOTE: `pip`/`pip3` is also available in this image. 29 | --------------------------------------------------------------------------------