1
mirror of https://github.com/jakejarvis/docker-tor.git synced 2025-04-26 03:05:21 -04:00

initial commit 🎉

This commit is contained in:
Jake Jarvis 2022-12-29 11:35:34 -05:00
commit aa5b5c006a
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39
3 changed files with 107 additions and 0 deletions

57
.github/workflows/build-and-push.yml vendored Normal file
View File

@ -0,0 +1,57 @@
name: Build and push image
on:
workflow_dispatch:
push:
branches:
- 'main'
tags:
- '*'
pull_request:
branches:
- 'main'
permissions:
contents: read
# packages: write
jobs:
build-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# - uses: docker/login-action@v2
# if: github.event_name != 'pull_request'
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v4
id: meta
with:
images: |
jakejarvis/tor
# ghcr.io/jakejarvis/tor
flavor: |
latest=auto
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=pep440,pattern={{raw}}
type=pep440,pattern=v{{major}}.{{minor}}
type=ref,event=pr
- uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
builder: ${{ steps.buildx.outputs.name }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max

41
Dockerfile Normal file
View File

@ -0,0 +1,41 @@
FROM ubuntu:22.04
LABEL maintainer "Jake Jarvis <jake@jarv.is>"
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y \
ca-certificates \
apt-transport-https \
apt-utils \
lsb-release \
gnupg \
curl \
# Add torproject.org repository for stable Tor
&& curl -fsSL https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --dearmor -o /usr/share/keyrings/tor-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org $(lsb_release -cs) main \
deb-src [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/tor.list >/dev/null \
# Install Tor with GeoIP
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y \
tor \
tor-geoipdb \
obfs4proxy \
iputils-ping \
# Tidy up
&& apt-get purge --auto-remove -y \
apt-transport-https \
apt-utils \
lsb-release \
gnupg \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy entrypoint script
COPY ./entrypoint.sh /usr/local/bin/docker-entrypoint
USER debian-tor
ENTRYPOINT ["docker-entrypoint"]
CMD ["tor", "-f", "/etc/tor/torrc"]

9
entrypoint.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
set -o errexit
# fix permissions
find /var/lib/tor -type d -exec chmod -v 700 {} \;
find /var/lib/tor -type f -exec chmod -v 600 {} \;
chown -R debian-tor /var/lib/tor
exec "$@"