diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 1b9eae0..d3d0941 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -7,36 +7,69 @@ on: types: [published, created, edited] pull_request: jobs: - push: + build_base_image: + strategy: + matrix: + python: [3.8, 3.9, 3.10.6, 3.11.1] + alpine: ["3.15", "3.16"] runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - - name: Docker meta - id: meta - uses: docker/metadata-action@v3 - with: - # list of Docker images to use as base name for tags - images: | - ghcr.io/${{ github.repository_owner }}/web-base - # generate Docker tags based on the following events/attributes - tags: | - type=semver,pattern={{row}} - type=sha - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + - name: Login to ghcr uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Web-base Meta + id: meta-web-base + uses: docker/metadata-action@v3 + with: + images: | + ghcr.io/${{ github.repository_owner }}/web-base + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + platforms: linux/amd64,linux/arm64 + - name: Build and push uses: docker/build-push-action@v2 with: + build-args: | + PYTHON_VERSION=${{ matrix.python }} + ALPINE_VERSION=${{ matrix.alpine }} context: . - platforms: linux/amd64,linux/arm64 + file: ./Docker/Dockerfile.base push: true - tags: ${{ steps.meta.outputs.tags }} + tags: ${{ matrix.python }}-alpine${{ matrix.alpine }} + +# - name: Poetry Meta +# id: meta-web-poetry +# uses: docker/metadata-action@v3 +# with: +# images: | +# ghcr.io/${{ github.repository_owner }}/web-base +# +# - name: Set up Docker Buildx +# uses: docker/setup-buildx-action@v2 +# with: +# platforms: linux/amd64,linux/arm64 +# build-args: | +# PYTHON_VERSION=${{ matrix.python }} +# ALPINE_VERSION=${{ matrix.alpine }} +# +# - name: Build and push Poetry +# uses: docker/build-push-action@v2 +# with: +# context: . +# file: ./Docker/Dockerfile.poetry +# platforms: linux/amd64,linux/arm64 +# push: true +# tags: ${{ matrix.python }}-alpine${{ matrix.alpine }} diff --git a/Dockerfile b/Docker/Dockerfile.base similarity index 79% rename from Dockerfile rename to Docker/Dockerfile.base index f59aa5c..b4e406a 100644 --- a/Dockerfile +++ b/Docker/Dockerfile.base @@ -1,4 +1,7 @@ -FROM python:3.10.6-alpine3.16 AS build-image +ARG PYTHON_VERSION +ARG ALPINE_VERSION + +FROM python:$PYTHON_VERSION-alpine$ALPINE_VERSION AS build-image RUN apk update \ && apk add --no-cache \ @@ -6,6 +9,6 @@ RUN apk update \ make autoconf libtool postgresql-dev build-base g++ gcc \ unixodbc-dev freetds-dev libffi libffi-dev czmq-dev libxml2-dev \ libxslt-dev automake cmake git openssl-dev ffmpeg libwebp-dev \ - cargo poetry + cargo CMD ["/bin/bash"] diff --git a/Docker/Dockerfile.poetry b/Docker/Dockerfile.poetry new file mode 100644 index 0000000..0ca412a --- /dev/null +++ b/Docker/Dockerfile.poetry @@ -0,0 +1,12 @@ +ARG PYTHON_VERSION +ARG ALPINE_VERSION + +FROM python:$PYTHON_VERSION-alpine$ALPINE_VERSION AS poetry +ARG install_dev +WORKDIR /app +ENV POETRY_HOME=/opt/poetry +ENV POETRY_VIRTUALENVS_IN_PROJECT=true +ENV PATH="$POETRY_HOME/bin:$PATH" +RUN python -c 'from urllib.request import urlopen; print(urlopen("https://install.python-poetry.org").read().decode())' | python - + +CMD ["/bin/bash"] \ No newline at end of file