Skip to content

Commit 4a6351c

Browse files
committed
trawl
1 parent 316713c commit 4a6351c

3 files changed

Lines changed: 203 additions & 0 deletions

File tree

‎.github/workflows/trawl.yaml‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: trawl
2+
3+
on:
4+
schedule:
5+
- cron: "0 10 * * *"
6+
push:
7+
branches:
8+
- "**"
9+
tags:
10+
- "v*.*.*"
11+
pull_request:
12+
branches:
13+
- "main"
14+
15+
jobs:
16+
trawl:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Set variables useful for later
20+
id: useful_vars
21+
run: |-
22+
echo "::set-output name=timestamp::$(date +%s)"
23+
echo "::set-output name=short_sha::${GITHUB_SHA::8}"
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
- name: Docker meta
27+
id: docker_meta
28+
uses: docker/metadata-action@v4
29+
with:
30+
images: ghcr.io/${{ github.repository }}/trawl
31+
tags: |
32+
type=schedule
33+
type=ref,event=branch
34+
type=ref,event=pr
35+
type=semver,pattern={{version}}
36+
type=semver,pattern={{major}}.{{minor}}
37+
type=semver,pattern={{major}}
38+
type=sha,prefix=,format=long,event=tag
39+
type=sha
40+
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
41+
type=raw,value=${{ github.ref_name }}-${{ steps.useful_vars.outputs.short_sha }}-${{ steps.useful_vars.outputs.timestamp }},enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
42+
- name: Set up QEMU
43+
uses: docker/setup-qemu-action@v2
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v2
46+
- name: Login to GHCR
47+
if: github.event_name != 'pull_request'
48+
uses: docker/login-action@v2
49+
with:
50+
registry: ghcr.io
51+
username: ${{ github.repository_owner }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
- name: Cache Docker layers
54+
uses: actions/cache@v3
55+
with:
56+
path: /tmp/.buildx-cache
57+
key: ${{ runner.os }}-trawl-buildx-${{ github.sha }}
58+
restore-keys: |
59+
${{ runner.os }}-trawl-buildx-
60+
- name: Build and push
61+
uses: docker/build-push-action@v4
62+
with:
63+
context: trawl
64+
push: ${{ github.event_name != 'pull_request' }}
65+
tags: ${{ steps.docker_meta.outputs.tags }}
66+
labels: ${{ steps.docker_meta.outputs.labels }}
67+
platforms: linux/amd64,linux/arm64
68+
cache-from: type=local,src=/tmp/.buildx-cache
69+
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max

‎trawl/Dockerfile‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
FROM debian:trixie-slim
2+
3+
RUN apt-get update && \
4+
apt-get install -y --no-install-recommends \
5+
wireguard-tools iproute2 iptables \
6+
rclone rsync lsyncd sshfs fuse3 unfs3 \
7+
openssh-client dropbear \
8+
socat netcat-openbsd curl wget jq \
9+
inotify-tools tcpdump mtr-tiny dnsutils \
10+
procps strace tmux file less zstd && \
11+
rm -rf /var/lib/apt/lists/* && \
12+
curl -fsSL https://github.com/aptible/supercronic/releases/download/v0.2.33/supercronic-linux-amd64 \
13+
-o /usr/local/bin/supercronic && \
14+
chmod +x /usr/local/bin/supercronic && \
15+
mkdir -p /etc/wireguard /data
16+
17+
VOLUME ["/data", "/etc/wireguard"]
18+
EXPOSE 51820/udp
19+
20+
RUN cat > /entrypoint.sh << 'SCRIPT'
21+
#!/bin/bash
22+
set -e
23+
24+
cleanup() {
25+
kill $(jobs -p) 2>/dev/null || true
26+
for conf in /etc/wireguard/wg*.conf; do
27+
[ -f "$conf" ] && wg-quick down "$(basename "${conf%.conf}")" 2>/dev/null || true
28+
done
29+
exit 0
30+
}
31+
trap cleanup SIGTERM SIGINT
32+
33+
# generate default wg0 only if no configs exist
34+
if ! ls /etc/wireguard/wg*.conf 2>/dev/null | grep -q .; then
35+
[ -f /etc/wireguard/privatekey ] || {
36+
wg genkey | tee /etc/wireguard/privatekey | wg pubkey > /etc/wireguard/publickey
37+
chmod 600 /etc/wireguard/privatekey
38+
echo "[INFO] pubkey: $(cat /etc/wireguard/publickey)"
39+
}
40+
cat > /etc/wireguard/wg0.conf << EOF
41+
[Interface]
42+
PrivateKey = $(cat /etc/wireguard/privatekey)
43+
Address = ${WG_IP:-192.168.192.2}/32
44+
ListenPort = 51820
45+
46+
[Peer]
47+
PublicKey = ${WG_CLIENT_PUBKEY:-CHANGEME}
48+
AllowedIPs = ${WG_CLIENT_IP:-192.168.192.1}/32
49+
EOF
50+
chmod 600 /etc/wireguard/wg0.conf
51+
fi
52+
53+
# bring up all WG interfaces
54+
for conf in /etc/wireguard/wg*.conf; do
55+
[ -f "$conf" ] && wg-quick up "$(basename "${conf%.conf}")" && \
56+
echo "[INFO] up: $(basename "${conf%.conf}")"
57+
done
58+
59+
exec ${CMD:-sleep infinity}
60+
SCRIPT
61+
62+
RUN chmod +x /entrypoint.sh
63+
CMD ["/entrypoint.sh"]

‎webdav-wg/Dockerfile‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
FROM debian:trixie-slim
2+
3+
RUN apt-get update && \
4+
apt-get install -y --no-install-recommends \
5+
wireguard-tools \
6+
rclone \
7+
lsyncd \
8+
rsync \
9+
openssh-client \
10+
inotify-tools \
11+
iproute2 && \
12+
rm -rf /var/lib/apt/lists/* && \
13+
mkdir -p /etc/wireguard /data
14+
15+
VOLUME ["/data", "/etc/wireguard"]
16+
EXPOSE 51820/udp
17+
18+
RUN cat > /entrypoint.sh << 'EOF'
19+
#!/bin/bash
20+
set -e
21+
WG_IFACE="wg0"
22+
cleanup() {
23+
echo "[INFO] Shutting down..."
24+
kill $(jobs -p) 2>/dev/null || true
25+
wg-quick down "${WG_IFACE}" 2>/dev/null || true
26+
exit 0
27+
}
28+
trap cleanup SIGTERM SIGINT
29+
30+
if [ ! -f /etc/wireguard/privatekey ]; then
31+
wg genkey | tee /etc/wireguard/privatekey | wg pubkey > /etc/wireguard/publickey
32+
chmod 600 /etc/wireguard/privatekey
33+
wg genpsk > /etc/wireguard/psk
34+
chmod 600 /etc/wireguard/psk
35+
echo "[INFO] Generated WireGuard keys. Public key: $(cat /etc/wireguard/publickey)"
36+
fi
37+
38+
if [ ! -f /etc/wireguard/webdav-password ]; then
39+
tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 32 > /etc/wireguard/webdav-password
40+
chmod 600 /etc/wireguard/webdav-password
41+
echo "[INFO] Generated WebDAV password: $(cat /etc/wireguard/webdav-password)"
42+
fi
43+
44+
WG_CLIENT_PUBKEY="${WG_CLIENT_PUBKEY:-CHANGEME}"
45+
WG_IP="${WG_IP:-100.87.143.201}"
46+
WG_CLIENT_IP="${WG_CLIENT_IP:-100.87.143.1}"
47+
48+
cat > "/etc/wireguard/${WG_IFACE}.conf" << WGEOF
49+
[Interface]
50+
PrivateKey = $(cat /etc/wireguard/privatekey)
51+
Address = ${WG_IP}/32
52+
ListenPort = 51820
53+
54+
[Peer]
55+
PublicKey = ${WG_CLIENT_PUBKEY}
56+
PresharedKey = $(cat /etc/wireguard/psk)
57+
AllowedIPs = ${WG_CLIENT_IP}/32
58+
WGEOF
59+
chmod 600 "/etc/wireguard/${WG_IFACE}.conf"
60+
wg-quick up "${WG_IFACE}"
61+
echo "[INFO] WireGuard up: ${WG_IP}"
62+
63+
WEBDAV_PASSWORD=$(cat /etc/wireguard/webdav-password)
64+
echo "[INFO] WebDAV credentials: root / ${WEBDAV_PASSWORD}"
65+
66+
DEFAULT_CMD="rclone serve webdav /data --addr ${WG_IP}:8080 --user root --pass ${WEBDAV_PASSWORD} --read-only ${RCLONE_ARGS}"
67+
exec ${CMD_OVERRIDE:-$DEFAULT_CMD}
68+
EOF
69+
70+
RUN chmod +x /entrypoint.sh
71+
CMD ["/entrypoint.sh"]

0 commit comments

Comments
 (0)