-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker setup & images releaser for multiple archs
- Loading branch information
Showing
14 changed files
with
209 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Dockerfile | ||
docker-compose* | ||
.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,72 @@ | ||
name: croniter | ||
on: [workflow_dispatch, push, pull_request] | ||
name: CI/CD | ||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
schedule: [{cron: '1 0 * * 6'}] | ||
env: | ||
DOCKER_BUILDKIT: "1" | ||
COMPOSE_DOCKER_CLI_BUILD: "1" | ||
BUILDKIT_PROGRESS: "plain" | ||
RELEASABLE_REPOS: "^kiorky/" | ||
RELEASABLE_BRANCHES: "^(refs/heads/)?(master|main|new-packaging)$" | ||
jobs: | ||
build-py2: | ||
test-py2: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["2.7"] | ||
strategy: {fail-fast: false} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
- name: Cache tox environments | ||
uses: actions/cache@v4 | ||
with: | ||
path: .cache | ||
key: ${{ runner.os }}-py27 | ||
- name: install dependencies && test on py27 | ||
run: | | ||
set -ex | ||
export PIP_CACHE_DIR=$(pwd)/.cache/pip;export PIP_DOWNLOAD_CACHE=$PIP_CACHE_DIR | ||
mkdir -pv $PIP_CACHE_DIR || true | ||
sudo apt update && sudo apt install -y python2.7 | ||
# install py 2 with eg: apt install python2.7 | ||
mkdir venv2 && curl -sSL "https://github.com/pypa/get-virtualenv/blob/20.27.0/public/2.7/virtualenv.pyz?raw=true" > venv2/venv && python2.7 venv2/venv venv2 | ||
venv2/bin/python2 -m pip install -r ./requirements/test.txt | ||
venv2/bin/tox --direct -e "py${pyver//\.}-{std,coverage}" | ||
# we need the latest py2 compatible pytest which is not the latest available | ||
venv2/bin/python2 -m pip install pytest -r <(grep -v pytest ./requirements/base.txt) | ||
venv2/bin/pytest src | ||
build-py3: | ||
test-py3: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
- name: Cache tox environments | ||
uses: actions/cache@v4 | ||
with: | ||
path: .tox | ||
key: ${{ runner.os }}-${{ matrix.python }}-tox | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
uses: actions/setup-python@v5 | ||
with: {python-version: "${{ matrix.python-version }}", cache: pip, cache-dependency-path: 'requirements/*.txt'} | ||
- name: install tests dependencies | ||
run: pip install -r requirements/test.txt -r requirements/lint.txt -r requirements/tox.txt | ||
- name: run lint | ||
run: tox --current-env -e lint | ||
- name: run tests with coverage | ||
run: tox --current-env -e cov | ||
|
||
test-32bits: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Cache tox environments | ||
uses: actions/cache@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: install dependencies && test on py3 | ||
path: .dockertox | ||
key: ${{ runner.os }}-${{ matrix.python }}-dockertox | ||
- name: Test with pytest | ||
run: | | ||
set -ex | ||
python -m pip install --upgrade --use-pep517 pip | ||
pip install --use-pep517 -r requirements/test.txt | ||
pyver=$(python --version 2>&1 | awk '{print substr($2, 0, 4)}' | awk '{ sub(/[ \t]+$/, ""); print }') | ||
tox --direct -e "py${pyver//\.}-{std,coverage}" | ||
docker compose build --build-arg BASE=corpusops/croniter:32bits | ||
docker compose run --rm app tox --current-env -e test | ||
env: {COMPOSE_FILE: "docker-compose.yml:docker-compose-32bits.yml"} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: docker images builder | ||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
schedule: [{cron: '1 0 * * 6'}] | ||
env: | ||
DOCKER_BUILDKIT: "1" | ||
COMPOSE_DOCKER_CLI_BUILD: "1" | ||
BUILDKIT_PROGRESS: "plain" | ||
RELEASABLE_REPOS: "^kiorky/" | ||
RELEASABLE_BRANCHES: "^(refs/heads/)?(master|main|new-packaging)$" | ||
jobs: | ||
docker-build: | ||
runs-on: ubuntu-24.04 | ||
strategy: | ||
max-parallel: 5 | ||
fail-fast: false | ||
matrix: | ||
FLAVOR: [32bits, latest] | ||
env: {FLAVOR: "${{matrix.FLAVOR}}"} | ||
steps: | ||
- name: Set vars | ||
run: |- | ||
if ( echo "$GITHUB_REF" | egrep -q "${RELEASABLE_BRANCHES}" ) \ | ||
&& ( echo "$GITHUB_REPOSITORY" | egrep -q "${RELEASABLE_REPOS}" ) | ||
then releasable=true;else releasable=false;fi | ||
echo "releasable=$releasable" >> $GITHUB_OUTPUT | ||
id: v | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
- uses: actions/checkout@v4 | ||
- name: Build | ||
run: | | ||
set -ex | ||
export COMPOSE_FILE="docker-compose.yml:docker-compose-build.yml" | ||
if ( echo "${{matrix.FLAVOR}}" | grep -q 32 );then | ||
export COMPOSE_FILE="${COMPOSE_FILE}:docker-compose-32bits.yml:docker-compose-build-32bits.yml" | ||
fi | ||
echo ${COMPOSE_FILE} | ||
docker compose build | ||
- name: test | ||
run: set -ex && docker compose run --rm app tox --current-env | ||
- name: Release | ||
run: | | ||
if [ "x${{steps.v.outputs.releasable}}" = "xtrue" ];then | ||
set -ex && docker push corpusops/croniter:${{matrix.FLAVOR}} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/.tox | ||
/.*tox | ||
.env | ||
/dist | ||
\.*.cfg | ||
*.egg-info | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,57 @@ | ||
ARG RSYNC=corpusops/rsync | ||
ARG PY_VER=3.12.1 | ||
FROM python:${PY_VER} | ||
ARG BASE=${BASE:-corpusops/ubuntu-bare:24.04} | ||
FROM $BASE AS base | ||
ENV CFLAGS="-I/usr/include/python3.12/" | ||
ADD apt.txt ./ | ||
RUN <<EOF | ||
set -ex | ||
apt update | ||
sed -re "/^# dev deps/,$ d" /apt.txt|grep -vE "^\s*#"|tr "\n" " " > apt.runtime | ||
apt-get install -qq -y --no-install-recommends $( cat apt.runtime ) | ||
if ! ( python --version );then | ||
ln -s /usr/bin/python3 /usr/bin/python | ||
fi | ||
if ! ( pip --version );then | ||
wget https://bootstrap.pypa.io/get-pip.py | ||
chmod +x get-pip.py | ||
./get-pip.py --break-system-packages | ||
fi | ||
rm -rf /var/lib/apt/lists/* | ||
EOF | ||
FROM base AS final | ||
RUN <<EOF | ||
set -ex | ||
apt update && apt-get install -qq -y --no-install-recommends $( grep -Ev '^#' apt.txt ) | ||
( mkdir src || true ) && touch src/__init__.py | ||
EOF | ||
WORKDIR app | ||
ADD *.rst LICENSE MANIFEST.in *.txt *.cfg *.py *.ini ./ | ||
ADD ./src/ src/ | ||
ADD requirements/test.txt requirements/base.txt requirements/ | ||
RUN pip install --no-cache-dir --break-system-packages -r req*/test.txt | ||
ADD requirements/lint.txt requirements/ | ||
RUN pip install --no-cache-dir --break-system-packages -r req*/lint.txt | ||
ADD requirements/release.txt requirements/ | ||
RUN pip install --no-cache-dir --break-system-packages -r req*/release.txt | ||
ADD requirements/tox.txt requirements/ | ||
RUN pip install --no-cache-dir --break-system-packages -r req*/tox.txt | ||
RUN <<EOF | ||
set -ex | ||
apt remove -y python3-dev libpython3-dev cargo | ||
apt autoremove -y | ||
rm -rf /var/lib/apt/lists/* | ||
EOF | ||
|
||
# SQUASH Stage | ||
FROM $RSYNC AS squashed-rsync | ||
FROM base AS squashed-ancestor | ||
WORKDIR /app | ||
ADD *.rst LICENSE MANIFEST.in *.txt *.cfg *.py *.ini ./ | ||
ADD requirements/ ./requirements/ | ||
RUN mkdir src/ && touch src/__init__.py | ||
RUN pip install -r req*/base.txt | ||
RUN pip install -r req*/release.txt | ||
RUN pip install -r req*/test.txt | ||
ADD *.rst LICENSE MANIFEST.in *.txt *.sh *.cfg *.py *.ini ./ | ||
ARG ROOTFS="/BASE_ROOTFS_TO_COPY_THAT_WONT_COLLIDE_1234567890" | ||
ARG PATH="${ROOTFS}_rsync/bin:$PATH" | ||
RUN --mount=type=bind,from=final,target=$ROOTFS --mount=type=bind,from=squashed-rsync,target=${ROOTFS}_rsync \ | ||
rsync -Aaz --delete ${ROOTFS}/ / --exclude=/proc --exclude=/sys --exclude=/etc/resolv.conf --exclude=/etc/hosts --exclude=$ROOTFS* --exclude=dev/shm --exclude=dev/pts --exclude=dev/mqueue | ||
ADD *.rst LICENSE MANIFEST.in *.txt *.cfg *.py *.ini *sh ./ | ||
ADD src/ src/ | ||
ENTRYPOINT /app/docker-entry.sh | ||
ENTRYPOINT ["/app/docker-entry.sh"] | ||
CMD [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
python3 | ||
|
||
# dev deps | ||
python3-dev | ||
libpython3-dev | ||
cargo | ||
git-core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
services: | ||
app: | ||
image: "${CRONITER_IMAGE:-corpusops/croniter:32bits}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
services: | ||
app: | ||
build: | ||
cache_from: ["${CRONITER_IMAGE:-corpusops/croniter:32bits}"] | ||
args: | ||
BASE: "corpusops/debian-32:trixie" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
services: | ||
app: | ||
build: | ||
cache_from: ["${CRONITER_IMAGE:-corpusops/croniter:latest}"] | ||
context: . | ||
args: | ||
BUILDKIT_INLINE_CACHE: "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
version: "3.8" | ||
services: | ||
app: | ||
build: {context: .} | ||
image: "${CRONITER_IMAGE:-corpusops/croniter:latest}" | ||
volumes: | ||
- ./src:/app/src | ||
- ./setup.py:/app/setup.py | ||
- ./docker-entry.sh:/app/docker-entry.sh | ||
- ./.dockertox:/app/.tox | ||
- ./setup.cfg:/app/setup.cfg | ||
- ./setup.py:/app/setup.py | ||
- ./src:/app/src | ||
- ./tox.ini:/app/tox.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
#!/usr/bin/env bash | ||
[[ -n "${SDEBUG}" ]] && set -x | ||
cd /app | ||
python setup.py develop >/dev/null 2>&1 | ||
exec bash $@ | ||
# vim:set et sts=4 ts=4 tw=80: | ||
if [[ -z $@ ]];then | ||
exec bash | ||
else | ||
exec "$@" | ||
fi | ||
# vim:set et sts=4 ts=4 tw=0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
. venv/bin/activate | ||
. venv3/bin/activate | ||
fullrelease | ||
git push taichino && git push taichino --tags | ||
# vim:set et sts=4 ts=4 tw=80: |