Skip to content

Commit 0c3894e

Browse files
authored
Merge pull request #6 from dosAnjosGustavo/main
Update Privoxy base image to v4.0.0
2 parents 43f0795 + c9f49ba commit 0c3894e

File tree

10 files changed

+232
-319
lines changed

10 files changed

+232
-319
lines changed

.github/workflows/docker_auto.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Automatic build on release and push to Docker Hub
22
on:
33
schedule:
4-
- cron: '0 0 * * SUN'
4+
- cron: "0 0 * * SUN"
55
push:
66
tags:
77
- "[0-9]+.[0-9]+.[0-9]+"
@@ -11,13 +11,13 @@ jobs:
1111
uses: ./.github/workflows/test.yml
1212
main:
1313
runs-on: ubuntu-latest
14-
needs:
14+
needs:
1515
- tests
1616
env:
1717
DOCKER_PLATFORMS: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386
1818
DOCKER_IMAGE: ghtardo/docker-privoxy-https
19-
LASTEST_VERSION: "3.0.34-2"
20-
PRIVOXY_VERSION: "3.0.34"
19+
LASTEST_VERSION: "4.0.0"
20+
PRIVOXY_VERSION: "4.0.0"
2121
steps:
2222
- name: Set up QEMU
2323
uses: docker/setup-qemu-action@v3
@@ -108,4 +108,4 @@ jobs:
108108
- name: Move cache
109109
run: |
110110
rm -rf /tmp/.buildx-cache
111-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
111+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

.github/workflows/test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ jobs:
1111
privoxy:
1212
strategy:
1313
matrix:
14-
privoxy_version: [3.0.34]
14+
privoxy_version: [4.0.0]
15+
python-version: [3.12]
1516
fail-fast: false
1617
runs-on: ubuntu-latest
1718

@@ -34,7 +35,7 @@ jobs:
3435
- name: Set up Python
3536
uses: actions/setup-python@v4
3637
with:
37-
python-version: "3.11"
38+
python-version: 3.12
3839

3940
- name: Install poetry
4041
uses: abatilo/actions-poetry@v2
@@ -47,4 +48,4 @@ jobs:
4748
poetry install
4849
4950
- name: Run pytest
50-
run: poetry run pytest --privoxy-version ${{ matrix.privoxy_version }} --no-cache -v
51+
run: poetry run pytest --privoxy-version ${{ matrix.privoxy_version }} --no-cache -v

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
__pycache__/
2-
tests/privoxy-ca-bundle.crt
2+
tests/privoxy-ca-bundle.crt
3+
/.pytest_cache
4+
/.venv

Dockerfile

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN set -ex; \
1414
mkdir /var/lib/privoxy/; \
1515
chown privoxy:privoxy /var/lib/privoxy/;
1616

17-
ARG PRIVOXY_VERSION=3.0.34
17+
ARG PRIVOXY_VERSION=4.0.0
1818

1919
# Build Privoxy
2020
RUN set -eux; \
@@ -26,7 +26,7 @@ RUN set -eux; \
2626
apk add --no-cache --virtual build-deps \
2727
libc-dev \
2828
zlib-dev \
29-
pcre-dev \
29+
pcre2-dev \
3030
openssl-dev \
3131
brotli-dev; \
3232
mkdir -p /usr/local/src/privoxy-${PRIVOXY_VERSION}-stable; \
@@ -40,15 +40,19 @@ RUN set -eux; \
4040
make -s install USER=privoxy GROUP=privoxy; \
4141
chown -R privoxy:privoxy /usr/local/etc/privoxy/; \
4242
rm -rf /var/lib/privoxy/privoxy-src.tar.gz /usr/local/src/privoxy-${PRIVOXY_VERSION}-stable; \
43-
apk del build-tools;
43+
apk del build-tools build-deps;
4444

4545
# Add system tools
46-
RUN apk add --no-cache --virtual sys-tools \
47-
openssl \
48-
python3 \
49-
supervisor \
50-
bash \
51-
sed;
46+
RUN set -eux; \
47+
apk add --no-cache --virtual runtime-deps \
48+
openssl \
49+
python3 \
50+
pcre2 \
51+
brotli \
52+
supervisor \
53+
bash \
54+
sed \
55+
net-tools;
5256

5357
# Enable Privoxy HTTPS inspection
5458
RUN set -ex; \
@@ -60,22 +64,38 @@ COPY data/rules/ /usr/local/etc/privoxy/privman-rules/
6064
COPY data/supervisord.conf /usr/local/etc/privoxy/
6165
COPY data/config /usr/local/etc/privoxy/
6266
COPY data/privoxy-blocklist.conf /var/lib/privoxy/
63-
COPY bin/privman.py /var/lib/privoxy/
64-
COPY bin/privoxy-blocklist.sh /var/lib/privoxy/
67+
RUN set -eux; \
68+
sed -i 's/\r$//' /var/lib/privoxy/privoxy-blocklist.conf
69+
COPY bin/privman.py /var/lib/privoxy/privman.py
70+
COPY bin/privoxy-blocklist.sh /var/lib/privoxy/privoxy-blocklist.sh
71+
RUN set -eux; \
72+
# Remove CRLF (dos2unix) and ensure LF-only
73+
sed -i 's/\r$//' /var/lib/privoxy/privoxy-blocklist.sh; \
74+
# Make executable
75+
chmod +x /var/lib/privoxy/privoxy-blocklist.sh; \
76+
# (Re)create the symlink
77+
ln -sf /var/lib/privoxy/privoxy-blocklist.sh /usr/local/bin/privoxy-blocklist
6578
COPY docker-entrypoint.sh /usr/local/bin/
79+
RUN sed -i 's/\r$//' /usr/local/bin/docker-entrypoint.sh \
80+
&& chmod +x /usr/local/bin/docker-entrypoint.sh
6681

6782
# Set the correct permissions
6883
RUN set -ex; \
84+
sed -i 's/\r$//' /var/lib/privoxy/privman.py /var/lib/privoxy/privoxy-blocklist.sh; \
85+
head -1 /var/lib/privoxy/privman.py | grep -q '^#!' || \
86+
sed -i '1i #!/usr/bin/env python3' /var/lib/privoxy/privman.py; \
6987
mkdir -p /usr/local/etc/privoxy/CA /usr/local/etc/privoxy/certs /usr/local/etc/privoxy/privman-rules; \
7088
chown -R privoxy:privoxy /usr/local/etc/privoxy/config /usr/local/etc/privoxy/CA /usr/local/etc/privoxy/certs /usr/local/etc/privoxy/privman-rules /var/lib/privoxy/privoxy-blocklist.conf; \
71-
chmod a+x /var/lib/privoxy/privman.py /var/lib/privoxy/privoxy-blocklist.sh /usr/local/bin/docker-entrypoint.sh; \
72-
ln -s /var/lib/privoxy/privman.py /usr/local/bin/privman; \
73-
ln -s /var/lib/privoxy/privoxy-blocklist.sh /usr/local/bin/privoxy-blocklist;
89+
chmod +x /var/lib/privoxy/privman.py; \
90+
ln -sf /var/lib/privoxy/privman.py /usr/local/bin/privman; \
91+
ln -sf /var/lib/privoxy/privoxy-blocklist.sh /usr/local/bin/privoxy-blocklist;
7492

7593
ENV ADBLOCK_URLS="" \
7694
ADBLOCK_FILTERS=""
7795

78-
ENTRYPOINT ["docker-entrypoint.sh"]
96+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
97+
98+
RUN cp -a /usr/local/etc/privoxy /opt/privoxy-default
7999

80100
VOLUME /usr/local/etc/privoxy
81101
EXPOSE 8118/tcp

bin/privman.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ def generate_crt_bundle(subj, forced=False):
3636
ca_key_file = os.path.join(BASEDIR_CA, 'cakey.pem')
3737
if not os.path.isfile(ca_bundle_file) or forced:
3838
os.system(f"openssl ecparam -out {ca_key_file} -name secp384r1 -genkey")
39-
os.system(f'openssl req -new -x509 -key {ca_key_file} -sha384 -days 3650 -out {ca_bundle_file} -extensions v3_ca -subj "{subj}"')
39+
os.system(
40+
f'openssl req -new -x509 '
41+
f'-key {ca_key_file} -sha384 -days 3650 '
42+
f'-out {ca_bundle_file} '
43+
f'-subj "{subj}" '
44+
f'-addext "basicConstraints=critical,CA:TRUE" '
45+
f'-addext "keyUsage=critical,keyCertSign,cRLSign"'
46+
)
4047
print_log("CRT Bundle", f"Generated successfully in '{ca_bundle_file}'")
4148
else:
4249
print_log("CRT Bundle", "Nothing to do. The file already exists.")

data/config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Sample Configuration File for Privoxy 3.0.34
1+
# Sample Configuration File for Privoxy 4.0.0
22
#
33
# Copyright (C) 2001-2023 Privoxy Developers https://www.privoxy.org/
44
#
@@ -791,7 +791,7 @@ logfile logfile
791791
#
792792
# listen-address [::1]:8118
793793
#
794-
listen-address :8118
794+
listen-address 0.0.0.0:8118
795795
#
796796
# 4.2. toggle
797797
# ============

docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
#!/bin/sh
22
set -e
33
privman --init
4+
5+
6+
if [ ! -e /usr/local/etc/privoxy/config ] || [ -z "$(ls -A /usr/local/etc/privoxy)" ]; then
7+
echo "[entrypoint] void config, populating defaults..."
8+
cp -a /opt/privoxy-default/* /usr/local/etc/privoxy/
9+
fi
10+
411
exec "$@"

0 commit comments

Comments
 (0)