Skip to content

Commit 6aac762

Browse files
committed
trawl
1 parent 316713c commit 6aac762

2 files changed

Lines changed: 129 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: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 \
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+
mkdir -p /etc/wireguard /data
13+
14+
VOLUME ["/data", "/etc/wireguard"]
15+
EXPOSE 51820/udp
16+
17+
RUN cat > /entrypoint.sh << 'SCRIPT'
18+
#!/bin/bash
19+
set -e
20+
21+
cleanup() {
22+
kill $(jobs -p) 2>/dev/null || true
23+
for conf in /etc/wireguard/wg*.conf; do
24+
[ -f "$conf" ] && wg-quick down "$(basename "${conf%.conf}")" 2>/dev/null || true
25+
done
26+
exit 0
27+
}
28+
trap cleanup SIGTERM SIGINT
29+
30+
# generate default wg0 only if no configs exist
31+
if ! ls /etc/wireguard/wg*.conf 2>/dev/null | grep -q .; then
32+
[ -f /etc/wireguard/privatekey ] || {
33+
wg genkey | tee /etc/wireguard/privatekey | wg pubkey > /etc/wireguard/publickey
34+
chmod 600 /etc/wireguard/privatekey
35+
echo "[INFO] pubkey: $(cat /etc/wireguard/publickey)"
36+
}
37+
cat > /etc/wireguard/wg0.conf << EOF
38+
[Interface]
39+
PrivateKey = $(cat /etc/wireguard/privatekey)
40+
Address = ${WG_IP:-192.168.192.2}/32
41+
ListenPort = 51820
42+
43+
[Peer]
44+
PublicKey = ${WG_CLIENT_PUBKEY:-CHANGEME}
45+
AllowedIPs = ${WG_CLIENT_IP:-192.168.192.1}/32
46+
EOF
47+
chmod 600 /etc/wireguard/wg0.conf
48+
fi
49+
50+
# bring up all WG interfaces
51+
for conf in /etc/wireguard/wg*.conf; do
52+
[ -f "$conf" ] && wg-quick up "$(basename "${conf%.conf}")" && \
53+
echo "[INFO] up: $(basename "${conf%.conf}")"
54+
done
55+
56+
exec ${CMD:-sleep infinity}
57+
SCRIPT
58+
59+
RUN chmod +x /entrypoint.sh
60+
CMD ["/entrypoint.sh"]

0 commit comments

Comments
 (0)