diff --git a/.gitea/workflows/builder.yaml b/.gitea/workflows/builder.yaml index 30c4dd1..a13e70e 100644 --- a/.gitea/workflows/builder.yaml +++ b/.gitea/workflows/builder.yaml @@ -30,14 +30,27 @@ jobs: uses: docker/build-push-action@v6 with: context: ./apps/aquatic - file: ./apps/aquatic/docker/aquatic_udp.Dockerfile + file: ./apps/aquatic/docker/aquatic_udp_futureporn.Dockerfile push: true tags: gitea.futureporn.net/futureporn/aquatic:latest + - name: Build futureporn/tracker-helper + uses: docker/build-push-action@v6 + with: + context: ./services/tracker-helper + push: true + tags: gitea.futureporn.net/futureporn/tracker-helper:latest + labels: | + org.opencontainers.image.description=Custom Aquatic helper service, adding info_hash accesslist operations via HTTP + org.opencontainers.image.title=tracker-helper + org.opencontainers.image.licenses=unlicense + org.opencontainers.image.source=https://gitea.futureporn.net/futureporn/fp + org.opencontainers.image.url=https://gitea.futureporn.net/futureporn/-/packages/container/tracker-helper + - name: Build futureporn/tracker uses: docker/build-push-action@v6 with: - context: ./services/tracker + context: ./apps/tracker push: true tags: gitea.futureporn.net/futureporn/tracker:latest labels: | @@ -50,19 +63,19 @@ jobs: TRACKER_HELPER_USERNAME=${{ secrets.TRACKER_HELPER_USERNAME }} TRACKER_HELPER_PASSWORD=${{ secrets.TRACKER_HELPER_PASSWORD }} - - name: Build futureporn/bright - uses: docker/build-push-action@v6 - with: - context: ./apps/bright - push: true - tags: gitea.futureporn.net/futureporn/bright:latest - build-args: | - MIX_ENV=prod - labels: | - org.opencontainers.image.description=The Galaxy's Best VTuber hentai site - org.opencontainers.image.title=bright - org.opencontainers.image.created={{commit_date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'}} - org.opencontainers.image.version={{version}} - org.opencontainers.image.licenses=unlicense - org.opencontainers.image.source=https://gitea.futureporn.net/futureporn/fp - org.opencontainers.image.url=https://gitea.futureporn.net/futureporn/-/packages/container/bright + # - name: Build futureporn/bright + # uses: docker/build-push-action@v6 + # with: + # context: ./apps/bright + # push: true + # tags: gitea.futureporn.net/futureporn/bright:latest + # build-args: | + # MIX_ENV=prod + # labels: | + # org.opencontainers.image.description=The Galaxy's Best VTuber hentai site + # org.opencontainers.image.title=bright + # org.opencontainers.image.created={{commit_date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'}} + # org.opencontainers.image.version={{version}} + # org.opencontainers.image.licenses=unlicense + # org.opencontainers.image.source=https://gitea.futureporn.net/futureporn/fp + # org.opencontainers.image.url=https://gitea.futureporn.net/futureporn/-/packages/container/bright diff --git a/.gitea/workflows/tests.yaml b/.gitea/workflows/tests.yaml index ab15f0e..f25a07c 100644 --- a/.gitea/workflows/tests.yaml +++ b/.gitea/workflows/tests.yaml @@ -37,6 +37,9 @@ jobs: TRACKER_HELPER_URL: ${{ vars.TRACKER_HELPER_URL }} TRACKER_HELPER_USERNAME: ${{ secrets.TRACKER_HELPER_USERNAME }} TRACKER_HELPER_PASSWORD: ${{ secrets.TRACKER_HELPER_PASSWORD }} + TRACKER_HELPER_ACCESSLIST_URL: ${{ vars.TRACKER_HELPER_ACCESSLIST_URL }} + TRACKER_HELPER_ACCESSLIST_PATH: /var/lib/aquatic/accesslist + DB_NAME: ${{ vars.DB_NAME }} DB_HOST: ${{ vars.DB_HOST }} DB_PORT: ${{ vars.DB_PORT }} @@ -79,7 +82,8 @@ jobs: - 3003:3003 - 9000:9000 env: - TRACKER_HELPER_ACCESSLIST_PATH: /var/lib/aquatic/whitelist + TRACKER_HELPER_ACCESSLIST_PATH: /var/lib/aquatic/accesslist + TRACKER_HELPER_ACCESSLIST_URL: http://localhost:5063/accesslist TRACKER_HELPER_USERNAME: ${{ secrets.TRACKER_HELPER_USERNAME }} TRACKER_HELPER_PASSWORD: ${{ secrets.TRACKER_HELPER_PASSWORD }} TRACKER_HELPER_PORT: 5063 diff --git a/apps/aquatic/docker/aquatic_udp_futureporn.Dockerfile b/apps/aquatic/docker/aquatic_udp_futureporn.Dockerfile new file mode 100644 index 0000000..29de663 --- /dev/null +++ b/apps/aquatic/docker/aquatic_udp_futureporn.Dockerfile @@ -0,0 +1,40 @@ +# syntax=docker/dockerfile:1 + +FROM rust:latest AS builder + +WORKDIR /usr/src/aquatic + +COPY . . + +RUN . ./scripts/env-native-cpu-without-avx-512 && cargo build --release -p aquatic_udp + +FROM debian:stable-slim + + +ENV CONFIG_FILE_CONTENTS "[statistics]\ninterval = 5\nprint_to_stdout = true" +ENV ACCESS_LIST_CONTENTS "" + +WORKDIR /etc/aquatic/ + +COPY --from=builder /usr/src/aquatic/target/release/aquatic_udp /usr/local/bin/aquatic_udp + +COPY <<-"EOT" /usr/local/bin/entrypoint.sh +#!/bin/bash +echo -e "$CONFIG_FILE_CONTENTS" > /etc/aquatic/config.toml +echo -e "$ACCESS_LIST_CONTENTS" > /var/lib/aquatic/whitelist +exec /usr/local/bin/aquatic_udp -c /etc/aquatic/config.toml "$@" +EOT + +RUN mkdir -p /var/lib/aquatic && \ + touch /var/lib/aquatic/whitelist && \ + chmod 0666 /var/lib/aquatic/whitelist && \ + chmod +x /usr/local/bin/entrypoint.sh + + + +HEALTHCHECK --interval=5s --timeout=3s --retries=3 \ + CMD pidof aquatic_udp || exit 1 + +## we cd before running to workaround nektos/act behavior which overrides WORKDIR +ENTRYPOINT ["sh", "-c", "cd /etc/aquatic && /usr/local/bin/entrypoint.sh"] +# ENTRYPOINT ["tail", "-f", "/dev/null"] # for debugging \ No newline at end of file diff --git a/apps/bright/config/runtime.exs b/apps/bright/config/runtime.exs index b4f96e3..08db3db 100644 --- a/apps/bright/config/runtime.exs +++ b/apps/bright/config/runtime.exs @@ -32,7 +32,7 @@ config :bright, config :bright, :torrent, tracker_url: System.get_env("TRACKER_URL"), - tracker_helper_url: System.get_env("TRACKER_HELPER_URL"), + tracker_helper_accesslist_url: System.get_env("TRACKER_HELPER_ACCESSLIST_URL"), tracker_helper_username: System.get_env("TRACKER_HELPER_USERNAME"), tracker_helper_password: System.get_env("TRACKER_HELPER_PASSWORD") diff --git a/apps/bright/lib/bright/tracker.ex b/apps/bright/lib/bright/tracker.ex index d028348..f8f2ca6 100644 --- a/apps/bright/lib/bright/tracker.ex +++ b/apps/bright/lib/bright/tracker.ex @@ -17,16 +17,16 @@ defmodule Bright.Tracker do This is where we send infohashes that end up in aquatic's accesslist Usually it's port 5063, path /accesslist """ - @spec accesslist_url() :: binary() - def accesslist_url do + @spec tracker_helper_accesslist_url() :: binary() + def tracker_helper_accesslist_url do url = case Application.fetch_env!(:bright, :torrent)[:tracker_helper_accesslist_url] do - nil -> raise "accesslist_url missing or empty in app config" - "" -> raise "accesslist_url missing or empty in app config" + nil -> raise "tracker_helper_accesslist_url missing or empty in app config" + "" -> raise "tracker_helper_accesslist_url missing or empty in app config" url -> url end - Logger.debug("accesslist_url=#{url}") + Logger.debug("tracker_helper_accesslist_url=#{url}") url end @@ -49,7 +49,7 @@ defmodule Bright.Tracker do end def accesslist_info_hash(info_hash) do - accesslist_url = accesslist_url() + accesslist_url = tracker_helper_accesslist_url() username = tracker_helper_username() password = tracker_helper_password() diff --git a/apps/bright/test/bright/images_test.exs b/apps/bright/test/bright/images_test.exs index db34d67..71e3945 100644 --- a/apps/bright/test/bright/images_test.exs +++ b/apps/bright/test/bright/images_test.exs @@ -13,7 +13,7 @@ defmodule Bright.ImagesTest do {:ok, filename} = Images.create_thumbnail(@test_mp4_fixture) - assert Regex.match?(~r/^\/root\/\.cache\/futureporn\/[^\/]+\/[^\/]+\.png$/, filename) + assert Regex.match?(~r/\.cache\/futureporn\/[^\/]+\/[^\/]+\.png$/, filename) assert File.exists?(filename) assert File.stat!(filename).size > 0, "thumbnail file is empty" end diff --git a/apps/bright/test/bright/tracker_test.exs b/apps/bright/test/bright/tracker_test.exs index d6b67db..8884e4a 100644 --- a/apps/bright/test/bright/tracker_test.exs +++ b/apps/bright/test/bright/tracker_test.exs @@ -3,24 +3,22 @@ defmodule Bright.TrackerTest do use Bright.DataCase alias Bright.Tracker - alias Bright.URLEncoder describe "tracker" do use ExUnit.Case, async: false - import Bright.StreamsFixtures # tails-amd64-6.10-img (BT info_hash v1) @info_hash_v1_fixture "07b4516336e4afe9232c73bc312642590a7d7e95" @tag :integration - test "whitelist_info_hash/1 using a string info_hash" do - case Tracker.whitelist_info_hash(@info_hash_v1_fixture) do + test "accesslist_info_hash/1 using a string info_hash" do + case Tracker.accesslist_info_hash(@info_hash_v1_fixture) do {:ok, info_hash} -> assert :ok assert info_hash === @info_hash_v1_fixture {:error, :closed} -> - flunk("The connection to opentracker was closed. Is opentracker running?") + flunk("The connection to tracker was closed. Is tracker running?") other -> flunk("Unexpected result: #{inspect(other)}") diff --git a/apps/tracker-helper/Dockerfile b/apps/tracker/Dockerfile similarity index 100% rename from apps/tracker-helper/Dockerfile rename to apps/tracker/Dockerfile diff --git a/apps/tracker-helper/root/etc/aquatic/config.toml b/apps/tracker/root/etc/aquatic/config.toml similarity index 100% rename from apps/tracker-helper/root/etc/aquatic/config.toml rename to apps/tracker/root/etc/aquatic/config.toml diff --git a/apps/tracker-helper/root/etc/caddy/Caddyfile b/apps/tracker/root/etc/caddy/Caddyfile similarity index 100% rename from apps/tracker-helper/root/etc/caddy/Caddyfile rename to apps/tracker/root/etc/caddy/Caddyfile diff --git a/apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/aquatic/run b/apps/tracker/root/etc/s6-overlay/s6-rc.d/aquatic/run similarity index 100% rename from apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/aquatic/run rename to apps/tracker/root/etc/s6-overlay/s6-rc.d/aquatic/run diff --git a/apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/aquatic/type b/apps/tracker/root/etc/s6-overlay/s6-rc.d/aquatic/type similarity index 100% rename from apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/aquatic/type rename to apps/tracker/root/etc/s6-overlay/s6-rc.d/aquatic/type diff --git a/apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/caddy/dependencies.d/aquatic b/apps/tracker/root/etc/s6-overlay/s6-rc.d/caddy/dependencies.d/aquatic similarity index 100% rename from apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/caddy/dependencies.d/aquatic rename to apps/tracker/root/etc/s6-overlay/s6-rc.d/caddy/dependencies.d/aquatic diff --git a/apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/caddy/run b/apps/tracker/root/etc/s6-overlay/s6-rc.d/caddy/run similarity index 100% rename from apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/caddy/run rename to apps/tracker/root/etc/s6-overlay/s6-rc.d/caddy/run diff --git a/apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/caddy/type b/apps/tracker/root/etc/s6-overlay/s6-rc.d/caddy/type similarity index 100% rename from apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/caddy/type rename to apps/tracker/root/etc/s6-overlay/s6-rc.d/caddy/type diff --git a/apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/tracker-helper/dependencies.d/aquatic b/apps/tracker/root/etc/s6-overlay/s6-rc.d/tracker-helper/dependencies.d/aquatic similarity index 100% rename from apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/tracker-helper/dependencies.d/aquatic rename to apps/tracker/root/etc/s6-overlay/s6-rc.d/tracker-helper/dependencies.d/aquatic diff --git a/apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/tracker-helper/run b/apps/tracker/root/etc/s6-overlay/s6-rc.d/tracker-helper/run similarity index 100% rename from apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/tracker-helper/run rename to apps/tracker/root/etc/s6-overlay/s6-rc.d/tracker-helper/run diff --git a/apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/tracker-helper/type b/apps/tracker/root/etc/s6-overlay/s6-rc.d/tracker-helper/type similarity index 100% rename from apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/tracker-helper/type rename to apps/tracker/root/etc/s6-overlay/s6-rc.d/tracker-helper/type diff --git a/apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/user/contents.d/aquatic b/apps/tracker/root/etc/s6-overlay/s6-rc.d/user/contents.d/aquatic similarity index 100% rename from apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/user/contents.d/aquatic rename to apps/tracker/root/etc/s6-overlay/s6-rc.d/user/contents.d/aquatic diff --git a/apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/user/contents.d/tracker-helper b/apps/tracker/root/etc/s6-overlay/s6-rc.d/user/contents.d/tracker-helper similarity index 100% rename from apps/tracker-helper/root/etc/s6-overlay/s6-rc.d/user/contents.d/tracker-helper rename to apps/tracker/root/etc/s6-overlay/s6-rc.d/user/contents.d/tracker-helper diff --git a/apps/tracker-helper/root/etc/tracker/healthcheck.sh b/apps/tracker/root/etc/tracker/healthcheck.sh similarity index 64% rename from apps/tracker-helper/root/etc/tracker/healthcheck.sh rename to apps/tracker/root/etc/tracker/healthcheck.sh index 4991d56..13de203 100755 --- a/apps/tracker-helper/root/etc/tracker/healthcheck.sh +++ b/apps/tracker/root/etc/tracker/healthcheck.sh @@ -1,5 +1,5 @@ #!/bin/sh pidof aquatic_udp || exit 111 -curl -f http://localhost:5063/helper || exit 112 +curl -f http://localhost:5063/health || exit 112 curl -f http://localhost:9000/metrics || exit 113 \ No newline at end of file diff --git a/apps/tracker-helper/root/usr/src/tracker-helper/.gitkeep b/apps/tracker/root/usr/src/tracker-helper/.gitkeep similarity index 100% rename from apps/tracker-helper/root/usr/src/tracker-helper/.gitkeep rename to apps/tracker/root/usr/src/tracker-helper/.gitkeep diff --git a/apps/tracker-helper/root/var/lib/aquatic/accesslist b/apps/tracker/root/var/lib/aquatic/accesslist similarity index 100% rename from apps/tracker-helper/root/var/lib/aquatic/accesslist rename to apps/tracker/root/var/lib/aquatic/accesslist diff --git a/config/deploy.yml b/config/deploy.yml index 83b2670..2915487 100644 --- a/config/deploy.yml +++ b/config/deploy.yml @@ -89,39 +89,21 @@ ssh: # Use accessory services (secrets come from .kamal/secrets). # accessories: - tracker-helper: - image: gitea.futureporn.net/futureporn/opentracker:latest - host: 45.76.57.101 - port: "127.0.0.1:3000:3000" - env: - secret: - - WL_CREDENTIALS - proxy: - ssl: true - forward_headers: true - app_port: 3000 - host: tracker-helper.futureporn.net - healthcheck: - path: /health - volumes: - - opentracker-etc:/etc/opentracker - - opentracker-var:/var/run/opentracker - tracker: image: gitea.futureporn.net/futureporn/tracker:latest host: 45.76.57.101 port: "0.0.0.0:5063:5063" env: clear: - HELPER_ACCESSLIST_PATH: "/var/lib/aquatic/accesslist" + TRACKER_HELPER_ACCESSLIST_PATH: "/var/lib/aquatic/accesslist" secret: - - HELPER_USERNAME - - HELPER_PASSWORD - + - TRACKER_HELPER_USERNAME + - TRACKER_HELPER_PASSWORD proxy: ssl: true - forward_headers: true - app_port: 5063 # note: tracker also uses port 6969/udp and 9000/tcp, but the api at 5063/tcp is what we specify here. # @todo @blocking https://github.com/basecamp/kamal-proxy/issues/48 + forward_headers: false + # note: tracker also uses port 6969/udp and 9000/tcp, but the api at 5063/tcp is what we specify here. # @todo @blocking https://github.com/basecamp/kamal-proxy/issues/48 + app_port: 5063 host: tracker.futureporn.net healthcheck: path: /health diff --git a/services/tracker/.dockerignore b/services/tracker-helper/.dockerignore similarity index 100% rename from services/tracker/.dockerignore rename to services/tracker-helper/.dockerignore diff --git a/services/tracker/.gitignore b/services/tracker-helper/.gitignore similarity index 100% rename from services/tracker/.gitignore rename to services/tracker-helper/.gitignore diff --git a/services/tracker/Dockerfile b/services/tracker-helper/Dockerfile similarity index 100% rename from services/tracker/Dockerfile rename to services/tracker-helper/Dockerfile diff --git a/services/tracker/README.md b/services/tracker-helper/README.md similarity index 100% rename from services/tracker/README.md rename to services/tracker-helper/README.md diff --git a/services/tracker/app.ts b/services/tracker-helper/app.ts similarity index 100% rename from services/tracker/app.ts rename to services/tracker-helper/app.ts diff --git a/services/tracker/bun.lockb b/services/tracker-helper/bun.lockb similarity index 100% rename from services/tracker/bun.lockb rename to services/tracker-helper/bun.lockb diff --git a/services/tracker/fifo-helper.ts b/services/tracker-helper/fifo-helper.ts similarity index 100% rename from services/tracker/fifo-helper.ts rename to services/tracker-helper/fifo-helper.ts diff --git a/services/tracker/index.ts b/services/tracker-helper/index.ts similarity index 100% rename from services/tracker/index.ts rename to services/tracker-helper/index.ts diff --git a/services/tracker/package.json b/services/tracker-helper/package.json similarity index 100% rename from services/tracker/package.json rename to services/tracker-helper/package.json diff --git a/services/tracker/pnpm-lock.yaml b/services/tracker-helper/pnpm-lock.yaml similarity index 100% rename from services/tracker/pnpm-lock.yaml rename to services/tracker-helper/pnpm-lock.yaml diff --git a/services/tracker/test/app.test.ts b/services/tracker-helper/test/app.test.ts similarity index 100% rename from services/tracker/test/app.test.ts rename to services/tracker-helper/test/app.test.ts diff --git a/services/tracker-helper/test/fixtures/taco b/services/tracker-helper/test/fixtures/taco deleted file mode 100644 index 0e628b0..0000000 --- a/services/tracker-helper/test/fixtures/taco +++ /dev/null @@ -1,4 +0,0 @@ -b22ea43e4c0a7f73fc706b5faf1c35bb078d3722 -3aa5ad5e62eaffd148cff3dbe93ff2e1e9cbcf01 -3aa5ad5e62eaffd148cff3dbe93ff2e1e9cbcf01 -3aa5ad5e62eaffd148cff3dbe93ff2e1e9cbcf01 diff --git a/services/tracker/test/fixtures/whitelist b/services/tracker-helper/test/fixtures/whitelist similarity index 100% rename from services/tracker/test/fixtures/whitelist rename to services/tracker-helper/test/fixtures/whitelist diff --git a/services/tracker/tsconfig.json b/services/tracker-helper/tsconfig.json similarity index 100% rename from services/tracker/tsconfig.json rename to services/tracker-helper/tsconfig.json