Skip to content

Commit

Permalink
add Ubuntu 20.04 image
Browse files Browse the repository at this point in the history
  • Loading branch information
magicxor committed Apr 21, 2024
1 parent 8b50121 commit 2d93a13
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build_and_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,51 @@ env:
DOCKER_IMAGE: tor-simple

jobs:
ubuntu_20_04_repo:
name: tor from Ubuntu 20.04 repo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- id: get_build_info
run: |
docker build . --file=ubuntu_20.04_repo/VersionInfo.Dockerfile --progress=plain --no-cache -t tor-version-info
package_versions=$(docker run --rm tor-version-info)
echo "PACKAGE_VERSIONS=$package_versions" >> $GITHUB_OUTPUT
echo "BUILD_DATE=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_OUTPUT
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# https://github.com/docker/build-push-action
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
context: ubuntu_20.04_repo/.
no-cache: true
tags: |
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:${{ steps.get_build_info.outputs.PACKAGE_VERSIONS }}
platforms: |
linux/amd64
linux/arm/v7
linux/arm64/v8
build-args: |
VERSION=${{ steps.get_build_info.outputs.PACKAGE_VERSIONS }}
VCS_REF=${{ github.sha }}
BUILD_DATE=${{ steps.get_build_info.outputs.BUILD_DATE }}
BUILD_PLATFORM=${{ runner.os }}/${{ runner.arch }}
ubuntu_lts_repo:
name: tor from Ubuntu LTS repo
runs-on: ubuntu-latest
Expand Down
26 changes: 26 additions & 0 deletions ubuntu_20.04_repo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM ubuntu:20.04

ARG BUILD_PLATFORM
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION

RUN apt-get update && \
apt-get install -y curl tor tor-geoipdb obfs4proxy && \
# check versions
tor_version=$(apt-cache madison tor | awk '{print $3; exit}') && \
obfs4proxy_version=$(apt-cache madison obfs4proxy | awk '{print $3; exit}') && \
ubuntu_version=$(cat /etc/os-release | grep VERSION_ID | awk -F '"' '{print $2}') && \
actualVersion="ubuntu_lts_${ubuntu_version}_tor_${tor_version}_obfs4proxy_${obfs4proxy_version}" && \
if [ "$actualVersion" != "$VERSION" ]; then echo "Version mismatch: argument $VERSION, actual $actualVersion" && exit 1; fi && \
# cleanup
apt-get clean && \
rm -rf /var/lib/apt/lists/*

EXPOSE 9050

HEALTHCHECK --interval=60s --timeout=15s --start-period=20s \
CMD curl -x socks5h://127.0.0.1:9050 'https://check.torproject.org/api/ip' | grep -qm1 -E '"IsTor"\s*:\s*true'

VOLUME ["/var/lib/tor"]
CMD ["tor"]
9 changes: 9 additions & 0 deletions ubuntu_20.04_repo/VersionInfo.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ubuntu:20.04

RUN apt-get update && \
tor_version=$(apt-cache madison tor | awk '{print $3; exit}') && \
obfs4proxy_version=$(apt-cache madison obfs4proxy | awk '{print $3; exit}') && \
ubuntu_version=$(cat /etc/os-release | grep VERSION_ID | awk -F '"' '{print $2}') && \
echo "ubuntu_lts_${ubuntu_version}_tor_${tor_version}_obfs4proxy_${obfs4proxy_version}" > /version.txt

CMD cat /version.txt

0 comments on commit 2d93a13

Please sign in to comment.