Skip to content

Commit

Permalink
new jobs: ubuntu_lts_repo and ubuntu_rolling_sources
Browse files Browse the repository at this point in the history
  • Loading branch information
magicxor committed Mar 23, 2024
1 parent b285461 commit c42db96
Show file tree
Hide file tree
Showing 7 changed files with 240 additions and 23 deletions.
55 changes: 50 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build images
name: Build and push images

on:
push:
Expand All @@ -9,13 +9,13 @@ on:
# see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
- cron: '0 0 1 * *'


env:
DOCKER_REGISTRY: magicxor
DOCKER_IMAGE: tor-simple

jobs:
buildx:
ubuntu_lts_repo:
name: TOR from Ubuntu LTS repo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -27,7 +27,7 @@ jobs:

- id: get_build_info
run: |
docker build . --file=VersionInfo.Dockerfile --progress=plain --no-cache -t tor-version-info
docker build . --file=ubuntu_lts_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
Expand All @@ -45,7 +45,7 @@ jobs:
uses: docker/build-push-action@v5
with:
push: true
context: .
context: ubuntu_lts_repo/.
no-cache: true
tags: |
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:latest
Expand All @@ -59,3 +59,48 @@ jobs:
VCS_REF=${{ github.sha }}
BUILD_DATE=${{ steps.get_build_info.outputs.BUILD_DATE }}
BUILD_PLATFORM=${{ runner.os }}/${{ runner.arch }}
ubuntu_rolling_sources:
name: TOR from sources
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_rolling_sources/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_rolling_sources/.
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 }}
62 changes: 62 additions & 0 deletions .github/workflows/build_and_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build and push images

on:
push:
branches:
- master
schedule:
# every 1st day of every month
# see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
- cron: '0 0 1 * *'


env:
DOCKER_REGISTRY: magicxor
DOCKER_IMAGE: tor-simple

jobs:
ubuntu_lts_repo:
name: Ubuntu LTS repo tor version
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_lts_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_lts_repo/.
no-cache: true
tags: |
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:latest
${{ 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 }}
17 changes: 0 additions & 17 deletions Dockerfile

This file was deleted.

22 changes: 22 additions & 0 deletions ubuntu_lts_repo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ubuntu:latest

ARG BUILD_PLATFORM
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION

RUN apt-get update && \
apt-get install -y curl tor tor-geoipdb obfs4proxy && \
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: expected $VERSION, got $actualVersion" && exit 1; fi

EXPOSE 9050

HEALTHCHECK --interval=60s --timeout=15s --start-period=20s \
CMD curl -s --socks5 127.0.0.1:9050 'https://check.torproject.org/' | grep -qm1 Congratulations

VOLUME ["/var/lib/tor"]
CMD ["tor"]
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ 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_version}_${tor_version}_${obfs4proxy_version}" > /version.txt
echo "ubuntu_lts_${ubuntu_version}_tor_${tor_version}_obfs4proxy_${obfs4proxy_version}" > /version.txt

CMD cat /version.txt
74 changes: 74 additions & 0 deletions ubuntu_rolling_sources/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
FROM ubuntu:rolling

ARG BUILD_PLATFORM
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION

# see https://git.torproject.org/

RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y golang git build-essential automake libevent-dev libssl-dev zlib1g-dev && \
echo go version && \
mkdir -p ~/git && \
# build tor
cd ~/git && \
git clone https://gitlab.torproject.org/tpo/core/tor.git && \
cd ~/git/tor && \
git fetch --tags && \
torLatestTag=$(git describe --tags "$(git rev-list --tags --max-count=1)") && \
git checkout $torLatestTag && \
./autogen.sh && \
./configure --disable-asciidoc && \
make && \
make install && \
# build webtunnel
cd ~/git && \
git clone https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/webtunnel.git && \
cd ~/git/webtunnel/main/client && \
webtunnelCommitHash=$(git rev-parse --short HEAD) && \
go get && \
go build && \
cp client /usr/bin/webtunnel && \
chmod +x /usr/bin/webtunnel && \
# build snowflake
cd ~/git && \
git clone https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git && \
cd ~/git/snowflake/client && \
snowflakeCommitHash=$(git rev-parse --short HEAD) && \
go get && \
go build && \
cp client /usr/bin/snowflake && \
chmod +x /usr/bin/snowflake && \
# build obfs4proxy
cd ~/git && \
git clone https://gitlab.com/yawning/obfs4.git && \
cd ~/git/obfs4 && \
git fetch --tags && \
obfs4LatestTag=$(git describe --tags "$(git rev-list --tags --max-count=1)") && \
git checkout $obfs4LatestTag && \
cd ~/git/obfs4/obfs4proxy && \
go get && \
go build && \
cp obfs4proxy /usr/bin/obfs4proxy && \
chmod +x /usr/bin/obfs4proxy && \
# cleanup
apt-get remove -y golang git build-essential automake libevent-dev libssl-dev zlib1g-dev && \
apt-get autoremove -y && \
apt-get install -y libc6 libcap2 libevent-dev liblzma5 libseccomp2 libssl3 libsystemd0 libzstd1 zlib1g adduser lsb-base && \
rm -rf ~/git && \
# check versions
ubuntu_version=$(cat /etc/os-release | grep VERSION_ID | awk -F '"' '{print $2}') && \
torLatestTag=$(echo $torLatestTag | sed 's/.*-//') && \
obfs4LatestTag=$(echo $obfs4LatestTag | sed 's/.*-//') && \
actualVersion="ubuntu_rolling_${ubuntu_version}_tor_${torLatestTag}_obfs4proxy_${obfs4LatestTag}_webtunnel_${webtunnelCommitHash}_snowflake_${snowflakeCommitHash}" && \
if [ "$actualVersion" != "$VERSION" ]; then echo "Version mismatch: expected $VERSION, got $actualVersion" && exit 1; fi

EXPOSE 9050

HEALTHCHECK --interval=60s --timeout=15s --start-period=20s \
CMD curl -s --socks5 127.0.0.1:9050 'https://check.torproject.org/' | grep -qm1 Congratulations

VOLUME ["/var/lib/tor"]
CMD ["tor"]
31 changes: 31 additions & 0 deletions ubuntu_rolling_sources/VersionInfo.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM ubuntu:rolling

# see https://git.torproject.org/

RUN apt-get update && \
apt-get install -y git && \
mkdir -p ~/git && \
cd ~/git && \
git clone https://gitlab.torproject.org/tpo/core/tor.git && \
cd ~/git/tor && \
git fetch --tags && \
torLatestTag=$(git describe --tags "$(git rev-list --tags --max-count=1)") && \
cd ~/git && \
git clone https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/webtunnel.git && \
cd ~/git/webtunnel/main/client && \
webtunnelCommitHash=$(git rev-parse --short HEAD) && \
cd ~/git && \
git clone https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git && \
cd ~/git/snowflake/ && \
snowflakeCommitHash=$(git rev-parse --short HEAD) && \
cd ~/git && \
git clone https://gitlab.com/yawning/obfs4.git && \
cd ~/git/obfs4 && \
git fetch --tags && \
obfs4LatestTag=$(git describe --tags "$(git rev-list --tags --max-count=1)") && \
ubuntu_version=$(cat /etc/os-release | grep VERSION_ID | awk -F '"' '{print $2}') && \
torLatestTag=$(echo $torLatestTag | sed 's/.*-//') && \
obfs4LatestTag=$(echo $obfs4LatestTag | sed 's/.*-//') && \
echo "ubuntu_rolling_${ubuntu_version}_tor_${torLatestTag}_obfs4proxy_${obfs4LatestTag}_webtunnel_${webtunnelCommitHash}_snowflake_${snowflakeCommitHash}" > /version.txt

CMD cat /version.txt

0 comments on commit c42db96

Please sign in to comment.