[
  {
    "path": ".github/workflows/build.yml",
    "content": "name: build images\n\non:\n  push:\n    branches:\n      - master\n\njobs:\n  buildx:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v2\n      - uses: docker/login-action@v1\n        with:\n          username: ${{ secrets.DOCKER_USERNAME }}\n          password: ${{ secrets.DOCKER_PASSWORD }}\n      - id: build_args\n        run: |\n          echo '::set-output name=BUILD_DATE::$(date +'%Y-%m-%dT%H:%M:%S')'\n          echo '::set-output name=VERSION::$(head -1 VERSION)'\n      - name: Set up Docker Buildx\n        uses: crazy-max/ghaction-docker-buildx@v1\n        with:\n          buildx-version: latest\n          qemu-version: latest\n      - name: Run Buildx\n        run: |\n          DOCKER_IMAGE=osminogin/tor-simple\n          docker buildx create --use --name build --node build --driver-opt network=host\n          docker buildx build \\\n            --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \\\n            --output \"type=image,push=true\" \\\n            --tag ${DOCKER_IMAGE}:latest \\\n            --tag ${DOCKER_IMAGE}:${{ steps.build_args.outputs.VERSION }} \\\n            --build-arg VERSION=${{ steps.build_args.outputs.VERSION }} \\\n            --build-arg BUILD_DATE=${{ steps.build_args.outputs.BUILD_DATE }} \\\n            --build-arg VCS_REF=${GITHUB_SHA::8} \\\n            .\n      - name: Inspect Image\n        run: |\n          docker buildx imagetools inspect osminogin/tor-simple:latest\n"
  },
  {
    "path": ".github/workflows/updater.yml",
    "content": "name: Latest version\n\non:\n  schedule:\n    - cron:  \"30 2 * * *\"\n\njobs:\n\n  check:\n    runs-on: ubuntu-latest\n    steps:\n\n      - uses: actions/checkout@v2\n\n      - name: Get remote package data\n        uses: wei/curl@master\n        with:\n          args: --silent \"https://pkgs.alpinelinux.org/package/edge/community/x86_64/tor\" --output ./package_data.html\n\n      - name: Cut version from package data\n        run: |\n          remote_version=$(grep -A 3 -i version ./package_data.html | sed -E 's#.*>([0-9\\.]+)-r[0-9]+</a>#\\1#g' | tail -1 | sed 's/^[ \\t]*//;s/[ \\t]*$//')\n          echo \"##[set-output name=version;]$remote_version\"\n        id: package_version\n\n      - name: Check remote version with local\n        run: |\n          grep -q ${{ steps.package_version.outputs.version }} VERSION\n"
  },
  {
    "path": ".github/workflows/version.yml",
    "content": "name: latest version\n\non:\n  schedule:\n    - cron: '20 1 * * *'\n  push:\n    branches:\n      - master\n\njobs:\n\n  check:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v2\n\n      - name: Get remote package data\n        uses: wei/curl@master\n        with:\n          args: --silent \"https://pkgs.alpinelinux.org/package/edge/community/x86_64/tor\" --output package_data.html\n\n      - name: Check remote version with local\n        run: |\n          grep -A 3 -i version package_data.html | sed -E 's#.*>([^>-]+).*</strong></a>#\\1#g' | tail -1 | grep -q $(cat VERSION)\n"
  },
  {
    "path": ".gitignore",
    "content": ".idea/"
  },
  {
    "path": "Dockerfile",
    "content": "FROM alpine:edge\n\nARG TARGETPLATFORM\nARG BUILDPLATFORM\nARG BUILD_DATE\nARG VCS_REF\nARG VERSION\n\nLABEL maintainer=\"osintsev@gmail.com\" \\\n    org.label-schema.license=\"MIT\" \\\n    org.label-schema.build-date=$BUILD_DATE \\\n    org.label-schema.name=\"Tor network client (daemon)\" \\\n    org.label-schema.description=\"Tor network client (daemon) with simple usage\" \\\n    org.label-schema.url=\"https://www.torproject.org\" \\\n    org.label-schema.vcs-url=\"https://github.com/osminogin/docker-tor-simple\" \\\n    org.label-schema.vcs-ref=$VCS_REF \\\n    org.label-schema.usage=\"https://github.com/osminogin/docker-tor-simple#getting-started\" \\\n    org.label-schema.docker.cmd=\"docker run -d --rm --publish 127.0.0.1:9050:9050 --name tor osminogin/tor-simple\" \\\n    org.label-schema.schema-version=\"1.0\" \\\n    org.label-schema.version=$VERSION\n\nRUN apk add --no-cache curl tor && \\\n    sed \"1s/^/SocksPort 0.0.0.0:9050\\n/\" /etc/tor/torrc.sample > /etc/tor/torrc\n\nEXPOSE 9050\n\nHEALTHCHECK --interval=60s --timeout=15s --start-period=20s \\\n    CMD curl -x socks5h://127.0.0.1:9050 'https://check.torproject.org/api/ip' | grep -qm1 -E '\"IsTor\"\\s*:\\s*true'\n\nVOLUME [\"/var/lib/tor\"]\n\nUSER tor\n\nCMD [\"tor\"]\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2015-2023 Vladimir Osintsev <osintsev@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "Makefile",
    "content": "PROJECT_NAME ?= tor\nVERSION ?= $(strip $(shell cat VERSION))\nGIT_COMMIT = $(strip $(shell git rev-parse --short HEAD))\nDOCKER_IMAGE ?= osminogin/tor-simple\nDOCKER_TAG ?= latest\n\n# Build Docker image\nbuild: docker_build docker_tag output\n\n# Build and push Docker image\nrelease: docker_tag docker_push output\n\ndefault: build\n\ndocker_build:\n\t@docker build \\\n\t\t--compress \\\n\t\t--force-rm \\\n\t\t--build-arg BUILD_DATE=`date -u +\"%Y-%m-%dT%H:%M:%SZ\"` \\\n\t\t--build-arg VCS_REF=$(GIT_COMMIT) \\\n\t\t--build-arg VERSION=$(VERSION) \\\n\t\t--tag $(DOCKER_IMAGE):$(VERSION) .\n\nbuildx:\n\t# TODO: Copy logic from docker file\n\ndocker_tag:\n\tdocker tag $(DOCKER_IMAGE):$(VERSION) $(DOCKER_IMAGE):$(DOCKER_TAG)\n\ndocker_push:\n\tdocker push $(DOCKER_IMAGE):$(DOCKER_TAG)\n\tdocker push $(DOCKER_IMAGE):$(VERSION)\n\nrun:\n\t@echo 'Starting container $(DOCKER_IMAGE):$(DOCKER_TAG)'\n\t@docker run --publish 9050:9050 -i $(DOCKER_IMAGE):$(DOCKER_TAG)\n\noutput:\n\t@echo Docker Image: $(DOCKER_IMAGE):$(DOCKER_TAG)\n\n.PHONY: release output run docker_build docker_push default build buildx\n"
  },
  {
    "path": "README.md",
    "content": "# docker-tor-simple\n\n[![build images](https://github.com/osminogin/docker-tor-simple/workflows/build%20images/badge.svg)](https://github.com/osminogin/docker-tor-simple/actions?query=workflow%3A%22build+images%22) [![](https://images.microbadger.com/badges/version/osminogin/tor-simple.svg)](https://microbadger.com/images/osminogin/tor-simple) [![latest version](https://github.com/osminogin/docker-tor-simple/actions/workflows/version.yml/badge.svg)](https://github.com/osminogin/docker-tor-simple/actions?query=workflow%3A%22latest+version%22) [![](https://img.shields.io/docker/stars/osminogin/tor-simple.svg)](https://hub.docker.com/r/osminogin/tor-simple) [![](https://images.microbadger.com/badges/image/osminogin/tor-simple.svg)](https://microbadger.com/images/osminogin/tor-simple) [![License: MIT](https://img.shields.io/badge/license-MIT-black.svg)](https://github.com/osminogin/docker-tor-simple/blob/master/LICENSE)\n\n**Smallest minimal docker container for Tor network proxy daemon.**\n\nSuitable for relay, exit node or hidden service modes with SOCKSv5 proxy enabled. It works well as a single self-contained container or in cooperation with other containers (like `nginx`) for organizing complex hidden services on the Tor network.\n\nThe image is based on great Alpine Linux distribution so it is has extremely low size (about 8 MB).\n\nService uses latest available version of [Tor package](https://pkgs.alpinelinux.org/package/edge/community/x86_64/tor) from [Edge repo](https://wiki.alpinelinux.org/wiki/Edge).\n\n## Port\n\n* `9050` SOCKSv5 (without auth)\n\n## Volumes\n\n* `/var/lib/tor` data dir.\n\n\n## Getting started\n\n### Installation\n\nAutomated builds of the image are available on [Docker Hub](https://hub.docker.com/r/osminogin/tor-simple/) and is the recommended method of installation.\n\n```bash\ndocker pull osminogin/tor-simple\n```\n\nAlternatively you can build the image yourself.\n\n```bash\nexport PROJECT_NAME=tor-node   # docker image name\nmake build DOCKER_IMAGE=$PROJECT_NAME\n```\n\n\n### Quickstart\n\n```bash\nexport PROJECT_NAME=tor-local   # changing default name\nmake build DOCKER_IMAGE=$PROJECT_NAME\nmake run\n\n# or with docker-compose ...\ndocker-compose up\n\n# or altenativly run docker directly ...\ndocker run --publish 127.0.0.1:9050:9050 -i $PROJECT_NAME\n```\n\nAfter start Tor proxy available on `localhost:9050`\n\n**Warning! Don't bind SOCKSv5 port 9050 to public network addresses if you don't know exactly what you are doing (is much better bind to `localhost` as in the example above)**.\n\n\n## Advanced usage\n\nYou can copy original tor config from container, modify and mount them back inside. Changing the configuration file is required for running Tor as exit node, relay or bridge. For some operation modes you need to expose additional ports (9001, 9030, 9051).\n\n```bash\n# Copy config  from running container\ndocker cp tor:/etc/tor/torrc $HOME/torrc\n# ... modify torrc and run again\n\n# Start more complex example with updated config\ndocker run --rm --name tor \\\n  --publish 127.0.0.1:9050:9050 \\\n  --expose 9001 --publish 9001:9001 \\ # ORPort\n  --expose 9030 --publish 9030:9030 \\\n  --expose 9051 --publish 9051:9051 \\\n  --volume $HOME/torrc:/etc/tor/torrc:ro \\\n  osminogin/tor-simple\n```\n\n## Unit file for systemd\n\n#### tor.service\n\n```ini\n[Unit]\nDescription=Tor service\nWants=network-online.target\nRequires=docker.service\nAfter=docker.service network.target network-online.target\n\n[Service]\nTimeoutStartSec=0\nRestart=always\nRestartSec=10s\nExecStartPre=/usr/bin/docker pull osminogin/tor-simple\nExecStart=/usr/bin/docker run --rm --name tor -p 127.0.0.1:9050:9050 osminogin/tor-simple\nExecStop=/usr/bin/docker stop tor\n\n[Install]\nWantedBy=multi-user.target\n```\n\n\n## Examples\n\nExample webserver deployment config with microservice architecture to setup Tor hidden service.\n\n\n#### docker-compose.yml\n\n```yaml\nversion: '3.7'\nservices:\n\n  tor-node:\n    image: osminogin/tor-simple\n    restart: always\n    depends_on:\n      - nginx\n\n  nginx:\n    image: nginx\n    restart: always\n```\n\n## License\n\nSee [LICENSE](https://github.com/osminogin/docker-tor-simple/blob/master/LICENSE)\n"
  },
  {
    "path": "VERSION",
    "content": "0.4.9.5\n"
  },
  {
    "path": "contrib/tor.service",
    "content": "[Unit]\nDescription=Tor daemon\nWants=network-online.target\nRequires=docker.service\nAfter=docker.service network.target network-online.target\n\n[Service]\nTimeoutStartSec=0\nRestart=always\nRestartSec=15s\nExecStartPre=/usr/bin/docker pull osminogin/tor-simple\nExecStart=/usr/bin/docker run --rm --name tor -p 127.0.0.1:9050:9050 osminogin/tor-simple\nExecStop=/usr/bin/docker stop tor\n\n[Install]\nWantedBy=multi-user.target\n"
  },
  {
    "path": "docker-compose.yml",
    "content": "version: '3'\n\nservices:\n  tor:\n    build: .\n    restart: always\n    ports:\n      - 127.0.0.1:9050:9050\n    volumes:\n      - tor-data:/var/lib/tor\n\nvolumes:\n  tor-data:\n    driver: local\n"
  },
  {
    "path": "hooks/build",
    "content": "#!/bin/sh\n\nmake build && make release\n"
  }
]