Skip to content

Commit d37db6c

Browse files
committed
trawl
1 parent 316713c commit d37db6c

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

.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"]

0 commit comments

Comments
 (0)