name: Build a container on: workflow_call: inputs: tachidesk_release_type: required: true default: 'preview' description: 'Suwayomi Release Type' type: string do_upload: required: true default: true description: 'Should the image be uploaded to the registry?' type: boolean secrets: DISCORD_TACHIDESK_WEBHOOK_ID: required: false DISCORD_TACHIDESK_TOKEN: required: false env: server_repo: ${{ inputs.tachidesk_release_type == 'stable' && 'Suwayomi-Server' || 'Suwayomi-Server-preview' }} test_image_tag: ghcr.io/suwayomi/suwayomi-server-test:testing this_actions_run_url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" jobs: build_the_container: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v5 with: # We want a full clone of the repo so that the rev-list count below is correct fetch-depth: 0 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Get latest release metadata id: get_latest_release_metadata run: | curl -s https://api.github.com/repos/suwayomi/${{ env.server_repo }}/releases/latest > ${{ runner.temp }}/latest_release.json release_url=$(jq -r '.assets[] | select(.content_type == "application/java-archive") | .browser_download_url' ${{ runner.temp }}/latest_release.json) release_tag=$(jq -r '.tag_name' ${{ runner.temp }}/latest_release.json) release_filename=$(basename $release_url) tachidesk_docker_git_commit=$(git rev-list --count HEAD) build_date=$(date "+%F") echo "release_url=$release_url" >> $GITHUB_OUTPUT echo "release_tag=$release_tag" >> $GITHUB_OUTPUT echo "release_filename=$release_filename" >> $GITHUB_OUTPUT echo "tachidesk_docker_git_commit=$tachidesk_docker_git_commit" >> $GITHUB_OUTPUT echo "build_date=$build_date" >> $GITHUB_OUTPUT # this only builds the amd64 version of the image, which is fine as that's # all that is needed to test the container on GitHub Actions' build servers (which are running amd64 CPUs) - name: Build container image to test uses: docker/build-push-action@v6 with: load: true # this is important, as this tells build-push-action to save the container to the local docker daemon build-args: | BUILD_DATE=${{ steps.get_latest_release_metadata.outputs.build_date }} TACHIDESK_RELEASE_TAG=${{ steps.get_latest_release_metadata.outputs.release_tag }} TACHIDESK_RELEASE_DOWNLOAD_URL=${{ steps.get_latest_release_metadata.outputs.release_url }} TACHIDESK_FILENAME=${{ steps.get_latest_release_metadata.outputs.release_filename }} TACHIDESK_DOCKER_GIT_COMMIT=${{ steps.get_latest_release_metadata.outputs.tachidesk_docker_git_commit }} tags: ${{ env.test_image_tag }} # Launch the container and then hit the 'about' API to verify that it can start up correctly. - name: Test new container image without passing environment variables env: DO_UPLOAD: ${{ inputs.do_upload }} run: | mkdir -p ${{ runner.temp }}/tachidesk chmod -R 777 ${{ runner.temp }}/tachidesk docker run -d -p 127.0.0.1:4568:4567 -v ${{ runner.temp }}/tachidesk:/home/suwayomi/.local/share/Tachidesk --name=suwayomi_test ${{ env.test_image_tag }} sleep 15 curl -s 127.0.0.1:4568/api/v1/settings/about/ && val=$(curl -s 127.0.0.1:4568/api/v1/settings/about/ | grep -o "Suwayomi-Server" | sort --unique) docker stop suwayomi_test docker logs suwayomi_test > ${{ runner.temp }}/tachidesk.log docker rm suwayomi_test if [[ $val != "Suwayomi-Server" ]]; then echo "Container logs:" echo "==============================" cat ${{ runner.temp }}/tachidesk.log echo "==============================" echo "Did not find Suwayomi-Server in server response: ${val}" if [[ $DO_UPLOAD == "true" ]]; then curl \ -F 'payload_json={"username": "Github", "content": "<@199705443789045771>\nDocker ${{ inputs.tachidesk_release_type }} image dry run failed! 😢 Version - ${{ steps.get_latest_release_metadata.outputs.release_tag }}. [See the full run log](${{ env.this_actions_run_url }})"}' \ -F "file1=@${{ runner.temp }}/tachidesk.log" \ "https://discord.com/api/webhooks/${{ secrets.DISCORD_TACHIDESK_WEBHOOK_ID }}/${{ secrets.DISCORD_TACHIDESK_TOKEN }}" fi exit 1 fi - name: Test new container image with passing environment variables env: DO_UPLOAD: ${{ inputs.do_upload }} run: | mkdir -p ${{ runner.temp }}/tachidesk_env_vars chmod -R 777 ${{ runner.temp }}/tachidesk_env_vars docker run -d -p 127.0.0.1:4568:4567 -v ${{ runner.temp }}/tachidesk_env_vars:/home/suwayomi/.local/share/Tachidesk \ -e BIND_IP=0.0.0.0 \ -e BIND_PORT=4567 \ -e SOCKS_PROXY_ENABLED=false \ -e SOCKS_PROXY_VERSION=4 \ -e SOCKS_PROXY_HOST=socks_host \ -e SOCKS_PROXY_PORT=socks_port \ -e SOCKS_PROXY_USERNAME=socks_user \ -e SOCKS_PROXY_PASSWORD=socks_pass \ -e DOWNLOAD_AS_CBZ=true \ -e AUTH_MODE=basic_auth \ -e AUTH_USERNAME=manga \ -e AUTH_PASSWORD=hello123 \ -e JWT_AUDIENCE=suwayomi-server-api2 \ -e JWT_TOKEN_EXPIRY=10m \ -e JWT_REFRESH_EXPIRY=30d \ -e DEBUG=true \ -e MAX_LOG_FILES=1000 \ -e MAX_LOG_FILE_SIZE=1000mb \ -e MAX_LOG_FOLDER_SIZE=1000mb \ -e WEB_UI_ENABLED=true \ -e WEB_UI_FLAVOR=WebUI \ -e WEB_UI_CHANNEL=preview \ -e WEB_UI_UPDATE_INTERVAL=2 \ -e AUTO_DOWNLOAD_CHAPTERS=true \ -e AUTO_DOWNLOAD_EXCLUDE_UNREAD=false \ -e AUTO_DOWNLOAD_NEW_CHAPTERS_LIMIT=5 \ -e AUTO_DOWNLOAD_IGNORE_REUPLOADS=false \ -e DOWNLOAD_CONVERSIONS="{ \"image/filetype\" = { target = \"image/filetype\" }, \"image/filetype\" = { target = \"image/filetype\" } }" \ -e SERVE_CONVERSIONS="{ \"image/filetype\" = { target = \"image/filetype\" }, \"image/filetype\" = { target = \"image/filetype\" } }" \ -e EXTENSION_REPOS=[\"http://github.com/orginazation-name/repo-name\",\"http://github.com/orginazation-name-2/repo-name-2\"] \ -e MAX_SOURCES_IN_PARALLEL=12 \ -e UPDATE_EXCLUDE_UNREAD=false \ -e UPDATE_EXCLUDE_STARTED=false \ -e UPDATE_EXCLUDE_COMPLETED=false \ -e UPDATE_INTERVAL=30 \ -e UPDATE_MANGA_INFO=true \ -e BACKUP_TIME=13:37 \ -e BACKUP_INTERVAL=2 \ -e BACKUP_TTL=31 \ -e AUTO_BACKUP_INCLUDE_MANGA=true \ -e AUTO_BACKUP_INCLUDE_CATEGORIES=false \ -e AUTO_BACKUP_INCLUDE_CHAPTERS=false \ -e AUTO_BACKUP_INCLUDE_TRACKING=false \ -e AUTO_BACKUP_INCLUDE_HISTORY=false \ -e AUTO_BACKUP_INCLUDE_CLIENT_DATA=false \ -e AUTO_BACKUP_INCLUDE_SERVER_SETTINGS=false \ -e FLARESOLVERR_ENABLED=true \ -e FLARESOLVERR_URL=http://flaresolverr:8191 \ -e FLARESOLVERR_TIMEOUT=30 \ -e FLARESOLVERR_SESSION_NAME=session-name \ -e FLARESOLVERR_SESSION_TTL=120 \ -e FLARESOLVERR_RESPONSE_AS_FALLBACK=true \ -e OPDS_USE_BINARY_FILE_SIZES=true \ -e OPDS_ITEMS_PER_PAGE=51 \ -e OPDS_ENABLE_PAGE_READ_PROGRESS=false \ -e OPDS_MARK_AS_READ_ON_DOWNLOAD=true \ -e OPDS_SHOW_ONLY_UNREAD_CHAPTERS=true \ -e OPDS_SHOW_ONLY_DOWNLOADED_CHAPTERS=true \ -e OPDS_CHAPTER_SORT_ORDER=ASC \ -e OPDS_CBZ_MIME_TYPE=LEGACY \ -e KOREADER_SYNC_SERVER_URL=http://koreader:17200 \ -e KOREADER_SYNC_USERNAME=manga \ -e KOREADER_SYNC_USERKEY=hello123 \ -e KOREADER_SYNC_DEVICE_ID=100 \ -e KOREADER_SYNC_CHECKSUM_METHOD=filename \ -e KOREADER_SYNC_PERCENTAGE_TOLERANCE=0.001 \ -e KOREADER_SYNC_STRATEGY_FORWARD=disabled \ -e KOREADER_SYNC_STRATEGY_BACKWARD=prompt \ -e DATABASE_TYPE=H2 \ -e DATABASE_URL=postgresql://localhost:5432/suwayomi \ -e DATABASE_USERNAME=manga \ -e DATABASE_PASSWORD=hello123 \ -e USE_HIKARI_CONNECTION_POOL=false \ --name=suwayomi_test \ ${{ env.test_image_tag }} sleep 15 curl -s http://manga:hello123@127.0.0.1:4568/api/v1/settings/about/ && val_env_vars=$(curl -s http://manga:hello123@127.0.0.1:4568/api/v1/settings/about/ | grep -o "Suwayomi-Server" | sort --unique) docker stop suwayomi_test docker logs suwayomi_test > ${{ runner.temp }}/tachidesk_env_vars.log docker rm suwayomi_test if [[ $val_env_vars != "Suwayomi-Server" ]]; then echo "Container logs:" echo "==============================" cat ${{ runner.temp }}/tachidesk_env_vars.log echo "==============================" echo "Did not find Suwayomi-Server in server response: ${val_env_vars}" if [[ $DO_UPLOAD == "true" ]]; then curl \ -F 'payload_json={"username": "Github", "content": "<@199705443789045771>\nDocker ${{ inputs.tachidesk_release_type }} image dry run failed! 😢 Version - ${{ steps.get_latest_release_metadata.outputs.release_tag }}. [See the full run log](${{ env.this_actions_run_url }})"}' \ -F "file1=@${{ runner.temp }}/tachidesk_env_vars.log" \ "https://discord.com/api/webhooks/${{ secrets.DISCORD_TACHIDESK_WEBHOOK_ID }}/${{ secrets.DISCORD_TACHIDESK_TOKEN }}" fi exit 1 fi # Now we build for all the platforms we support here. NB: the amd64 # won't be rebuilt since the local docker daemon has that still cached - name: Push container image to registry if: inputs.do_upload uses: docker/build-push-action@v6 with: platforms: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x push: true build-args: | BUILD_DATE=${{ steps.get_latest_release_metadata.outputs.build_date }} TACHIDESK_RELEASE_TAG=${{ steps.get_latest_release_metadata.outputs.release_tag }} TACHIDESK_RELEASE_DOWNLOAD_URL=${{ steps.get_latest_release_metadata.outputs.release_url }} TACHIDESK_FILENAME=${{ steps.get_latest_release_metadata.outputs.release_filename }} TACHIDESK_DOCKER_GIT_COMMIT=${{ steps.get_latest_release_metadata.outputs.tachidesk_docker_git_commit }} TACHIDESK_KCEF= TACHIDESK_KCEF_RELEASE_URL=https://api.github.com/repos/JetBrains/JetBrainsRuntime/releases/latest TACHIDESK_ABORT_HANDLER_DOWNLOAD_URL=https://raw.githubusercontent.com/Suwayomi/Suwayomi-Server/refs/heads/master/scripts/resources/catch_abort.c tags: | ${{ inputs.tachidesk_release_type == 'stable' && 'ghcr.io/suwayomi/tachidesk:latest' || '' }} ghcr.io/suwayomi/tachidesk:${{ inputs.tachidesk_release_type }} ghcr.io/suwayomi/tachidesk:${{ steps.get_latest_release_metadata.outputs.release_tag }} ${{ inputs.tachidesk_release_type == 'stable' && 'ghcr.io/suwayomi/suwayomi-server:latest' || '' }} ghcr.io/suwayomi/suwayomi-server:${{ inputs.tachidesk_release_type }} ghcr.io/suwayomi/suwayomi-server:${{ steps.get_latest_release_metadata.outputs.release_tag }} ghcr.io/suwayomi/suwayomi-server:${{ steps.get_latest_release_metadata.outputs.release_tag }}-${{ inputs.tachidesk_release_type }} cache-from: type=registry,ref=ghcr.io/suwayomi/suwayomi-server:buildcache cache-to: type=registry,ref=ghcr.io/suwayomi/suwayomi-server:buildcache,mode=max # - name: Create slim container # uses: kitabisa/docker-slim-action@v1 # env: # DSLIM_HTTP_PROBE: false # DSLIM_PRESERVE_PATH: /opt/java/openjdk/lib,/opt/java/openjdk/conf,/home/suwayomi/.local/share/Tachidesk # with: # target: ghcr.io/suwayomi/suwayomi-server:${{ inputs.tachidesk_release_type }} # tag: '${{ inputs.tachidesk_release_type }}-slim' # - name: Tag slim container and push registery to repository # run: | # docker tag ghcr.io/suwayomi/suwayomi-server:${{ inputs.tachidesk_release_type }}-slim ghcr.io/suwayomi/suwayomi-server:${{ steps.get_latest_release_metadata.outputs.release_tag }}-slim # if [ "${{ inputs.tachidesk_release_type }}" == "stable" ]; then # docker tag ghcr.io/suwayomi/suwayomi-server:${{ inputs.tachidesk_release_type }}-slim ghcr.io/suwayomi/suwayomi-server:latest-slim # fi # docker image push "ghcr.io/suwayomi/suwayomi-server" --all-tags - name: Send a Discord message through the webhook (preview build) if: inputs.do_upload && inputs.tachidesk_release_type == 'preview' run: | curl -H "Content-Type: application/json" -d '{"content": "Docker Preview Image Published!","embeds":[{"color":16729344,"author":{"name":"${{ github.repository_owner }}","icon_url":"https://avatars.githubusercontent.com/u/81182076","url":"https://github.com/${{ github.repository_owner }}"},"title":"Docker Preview Release","url":"https://github.com/${{ github.repository_owner }}/Suwayomi-Server-docker","fields":[{"name":"docker update","value":"docker pull ghcr.io/suwayomi/suwayomi-server:preview","inline":false},{"name":"docker run","value":"docker run -p 4567:4567 ghcr.io/suwayomi/suwayomi-server:preview","inline":false}],"thumbnail":{"url": "https://www.docker.com/sites/default/files/d8/2019-07/vertical-logo-monochromatic.png"},"description":"Suwayomi-Server version - ${{ steps.get_latest_release_metadata.outputs.release_tag }}"}]}' "https://discord.com/api/webhooks/${{ secrets.DISCORD_TACHIDESK_WEBHOOK_ID }}/${{ secrets.DISCORD_TACHIDESK_TOKEN }}" - name: Send a Discord message through the webhook (stable build) if: inputs.do_upload && inputs.tachidesk_release_type == 'stable' run: | curl -H "Content-Type: application/json" -d '{"content": "Docker Stable Image Published!","embeds":[{"color":5409028,"author":{"name":"${{ github.repository_owner }}","icon_url":"https://avatars.githubusercontent.com/u/81182076","url":"https://github.com/${{ github.repository_owner }}"},"title":"Docker Stable Release","url":"https://github.com/${{ github.repository_owner }}/Suwayomi-Server-docker","fields":[{"name":"docker update","value":"docker pull ghcr.io/suwayomi/suwayomi-server:stable","inline":false},{"name":"docker run","value":"docker run -p 4567:4567 ghcr.io/suwayomi/suwayomi-server","inline":false}],"thumbnail":{"url": "https://www.docker.com/sites/default/files/d8/2019-07/vertical-logo-monochromatic.png"},"description":"Suwayomi-Server version - ${{ steps.get_latest_release_metadata.outputs.release_tag }}"}]}' "https://discord.com/api/webhooks/${{ secrets.DISCORD_TACHIDESK_WEBHOOK_ID }}/${{ secrets.DISCORD_TACHIDESK_TOKEN }}" - name: Save tag (stable build) if: inputs.do_upload && inputs.tachidesk_release_type == 'stable' run: | echo "`jq --arg value "${{ steps.get_latest_release_metadata.outputs.release_tag }}" '.stable=$value' scripts/tachidesk_version.json`" > scripts/tachidesk_version.json git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" git status if [ -n "$(git status --porcelain)" ]; then git pull git add . git commit -a -m "Update stable version" git push else echo "No changes to commit" fi