Skip to content

Commit

Permalink
refactor: prepare repo for 3.11 and 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarcoatl committed Sep 13, 2023
1 parent a4d7399 commit 42c1aa9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint Dockerfile
name: Lint Dockerfiles

on:
workflow_dispatch:
Expand All @@ -16,3 +16,6 @@ jobs:

- name: Lint Dockerfile
uses: hadolint/hadolint-action@v3.1.0
with:
recursive: true
verbose: true
12 changes: 10 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Get Dockerfile subdirectory
id: dockerfile
run: echo "subdir=$(echo ${{ github.event.release.tag_name }} | cut -d '.' -f 1,2)" >> $GITHUB_OUTPUT

- name: Read __VERSION__ file
id: getversion
run: echo "version=$(cat ${{ steps.dockerfile.outputs.subdir }}/__VERSION__)" >> $GITHUB_OUTPUT

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
Expand All @@ -24,13 +32,13 @@ jobs:
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
context: ${{ steps.dockerfile.outputs.subdir }}
platforms: |
linux/amd64
linux/arm64
push: true
tags: |
coatldev/six:${{ github.event.release.tag_name }}
coatldev/six:latest
coatldev/six:${{ steps.dockerfile.outputs.subdir }}
cache-from: type=gha
cache-to: type=gha,mode=max
1 change: 0 additions & 1 deletion .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
ignored:
- DL3008 # apt-get install pinned versions
- DL3013 # pip install pinned versions
27 changes: 14 additions & 13 deletions Dockerfile → 3.10/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ ENV PIP_NO_PYTHON_VERSION_WARNING 1
ENV PIP_ROOT_USER_ACTION ignore

# python
ARG PYTHON310_VERSION
ENV PYTHON_ROOT /opt/python
ENV PYTHON2_VERSION 2.7.18
ENV PYTHON3_VERSION 3.10.13
ENV PYTHON3_VERSION ${PYTHON310_VERSION}

# base dependencies
RUN set -eux; \
Expand Down Expand Up @@ -81,7 +82,7 @@ RUN set -eux; \

# > =============================================================== <

FROM builder AS python27
FROM builder AS python2

WORKDIR /tmp

Expand All @@ -97,7 +98,7 @@ RUN set -eux; \
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
./configure \
--build="$gnuArch" \
--prefix="${PYTHON_ROOT}/2.7/" \
--prefix="${PYTHON_ROOT}/2/" \
--enable-optimizations \
--enable-option-checking=fatal \
--enable-shared \
Expand Down Expand Up @@ -155,11 +156,11 @@ RUN set -eux; \
# update Pip, Setuptools and Wheel packages
RUN set -eux; \
\
"${PYTHON_ROOT}/2.7/bin/python2.7" -m ensurepip --default-pip; \
"${PYTHON_ROOT}/2.7/bin/python2.7" -m pip install --upgrade pip setuptools wheel
"${PYTHON_ROOT}/2/bin/python2.7" -m ensurepip --default-pip; \
"${PYTHON_ROOT}/2/bin/python2.7" -m pip install --upgrade pip setuptools wheel

# add some soft links for comfortable usage
WORKDIR "${PYTHON_ROOT}/2.7/bin"
WORKDIR "${PYTHON_ROOT}/2/bin"
RUN set -eux; \
\
ln -s idle idle2; \
Expand All @@ -169,7 +170,7 @@ RUN set -eux; \

# > =============================================================== <

FROM builder AS python310
FROM builder AS python3

WORKDIR /tmp

Expand All @@ -185,7 +186,7 @@ RUN set -eux; \
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
./configure \
--build="$gnuArch" \
--prefix="${PYTHON_ROOT}/3.10/" \
--prefix="${PYTHON_ROOT}/3/" \
--enable-loadable-sqlite-extensions \
--enable-optimizations \
--enable-option-checking=fatal \
Expand Down Expand Up @@ -224,10 +225,10 @@ RUN set -eux; \
# update Pip, Setuptools and Wheel packages
RUN set -eux; \
\
"${PYTHON_ROOT}/3.10/bin/python3.10" -m pip install --upgrade pip setuptools wheel
"${PYTHON_ROOT}/3/bin/python3.10" -m pip install --upgrade pip setuptools wheel

# add some soft links for comfortable usage
WORKDIR "${PYTHON_ROOT}/3.10/bin"
WORKDIR "${PYTHON_ROOT}/3/bin"
RUN set -eux; \
\
ln -s idle3.10 idle3; \
Expand All @@ -241,11 +242,11 @@ RUN set -eux; \

FROM base AS final

COPY --from=python27 ${PYTHON_ROOT}/2.7/ ${PYTHON_ROOT}/2.7/
COPY --from=python310 ${PYTHON_ROOT}/3.10/ ${PYTHON_ROOT}/3.10/
COPY --from=python2 ${PYTHON_ROOT}/2/ ${PYTHON_ROOT}/2/
COPY --from=python3 ${PYTHON_ROOT}/3/ ${PYTHON_ROOT}/3/

# ensure local python is preferred over distribution python
ENV PATH ${PYTHON_ROOT}/3.10/bin:${PYTHON_ROOT}/2.7/bin:$PATH
ENV PATH ${PYTHON_ROOT}/3/bin:${PYTHON_ROOT}/2/bin:$PATH

# git config "hack"
RUN set -eux; \
Expand Down
1 change: 1 addition & 0 deletions 3.10/__VERSION__
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10.13

0 comments on commit 42c1aa9

Please sign in to comment.