-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
95 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Build and push tor-node Docker images | ||
|
||
on: | ||
push: | ||
tags: | ||
- "tor-[0-9]+.[0-9]+.[0-9]+.[0-9]+-[0-9]+" | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ vars.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ vars.DOCKERHUB_USERNAME }}/tor-node | ||
tags: | | ||
type=match,pattern=tor-(\d+\.\d+\.\d+.\d+-\d+),group=1 | ||
type=match,pattern=tor-(\d+\.\d+\.\d+.\d+),group=1 | ||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: tor-node | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
GITHUB_SERVER_URL=${{ github.server_url }} | ||
GITHUB_REPOSITORY=${{ github.repository }} | ||
GITHUB_SHA=${{ github.sha }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
FROM debian:12-slim | ||
|
||
COPY entrypoint.sh / | ||
FROM debian:12-slim as base | ||
RUN set -eux \ | ||
\ | ||
&& apt-get -y update \ | ||
&& apt-get -y upgrade \ | ||
&& apt-get -y install tor \ | ||
&& apt-get -y clean \ | ||
&& rm -rf /var/lib/apt \ | ||
&& sed -i \ | ||
-e '0,/^#HiddenServicePort/{s/^#\(HiddenService\)/\1/}' \ | ||
-e '/^HiddenServicePort/{s/127\.0\.0\.1/p2pool/; s/80/3333/g}' \ | ||
/etc/tor/torrc \ | ||
&& rm -rf /var/lib/apt | ||
|
||
FROM base as builder | ||
COPY entrypoint.sh / | ||
RUN set -eux \ | ||
\ | ||
&& grep '^ExecStartPre' /lib/systemd/system/[email protected] \ | ||
| sed 's/^[^=]*=//' >> /entrypoint.sh \ | ||
&& grep '^ExecStart=' /lib/systemd/system/[email protected] \ | ||
|
@@ -20,4 +19,4 @@ RUN set -eux \ | |
|
||
VOLUME /var/lib/tor | ||
|
||
CMD /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [ $# -gt 1 ]; then | ||
echo 1>&2 "docker run gbenson/tor-node [[HOST:]PORT]" | ||
exit 1 | ||
fi | ||
|
||
unset host port | ||
if [ $# -eq 1 ]; then | ||
port=$(echo "$1" | sed 's/.*://') | ||
if [ "$port" != "$1" ]; then | ||
host=$(echo "$1" | sed "s/:$port\$//") | ||
fi | ||
fi | ||
echo "HOST=$host" | ||
echo "PORT=$port" | ||
|
||
if [ -n "$port" ]; then | ||
f=/etc/tor/torrc | ||
grep ^HiddenServicePort $f && exit 1 # crowbar | ||
sed -e '0,/^#HiddenServicePort/{s/^#\(HiddenService\)/\1/}' \ | ||
-e '/^HiddenServicePort/{s/80/@@PORT@@/g}' \ | ||
-i $f | ||
if [ -n "$host" ]; then | ||
sed -i "/^HiddenServicePort/{s/127\.0\.0\.1/@@HOST@@/}" $f | ||
fi | ||
sed -e "/^HiddenServicePort/{s/@@HOST@@/$host/; s/@@PORT@@/$port/g}" \ | ||
-i $f | ||
unset f | ||
fi | ||
|
||
unset host port | ||
|
||
chown debian-tor:debian-tor /var/lib/tor | ||
chmod 02700 /var/lib/tor |