Compare commits
1 Commits
master
..
4c2d87e996
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c2d87e996 |
@@ -1,49 +0,0 @@
|
||||
name: Nightly Rebuild
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
jobs:
|
||||
hadolint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: hadolint/hadolint-action@2332a7b74a6de0dda2e2221d575162eba76ba5e5 # v3.3.0
|
||||
continue-on-error: true
|
||||
with:
|
||||
dockerfile: Dockerfile
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
|
||||
- run: docker build -t ci-image:${{ github.sha }} .
|
||||
- run: bash tests/test.sh ci-image:${{ github.sha }}
|
||||
build-push:
|
||||
needs: [test]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
|
||||
- uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- id: get-latest-tag
|
||||
run: |
|
||||
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
||||
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||
- id: meta
|
||||
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6
|
||||
with:
|
||||
images: jcabillot/offlineimap
|
||||
tags: |
|
||||
type=raw,value=${{ steps.get-latest-tag.outputs.tag }}-latest,enable=${{ steps.get-latest-tag.outputs.tag != '' }}
|
||||
- uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
pull: true
|
||||
@@ -0,0 +1,65 @@
|
||||
name: Docker Build and Push
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master, main]
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: '30 3 * * 3'
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
|
||||
- uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf
|
||||
with:
|
||||
dockerfile: Dockerfile
|
||||
failure-threshold: error
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: lint
|
||||
steps:
|
||||
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
|
||||
- name: Build image
|
||||
run: docker build -t ci-image:${{ github.sha }} .
|
||||
- name: Save image
|
||||
run: docker save ci-image:${{ github.sha }} -o image.tar
|
||||
- uses: ChristopherHX/gitea-upload-artifact@62ac910c5d3dfa85c7cb2df15afe2e342b2407c2
|
||||
with:
|
||||
name: docker-image
|
||||
path: image.tar
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
|
||||
- uses: ChristopherHX/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7
|
||||
with:
|
||||
name: docker-image
|
||||
- name: Load image
|
||||
run: docker load < image.tar
|
||||
- name: Run tests
|
||||
run: bash tests/test.sh ci-image:${{ github.sha }}
|
||||
|
||||
push:
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
if: github.event_name != 'pull_request'
|
||||
steps:
|
||||
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
|
||||
- uses: ChristopherHX/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7
|
||||
with:
|
||||
name: docker-image
|
||||
- name: Load image
|
||||
run: docker load < image.tar
|
||||
- uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Tag and push
|
||||
run: |
|
||||
docker tag ci-image:${{ github.sha }} jcabillot/offlineimap:latest
|
||||
docker push jcabillot/offlineimap:latest
|
||||
@@ -1,44 +0,0 @@
|
||||
name: Main Release
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
jobs:
|
||||
hadolint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: hadolint/hadolint-action@2332a7b74a6de0dda2e2221d575162eba76ba5e5 # v3.3.0
|
||||
continue-on-error: true
|
||||
with:
|
||||
dockerfile: Dockerfile
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
|
||||
- run: docker build -t ci-image:${{ github.sha }} .
|
||||
- run: bash tests/test.sh ci-image:${{ github.sha }}
|
||||
build:
|
||||
needs: [test]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
|
||||
- run: docker build -t jcabillot/offlineimap:${{ github.sha }} .
|
||||
tag:
|
||||
needs: [build]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Configure git auth
|
||||
run: |
|
||||
git remote set-url origin "https://x-access-token:${{ secrets.SA_TOKEN_ACTION_PUSH_TAGS }}@scm.cabillot.eu/perso/offlineimap.git"
|
||||
- uses: anothrNick/github-tag-action@4ed44965e0db8dab2b466a16da04aec3cc312fd8 # v1.75.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.SA_TOKEN_ACTION_PUSH_TAGS }}
|
||||
DEFAULT_BUMP: patch
|
||||
RELEASE_BRANCHES: master
|
||||
WITH_V: true
|
||||
GIT_API_TAGGING: false
|
||||
@@ -1,20 +0,0 @@
|
||||
name: PR Checks
|
||||
on:
|
||||
pull_request:
|
||||
branches: [master]
|
||||
jobs:
|
||||
hadolint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: hadolint/hadolint-action@2332a7b74a6de0dda2e2221d575162eba76ba5e5 # v3.3.0
|
||||
continue-on-error: true
|
||||
with:
|
||||
dockerfile: Dockerfile
|
||||
build-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
|
||||
- run: docker build -t ci-image:${{ github.sha }} .
|
||||
- run: bash tests/test.sh ci-image:${{ github.sha }}
|
||||
@@ -1,44 +0,0 @@
|
||||
name: Tag Release
|
||||
on:
|
||||
push:
|
||||
tags: ['*']
|
||||
jobs:
|
||||
hadolint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: hadolint/hadolint-action@2332a7b74a6de0dda2e2221d575162eba76ba5e5 # v3.3.0
|
||||
continue-on-error: true
|
||||
with:
|
||||
dockerfile: Dockerfile
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
|
||||
- run: docker build -t ci-image:${{ github.sha }} .
|
||||
- run: bash tests/test.sh ci-image:${{ github.sha }}
|
||||
build-push:
|
||||
needs: [test]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
|
||||
- uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- id: meta
|
||||
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6
|
||||
with:
|
||||
images: jcabillot/offlineimap
|
||||
tags: |
|
||||
type=ref,event=tag
|
||||
type=ref,event=tag,suffix=-latest
|
||||
- uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
pull: true
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
image: docker:latest
|
||||
image: "docker:latest"
|
||||
|
||||
services:
|
||||
- "docker:dind"
|
||||
|
||||
+12
-6
@@ -5,17 +5,23 @@ COPY entrypoint.sh /entrypoint.sh
|
||||
COPY patch.py /tmp/patch.py
|
||||
|
||||
# hadolint ignore=DL3018
|
||||
RUN apk add --no-cache offlineimap openssl tini && \
|
||||
RUN apk add --no-cache offlineimap openssl && \
|
||||
adduser -D offlineimap && \
|
||||
# Apply post-install patches:
|
||||
# - UnicodeEncodeError fallback for defective messages (Maildir + IMAP)
|
||||
# - SSL SECLEVEL=1 in imaplib2 to allow connecting to servers with weak DH keys
|
||||
# (OpenSSL 3.x defaults to SECLEVEL=2)
|
||||
# Force SECLEVEL=1 in imaplib2 to allow connecting to servers with weak DH keys (DH_KEY_TOO_SMALL)
|
||||
# This is required because OpenSSL 3.x in Alpine 3.23 defaults to SECLEVEL=2
|
||||
sed -i 's/ctx = ssl.SSLContext(ssl_version)/ctx = ssl.SSLContext(ssl_version)\n ctx.set_ciphers("DEFAULT:@SECLEVEL=1")/' /usr/lib/python3.*/site-packages/imaplib2/imaplib2.py && \
|
||||
# Patch offlineimap email generator bug for defective messages
|
||||
python3 /tmp/patch.py && rm /tmp/patch.py
|
||||
|
||||
COPY --chown=offlineimap offlineimaprc.*.tmpl /home/offlineimap/
|
||||
|
||||
# Add Tini
|
||||
ENV "TINI_VERSION" "v0.16.1"
|
||||
#ADD "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini" "/tini"
|
||||
#RUN chmod +x "/tini"
|
||||
#ENTRYPOINT ["/tini", "--"]
|
||||
|
||||
USER "offlineimap"
|
||||
|
||||
ENTRYPOINT ["/sbin/tini", "--"]
|
||||
#ENTRYPOINT [ "/entrypoint.sh" ]
|
||||
CMD [ "/entrypoint.sh" ]
|
||||
@@ -1,52 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Post-install patches for offlineimap on Alpine.
|
||||
|
||||
Run as root in the Docker build (RUN python3 /tmp/patch.py).
|
||||
Fixes two upstream issues that persist in offlineimap 8.0.0:
|
||||
|
||||
1. UnicodeEncodeError when writing messages with non-ASCII bytes
|
||||
(Maildir.save thread + IMAP header generation).
|
||||
2. SSL SECLEVEL=2 in OpenSSL 3.x prevents connecting to servers with
|
||||
weak DH keys (DH_KEY_TOO_SMALL). Force SECLEVEL=1 in imaplib2.
|
||||
|
||||
Paths are resolved dynamically so the patch survives Python version
|
||||
bumps across Alpine releases (was hardcoded to python3.12).
|
||||
"""
|
||||
|
||||
import glob
|
||||
import sys
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# 1. Maildir.py — wrap fd.write(msg.as_bytes(...)) in a try/except
|
||||
# that falls back to UTF-8 encoded as_string on UnicodeEncodeError
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
maildir_path = glob.glob(
|
||||
"/usr/lib/python%d.%d/site-packages/offlineimap/folder/Maildir.py"
|
||||
% (sys.version_info.major, sys.version_info.minor)
|
||||
)[0]
|
||||
import sys, os
|
||||
|
||||
maildir_path = "/usr/lib/python3.12/site-packages/offlineimap/folder/Maildir.py"
|
||||
with open(maildir_path, "r") as f:
|
||||
maildir = f.read()
|
||||
|
||||
maildir = maildir.replace(
|
||||
"fd.write(msg.as_bytes(policy=output_policy))",
|
||||
"try:\n fd.write(msg.as_bytes(policy=output_policy))\n except UnicodeEncodeError:\n fd.write(msg.as_string(policy=output_policy).encode('utf-8'))",
|
||||
"try:\n fd.write(msg.as_bytes(policy=output_policy))\n except UnicodeEncodeError:\n fd.write(msg.as_string(policy=output_policy).encode('utf-8'))"
|
||||
)
|
||||
|
||||
with open(maildir_path, "w") as f:
|
||||
f.write(maildir)
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# 2. IMAP.py — add a helper and replace msg.as_bytes(policy=...) calls
|
||||
# with the helper that falls back on UnicodeEncodeError
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
imap_path = glob.glob(
|
||||
"/usr/lib/python%d.%d/site-packages/offlineimap/folder/IMAP.py"
|
||||
% (sys.version_info.major, sys.version_info.minor)
|
||||
)[0]
|
||||
|
||||
imap_path = "/usr/lib/python3.12/site-packages/offlineimap/folder/IMAP.py"
|
||||
with open(imap_path, "r") as f:
|
||||
imap_py = f.read()
|
||||
|
||||
@@ -57,40 +21,6 @@ def get_msg_bytes(msg, policy):
|
||||
except UnicodeEncodeError:
|
||||
return msg.as_string(policy=policy).encode('utf-8')
|
||||
"""
|
||||
imap_py = imap_patch + imap_py.replace(
|
||||
"msg.as_bytes(policy=output_policy)", "get_msg_bytes(msg, output_policy)"
|
||||
)
|
||||
|
||||
imap_py = imap_patch + imap_py.replace("msg.as_bytes(policy=output_policy)", "get_msg_bytes(msg, output_policy)")
|
||||
with open(imap_path, "w") as f:
|
||||
f.write(imap_py)
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# 3. imaplib2.py — force SECLEVEL=1 to allow weak DH keys
|
||||
# (moved here from a sed one-liner in the Dockerfile)
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
imaplib2_paths = glob.glob(
|
||||
"/usr/lib/python%d.%d/site-packages/imaplib2/imaplib2.py"
|
||||
% (sys.version_info.major, sys.version_info.minor)
|
||||
)
|
||||
|
||||
if imaplib2_paths:
|
||||
imaplib2_path = imaplib2_paths[0]
|
||||
with open(imaplib2_path, "r") as f:
|
||||
imaplib2_py = f.read()
|
||||
|
||||
old = "ctx = ssl.SSLContext(ssl_version)"
|
||||
new = (
|
||||
'ctx = ssl.SSLContext(ssl_version)\n'
|
||||
' ctx.set_ciphers("DEFAULT:@SECLEVEL=1")'
|
||||
)
|
||||
|
||||
if old in imaplib2_py:
|
||||
imaplib2_py = imaplib2_py.replace(old, new)
|
||||
with open(imaplib2_path, "w") as f:
|
||||
f.write(imaplib2_py)
|
||||
print("Patched imaplib2 SECLEVEL=1")
|
||||
else:
|
||||
print("imaplib2 already patched or pattern not found — skipping")
|
||||
else:
|
||||
print("imaplib2 not found — skipping SECLEVEL patch")
|
||||
Reference in New Issue
Block a user