diff --git a/.editorconfig b/.editorconfig old mode 100755 new mode 100644 index a92f7df..5f150f3 --- a/.editorconfig +++ b/.editorconfig @@ -15,6 +15,6 @@ trim_trailing_whitespace = false indent_style = space indent_size = 2 -[{**.sh,root/etc/cont-init.d/**,root/etc/services.d/**}] +[{**.sh,root/etc/s6-overlay/s6-rc.d/**,root/etc/cont-init.d/**,root/etc/services.d/**}] indent_style = space indent_size = 4 diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 710006b..9a258e3 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -6,7 +6,7 @@ * Read, and fill the Pull Request template * If this is a fix for a typo (in code, documentation, or the README) please file an issue and let us sort it out. We do not need a PR * If the PR is addressing an existing issue include, closes #\, in the body of the PR commit message -* If you want to discuss changes, you can also bring it up in [#dev-talk](https://discordapp.com/channels/354974912613449730/757585807061155840) in our [Discord server](https://discord.gg/YWrKVTn) +* If you want to discuss changes, you can also bring it up in [#dev-talk](https://discordapp.com/channels/354974912613449730/757585807061155840) in our [Discord server](https://linuxserver.io/discord) ## Common files @@ -24,7 +24,7 @@ ## Readme If you would like to change our readme, please __**do not**__ directly edit the readme, as it is auto-generated on each commit. -Instead edit the [readme-vars.yml](https://github.com/linuxserver/docker-mastodon/edit/main/readme-vars.yml). +Instead edit the [readme-vars.yml](https://github.com/linuxserver/docker-mastodon/edit/develop/readme-vars.yml). These variables are used in a template for our [Jenkins Builder](https://github.com/linuxserver/docker-jenkins-builder) as part of an ansible play. Most of these variables are also carried over to [docs.linuxserver.io](https://docs.linuxserver.io/images/docker-mastodon) @@ -105,17 +105,17 @@ docker build \ -t linuxserver/mastodon:latest . ``` -The ARM variants can be built on x86_64 hardware using `multiarch/qemu-user-static` +The ARM variants can be built on x86_64 hardware and vice versa using `lscr.io/linuxserver/qemu-static` ```bash -docker run --rm --privileged multiarch/qemu-user-static:register --reset +docker run --rm --privileged lscr.io/linuxserver/qemu-static --reset ``` Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64`. ## Update the changelog -If you are modifying the Dockerfiles or any of the startup scripts in [root](https://github.com/linuxserver/docker-mastodon/tree/main/root), add an entry to the changelog +If you are modifying the Dockerfiles or any of the startup scripts in [root](https://github.com/linuxserver/docker-mastodon/tree/develop/root), add an entry to the changelog ```yml changelogs: diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 1868697..ba43d3a 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,11 +1,11 @@ blank_issues_enabled: false contact_links: - name: Discord chat support - url: https://discord.gg/YWrKVTn + url: https://linuxserver.io/discord about: Realtime support / chat with the community and the team. - - name: Discourse discussion forum - url: https://discourse.linuxserver.io + - name: Github Discussions + url: https://github.com/orgs/linuxserver/discussions about: Post on our community forum. - name: Documentation diff --git a/.github/ISSUE_TEMPLATE/issue.bug.md b/.github/ISSUE_TEMPLATE/issue.bug.md deleted file mode 100644 index 714848c..0000000 --- a/.github/ISSUE_TEMPLATE/issue.bug.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve - ---- -[linuxserverurl]: https://linuxserver.io -[![linuxserver.io](https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/linuxserver_medium.png)][linuxserverurl] - - - - - ------------------------------- - -## Expected Behavior - - -## Current Behavior - - -## Steps to Reproduce - - -1. -2. -3. -4. - -## Environment -**OS:** -**CPU architecture:** x86_64/arm32/arm64 -**How docker service was installed:** - - - -## Command used to create docker container (run/create/compose/screenshot) - - -## Docker logs - diff --git a/.github/ISSUE_TEMPLATE/issue.bug.yml b/.github/ISSUE_TEMPLATE/issue.bug.yml new file mode 100644 index 0000000..8a680f9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/issue.bug.yml @@ -0,0 +1,76 @@ +# Based on the issue template +name: Bug report +description: Create a report to help us improve +title: "[BUG] " +labels: [Bug] +body: + - type: checkboxes + attributes: + label: Is there an existing issue for this? + description: Please search to see if an issue already exists for the bug you encountered. + options: + - label: I have searched the existing issues + required: true + - type: textarea + attributes: + label: Current Behavior + description: Tell us what happens instead of the expected behavior. + validations: + required: true + - type: textarea + attributes: + label: Expected Behavior + description: Tell us what should happen. + validations: + required: false + - type: textarea + attributes: + label: Steps To Reproduce + description: Steps to reproduce the behavior. + placeholder: | + 1. In this environment... + 2. With this config... + 3. Run '...' + 4. See error... + validations: + required: true + - type: textarea + attributes: + label: Environment + description: | + examples: + - **OS**: Ubuntu 20.04 + - **How docker service was installed**: distro's packagemanager + value: | + - OS: + - How docker service was installed: + render: markdown + validations: + required: false + - type: dropdown + attributes: + label: CPU architecture + options: + - x86-64 + - arm64 + validations: + required: true + - type: textarea + attributes: + label: Docker creation + description: | + Command used to create docker container + Provide your docker create/run command or compose yaml snippet, or a screenshot of settings if using a gui to create the container + render: bash + validations: + required: true + - type: textarea + attributes: + description: | + Provide a full docker log, output of "docker logs mastodon" + label: Container logs + placeholder: | + Output of `docker logs mastodon` + render: bash + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/issue.feature.md b/.github/ISSUE_TEMPLATE/issue.feature.md deleted file mode 100644 index 20a91fd..0000000 --- a/.github/ISSUE_TEMPLATE/issue.feature.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project - ---- -[linuxserverurl]: https://linuxserver.io -[![linuxserver.io](https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/linuxserver_medium.png)][linuxserverurl] - -<!--- If you are new to Docker or this application our issue tracker is **ONLY** used for reporting bugs or requesting features. Please use [our discord server](https://discord.gg/YWrKVTn) for general support. ---> - -<!--- If this acts as a feature request please ask yourself if this modification is something the whole userbase will benefit from ---> -<!--- If this is a specific change for corner case functionality or plugins please look at making a Docker Mod or local script https://blog.linuxserver.io/2019/09/14/customizing-our-containers/ --> - -<!--- Provide a general summary of the request in the Title above --> - ------------------------------- - -## Desired Behavior -<!--- Tell us what should happen --> - -## Current Behavior -<!--- Tell us what happens instead of the expected behavior --> - -## Alternatives Considered -<!--- Tell us what other options you have tried or considered --> diff --git a/.github/ISSUE_TEMPLATE/issue.feature.yml b/.github/ISSUE_TEMPLATE/issue.feature.yml new file mode 100644 index 0000000..099dcdb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/issue.feature.yml @@ -0,0 +1,31 @@ +# Based on the issue template +name: Feature request +description: Suggest an idea for this project +title: "[FEAT] <title>" +labels: [enhancement] +body: + - type: checkboxes + attributes: + label: Is this a new feature request? + description: Please search to see if a feature request already exists. + options: + - label: I have searched the existing issues + required: true + - type: textarea + attributes: + label: Wanted change + description: Tell us what you want to happen. + validations: + required: true + - type: textarea + attributes: + label: Reason for change + description: Justify your request, why do you want it, what is the benefit. + validations: + required: true + - type: textarea + attributes: + label: Proposed code change + description: Do you have a potential code change in mind? + validations: + required: false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 8b2203c..3ce2c18 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -3,7 +3,6 @@ [linuxserverurl]: https://linuxserver.io [![linuxserver.io](https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/linuxserver_medium.png)][linuxserverurl] - <!--- Before submitting a pull request please check the following --> <!--- If this is a fix for a typo (in code, documentation, or the README) please file an issue and let us sort it out. We do not need a PR --> @@ -12,7 +11,6 @@ <!--- You have included links to any files / patches etc your PR may be using in the body of the PR commit message --> <!--- We maintain a changelog of major revisions to the container at the end of readme-vars.yml in the root of this repository, please add your changes there if appropriate --> - <!--- Coding guidelines: --> <!--- 1. Installed packages in the Dockerfiles should be in alphabetical order --> <!--- 2. Changes to Dockerfile should be replicated in Dockerfile.armhf and Dockerfile.aarch64 if applicable --> @@ -21,11 +19,16 @@ ------------------------------ - - [ ] I have read the [contributing](https://github.com/linuxserver/docker-mastodon/blob/main/.github/CONTRIBUTING.md) guideline and understand that I have made the correct modifications +- [ ] I have read the [contributing](https://github.com/linuxserver/docker-mastodon/blob/develop/.github/CONTRIBUTING.md) guideline and understand that I have made the correct modifications + +<!--- LLM disclosure: --> + +- [ ] An LLM assisted me in writing the code or text for this PR +- [ ] An LLM agent wrote the code or text for this PR ------------------------------ -<!--- We welcome all PR’s though this doesn’t guarantee it will be accepted. --> +<!--- We welcome all PRs though this doesn’t guarantee it will be accepted. --> ## Description: <!--- Describe your changes in detail --> @@ -38,6 +41,5 @@ <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> - ## Source / References: <!--- Please include any forum posts/github links relevant to the PR --> diff --git a/.github/workflows/call_issue_pr_tracker.yml b/.github/workflows/call_issue_pr_tracker.yml new file mode 100644 index 0000000..d07cf12 --- /dev/null +++ b/.github/workflows/call_issue_pr_tracker.yml @@ -0,0 +1,19 @@ +name: Issue & PR Tracker + +on: + issues: + types: [opened,reopened,labeled,unlabeled,closed] + pull_request_target: + types: [opened,reopened,review_requested,review_request_removed,labeled,unlabeled,closed] + pull_request_review: + types: [submitted,edited,dismissed] + +permissions: + contents: read + +jobs: + manage-project: + permissions: + issues: write + uses: linuxserver/github-workflows/.github/workflows/issue-pr-tracker.yml@v1 + secrets: inherit diff --git a/.github/workflows/call_issues_cron.yml b/.github/workflows/call_issues_cron.yml new file mode 100644 index 0000000..1653798 --- /dev/null +++ b/.github/workflows/call_issues_cron.yml @@ -0,0 +1,16 @@ +name: Mark stale issues and pull requests +on: + schedule: + - cron: '21 5 * * *' + workflow_dispatch: + +permissions: + contents: read + +jobs: + stale: + permissions: + issues: write + pull-requests: write + uses: linuxserver/github-workflows/.github/workflows/issues-cron.yml@v1 + secrets: inherit diff --git a/.github/workflows/external_trigger.yml b/.github/workflows/external_trigger.yml index 0fb1c3e..4531aa6 100644 --- a/.github/workflows/external_trigger.yml +++ b/.github/workflows/external_trigger.yml @@ -3,90 +3,145 @@ name: External Trigger Main on: workflow_dispatch: +permissions: + contents: read + jobs: - external-trigger-main: + external-trigger-develop: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.3 + - uses: linuxserver/github-workflows/.github/actions/checkout@v1 - name: External Trigger - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/develop' + env: + SKIP_EXTERNAL_TRIGGER: ${{ vars.SKIP_EXTERNAL_TRIGGER }} run: | - if [ -n "${{ secrets.PAUSE_EXTERNAL_TRIGGER_MASTODON_MAIN }}" ]; then - echo "**** Github secret PAUSE_EXTERNAL_TRIGGER_MASTODON_MAIN is set; skipping trigger. ****" + printf "# External trigger for docker-mastodon\n\n" >> $GITHUB_STEP_SUMMARY + if grep -q "^mastodon_develop_" <<< "${SKIP_EXTERNAL_TRIGGER}"; then + echo "> [!NOTE]" >> $GITHUB_STEP_SUMMARY + echo "> Github organizational variable \`SKIP_EXTERNAL_TRIGGER\` contains \`mastodon_develop_\`; will skip trigger if version matches." >> $GITHUB_STEP_SUMMARY + elif grep -q "^mastodon_develop" <<< "${SKIP_EXTERNAL_TRIGGER}"; then + echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY + echo "> Github organizational variable \`SKIP_EXTERNAL_TRIGGER\` contains \`mastodon_develop\`; skipping trigger." >> $GITHUB_STEP_SUMMARY + exit 0 + fi + echo "> [!NOTE]" >> $GITHUB_STEP_SUMMARY + echo "> External trigger running off of develop branch. To disable this trigger, add \`mastodon_develop\` into the Github organizational variable \`SKIP_EXTERNAL_TRIGGER\`." >> $GITHUB_STEP_SUMMARY + printf "\n## Retrieving external version\n\n" >> $GITHUB_STEP_SUMMARY + EXT_RELEASE=$(curl -u "${{ secrets.CR_USER }}:${{ secrets.CR_PAT }}" -sX GET "https://api.github.com/repos/mastodon/mastodon/releases" | jq -r '. | first(.[] | select(.prerelease==true)) | .tag_name') + echo "Type is \`custom_json\`" >> $GITHUB_STEP_SUMMARY + if grep -q "^mastodon_develop_${EXT_RELEASE}" <<< "${SKIP_EXTERNAL_TRIGGER}"; then + echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY + echo "> Github organizational variable \`SKIP_EXTERNAL_TRIGGER\` matches current external release; skipping trigger." >> $GITHUB_STEP_SUMMARY exit 0 fi - echo "**** External trigger running off of main branch. To disable this trigger, set a Github secret named \"PAUSE_EXTERNAL_TRIGGER_MASTODON_MAIN\". ****" - echo "**** Retrieving external version ****" - EXT_RELEASE=$(curl -u "${{ secrets.CR_USER }}:${{ secrets.CR_PAT }}" -sX GET "https://api.github.com/repos/mastodon/mastodon/releases/latest" | jq -r '. | .tag_name') if [ -z "${EXT_RELEASE}" ] || [ "${EXT_RELEASE}" == "null" ]; then - echo "**** Can't retrieve external version, exiting ****" - FAILURE_REASON="Can't retrieve external version for mastodon branch main" + echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY + echo "> Can't retrieve external version, exiting" >> $GITHUB_STEP_SUMMARY + FAILURE_REASON="Can't retrieve external version for mastodon branch develop" GHA_TRIGGER_URL="https://github.com/linuxserver/docker-mastodon/actions/runs/${{ github.run_id }}" curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 16711680, "description": "**Trigger Failed** \n**Reason:** '"${FAILURE_REASON}"' \n**Trigger URL:** '"${GHA_TRIGGER_URL}"' \n"}], "username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }} exit 1 fi - EXT_RELEASE=$(echo ${EXT_RELEASE} | sed 's/[~,%@+;:/]//g') - echo "**** External version: ${EXT_RELEASE} ****" - echo "**** Retrieving last pushed version ****" + EXT_RELEASE_SANITIZED=$(echo ${EXT_RELEASE} | sed 's/[~,%@+;:/]//g') + echo "Sanitized external version: \`${EXT_RELEASE_SANITIZED}\`" >> $GITHUB_STEP_SUMMARY + echo "Retrieving last pushed version" >> $GITHUB_STEP_SUMMARY image="linuxserver/mastodon" - tag="latest" + tag="develop" token=$(curl -sX GET \ "https://ghcr.io/token?scope=repository%3Alinuxserver%2Fmastodon%3Apull" \ | jq -r '.token') - multidigest=$(curl -s \ - --header "Accept: application/vnd.docker.distribution.manifest.v2+json" \ - --header "Authorization: Bearer ${token}" \ - "https://ghcr.io/v2/${image}/manifests/${tag}" \ - | jq -r 'first(.manifests[].digest)') - digest=$(curl -s \ + multidigest=$(curl -s \ + --header "Accept: application/vnd.docker.distribution.manifest.v2+json" \ + --header "Accept: application/vnd.oci.image.index.v1+json" \ + --header "Authorization: Bearer ${token}" \ + "https://ghcr.io/v2/${image}/manifests/${tag}") + if jq -e '.layers // empty' <<< "${multidigest}" >/dev/null 2>&1; then + # If there's a layer element it's a single-arch manifest so just get that digest + digest=$(jq -r '.config.digest' <<< "${multidigest}") + else + # Otherwise it's multi-arch or has manifest annotations + if jq -e '.manifests[]?.annotations // empty' <<< "${multidigest}" >/dev/null 2>&1; then + # Check for manifest annotations and delete if found + multidigest=$(jq 'del(.manifests[] | select(.annotations))' <<< "${multidigest}") + fi + if [[ $(jq '.manifests | length' <<< "${multidigest}") -gt 1 ]]; then + # If there's still more than one digest, it's multi-arch + multidigest=$(jq -r ".manifests[] | select(.platform.architecture == \"amd64\").digest?" <<< "${multidigest}") + else + # Otherwise it's single arch + multidigest=$(jq -r ".manifests[].digest?" <<< "${multidigest}") + fi + if digest=$(curl -s \ --header "Accept: application/vnd.docker.distribution.manifest.v2+json" \ + --header "Accept: application/vnd.oci.image.manifest.v1+json" \ --header "Authorization: Bearer ${token}" \ - "https://ghcr.io/v2/${image}/manifests/${multidigest}" \ - | jq -r '.config.digest') + "https://ghcr.io/v2/${image}/manifests/${multidigest}"); then + digest=$(jq -r '.config.digest' <<< "${digest}"); + fi + fi image_info=$(curl -sL \ --header "Authorization: Bearer ${token}" \ - "https://ghcr.io/v2/${image}/blobs/${digest}" \ - | jq -r '.container_config') + "https://ghcr.io/v2/${image}/blobs/${digest}") + if [[ $(echo $image_info | jq -r '.container_config') == "null" ]]; then + image_info=$(echo $image_info | jq -r '.config') + else + image_info=$(echo $image_info | jq -r '.container_config') + fi IMAGE_RELEASE=$(echo ${image_info} | jq -r '.Labels.build_version' | awk '{print $3}') IMAGE_VERSION=$(echo ${IMAGE_RELEASE} | awk -F'-ls' '{print $1}') if [ -z "${IMAGE_VERSION}" ]; then - echo "**** Can't retrieve last pushed version, exiting ****" - FAILURE_REASON="Can't retrieve last pushed version for mastodon tag latest" + echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY + echo "Can't retrieve last pushed version, exiting" >> $GITHUB_STEP_SUMMARY + FAILURE_REASON="Can't retrieve last pushed version for mastodon tag develop" curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 16711680, "description": "**Trigger Failed** \n**Reason:** '"${FAILURE_REASON}"' \n"}], "username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }} exit 1 fi - echo "**** Last pushed version: ${IMAGE_VERSION} ****" - if [ "${EXT_RELEASE}" == "${IMAGE_VERSION}" ]; then - echo "**** Version ${EXT_RELEASE} already pushed, exiting ****" + echo "Last pushed version: \`${IMAGE_VERSION}\`" >> $GITHUB_STEP_SUMMARY + if [ "${EXT_RELEASE_SANITIZED}" == "${IMAGE_VERSION}" ]; then + echo "Sanitized version \`${EXT_RELEASE_SANITIZED}\` already pushed, exiting" >> $GITHUB_STEP_SUMMARY exit 0 - elif [ $(curl -s https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-mastodon/job/main/lastBuild/api/json | jq -r '.building') == "true" ]; then - echo "**** New version ${EXT_RELEASE} found; but there already seems to be an active build on Jenkins; exiting ****" + elif [ $(curl -s https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-mastodon/job/develop/lastBuild/api/json | jq -r '.building') == "true" ]; then + echo "New version \`${EXT_RELEASE}\` found; but there already seems to be an active build on Jenkins; exiting" >> $GITHUB_STEP_SUMMARY exit 0 else - echo "**** New version ${EXT_RELEASE} found; old version was ${IMAGE_VERSION}. Triggering new build ****" - response=$(curl -iX POST \ - https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-mastodon/job/main/buildWithParameters?PACKAGE_CHECK=false \ - --user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} | grep -i location | sed "s|^[L|l]ocation: \(.*\)|\1|") - echo "**** Jenkins job queue url: ${response%$'\r'} ****" - echo "**** Sleeping 10 seconds until job starts ****" - sleep 10 - buildurl=$(curl -s "${response%$'\r'}api/json" | jq -r '.executable.url') - buildurl="${buildurl%$'\r'}" - echo "**** Jenkins job build url: ${buildurl} ****" - echo "**** Attempting to change the Jenkins job description ****" - curl -iX POST \ - "${buildurl}submitDescription" \ - --user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} \ - --data-urlencode "description=GHA external trigger https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ - --data-urlencode "Submit=Submit" - echo "**** Notifying Discord ****" - TRIGGER_REASON="A version change was detected for mastodon tag latest. Old version:${IMAGE_VERSION} New version:${EXT_RELEASE}" - curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903, - "description": "**Build Triggered** \n**Reason:** '"${TRIGGER_REASON}"' \n**Build URL:** '"${buildurl}display/redirect"' \n"}], - "username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }} + if [[ "${artifacts_found}" == "false" ]]; then + echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY + echo "> New version detected, but not all artifacts are published yet; skipping trigger" >> $GITHUB_STEP_SUMMARY + FAILURE_REASON="New version ${EXT_RELEASE} for mastodon tag develop is detected, however not all artifacts are uploaded to upstream release yet. Will try again later." + curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903, + "description": "**Trigger Failed** \n**Reason:** '"${FAILURE_REASON}"' \n"}], + "username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }} + else + printf "\n## Trigger new build\n\n" >> $GITHUB_STEP_SUMMARY + echo "New sanitized version \`${EXT_RELEASE_SANITIZED}\` found; old version was \`${IMAGE_VERSION}\`. Triggering new build" >> $GITHUB_STEP_SUMMARY + if [[ "${artifacts_found}" == "true" ]]; then + echo "All artifacts seem to be uploaded." >> $GITHUB_STEP_SUMMARY + fi + response=$(curl -iX POST \ + https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-mastodon/job/develop/buildWithParameters?PACKAGE_CHECK=false \ + --user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} | grep -i location | sed "s|^[L|l]ocation: \(.*\)|\1|") + echo "Jenkins [job queue url](${response%$'\r'})" >> $GITHUB_STEP_SUMMARY + echo "Sleeping 10 seconds until job starts" >> $GITHUB_STEP_SUMMARY + sleep 10 + buildurl=$(curl -s "${response%$'\r'}api/json" | jq -r '.executable.url') + buildurl="${buildurl%$'\r'}" + echo "Jenkins job [build url](${buildurl})" >> $GITHUB_STEP_SUMMARY + echo "Attempting to change the Jenkins job description" >> $GITHUB_STEP_SUMMARY + curl -iX POST \ + "${buildurl}submitDescription" \ + --user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} \ + --data-urlencode "description=GHA external trigger https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ + --data-urlencode "Submit=Submit" + echo "**** Notifying Discord ****" + TRIGGER_REASON="A version change was detected for mastodon tag develop. Old version:${IMAGE_VERSION} New version:${EXT_RELEASE_SANITIZED}" + curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903, + "description": "**Build Triggered** \n**Reason:** '"${TRIGGER_REASON}"' \n**Build URL:** '"${buildurl}display/redirect"' \n"}], + "username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }} + fi fi diff --git a/.github/workflows/external_trigger_scheduler.yml b/.github/workflows/external_trigger_scheduler.yml index 5779e81..dbc2a4a 100644 --- a/.github/workflows/external_trigger_scheduler.yml +++ b/.github/workflows/external_trigger_scheduler.yml @@ -2,42 +2,47 @@ name: External Trigger Scheduler on: schedule: - - cron: '01 * * * *' + - cron: '24 * * * *' workflow_dispatch: +permissions: + contents: read + jobs: external-trigger-scheduler: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.3 + - uses: linuxserver/github-workflows/.github/actions/checkout@v1 with: fetch-depth: '0' - name: External Trigger Scheduler run: | - echo "**** Branches found: ****" - git for-each-ref --format='%(refname:short)' refs/remotes - echo "**** Pulling the yq docker image ****" - docker pull ghcr.io/linuxserver/yq - for br in $(git for-each-ref --format='%(refname:short)' refs/remotes) + printf "# External trigger scheduler for docker-mastodon\n\n" >> $GITHUB_STEP_SUMMARY + printf "Found the branches:\n\n%s\n" "$(git for-each-ref --format='- %(refname:lstrip=3)' refs/remotes)" >> $GITHUB_STEP_SUMMARY + for br in $(git for-each-ref --format='%(refname:lstrip=3)' refs/remotes) do - br=$(echo "$br" | sed 's|origin/||g') - echo "**** Evaluating branch ${br} ****" - ls_branch=$(curl -sX GET https://raw.githubusercontent.com/linuxserver/docker-mastodon/${br}/jenkins-vars.yml \ - | docker run --rm -i --entrypoint yq ghcr.io/linuxserver/yq -r .ls_branch) - if [ "$br" == "$ls_branch" ]; then - echo "**** Branch ${br} appears to be live; checking workflow. ****" + if [[ "${br}" == "HEAD" ]]; then + printf "\nSkipping %s.\n" ${br} >> $GITHUB_STEP_SUMMARY + continue + fi + printf "\n## Evaluating \`%s\`\n\n" ${br} >> $GITHUB_STEP_SUMMARY + ls_jenkins_vars=$(curl -sX GET https://raw.githubusercontent.com/linuxserver/docker-mastodon/${br}/jenkins-vars.yml) + ls_branch=$(echo "${ls_jenkins_vars}" | yq -r '.ls_branch') + ls_trigger=$(echo "${ls_jenkins_vars}" | yq -r '.external_type') + if [[ "${br}" == "${ls_branch}" ]] && [[ "${ls_trigger}" != "os" ]]; then + echo "Branch appears to be live and trigger is not os; checking workflow." >> $GITHUB_STEP_SUMMARY if curl -sfX GET https://raw.githubusercontent.com/linuxserver/docker-mastodon/${br}/.github/workflows/external_trigger.yml > /dev/null 2>&1; then - echo "**** Workflow exists. Triggering external trigger workflow for branch ${br} ****." + echo "Triggering external trigger workflow for branch." >> $GITHUB_STEP_SUMMARY curl -iX POST \ -H "Authorization: token ${{ secrets.CR_PAT }}" \ -H "Accept: application/vnd.github.v3+json" \ -d "{\"ref\":\"refs/heads/${br}\"}" \ https://api.github.com/repos/linuxserver/docker-mastodon/actions/workflows/external_trigger.yml/dispatches else - echo "**** Workflow doesn't exist; skipping trigger. ****" + echo "Skipping branch due to no external trigger workflow present." >> $GITHUB_STEP_SUMMARY fi else - echo "**** ${br} appears to be a dev branch; skipping trigger. ****" + echo "Skipping branch due to being detected as dev branch or having no external version." >> $GITHUB_STEP_SUMMARY fi done diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index 36bfed1..470046e 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -2,12 +2,18 @@ name: Greetings on: [pull_request_target, issues] +permissions: + contents: read + jobs: greeting: + permissions: + issues: write + pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/first-interaction@v1 + - uses: linuxserver/github-workflows/.github/actions/first-interaction@v1 with: - issue-message: 'Thanks for opening your first issue here! Be sure to follow the [bug](https://github.com/linuxserver/docker-mastodon/blob/main/.github/ISSUE_TEMPLATE/issue.bug.md) or [feature](https://github.com/linuxserver/docker-mastodon/blob/main/.github/ISSUE_TEMPLATE/issue.feature.md) issue templates!' - pr-message: 'Thanks for opening this pull request! Be sure to follow the [pull request template](https://github.com/linuxserver/docker-mastodon/blob/main/.github/PULL_REQUEST_TEMPLATE.md)!' - repo-token: ${{ secrets.GITHUB_TOKEN }} + issue_message: 'Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.' + pr_message: 'Thanks for opening this pull request! Be sure to follow the [pull request template](https://github.com/linuxserver/docker-mastodon/blob/develop/.github/PULL_REQUEST_TEMPLATE.md)!' + repo_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/package_trigger.yml b/.github/workflows/package_trigger.yml deleted file mode 100644 index bd37516..0000000 --- a/.github/workflows/package_trigger.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Package Trigger Main - -on: - workflow_dispatch: - -jobs: - package-trigger-main: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2.3.3 - - - name: Package Trigger - if: github.ref == 'refs/heads/main' - run: | - if [ -n "${{ secrets.PAUSE_PACKAGE_TRIGGER_MASTODON_MAIN }}" ]; then - echo "**** Github secret PAUSE_PACKAGE_TRIGGER_MASTODON_MAIN is set; skipping trigger. ****" - exit 0 - fi - if [ $(curl -s https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-mastodon/job/main/lastBuild/api/json | jq -r '.building') == "true" ]; then - echo "**** There already seems to be an active build on Jenkins; skipping package trigger ****" - exit 0 - fi - echo "**** Package trigger running off of main branch. To disable, set a Github secret named \"PAUSE_PACKAGE_TRIGGER_MASTODON_MAIN\". ****" - response=$(curl -iX POST \ - https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-mastodon/job/main/buildWithParameters?PACKAGE_CHECK=true \ - --user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} | grep -i location | sed "s|^[L|l]ocation: \(.*\)|\1|") - echo "**** Jenkins job queue url: ${response%$'\r'} ****" - echo "**** Sleeping 10 seconds until job starts ****" - sleep 10 - buildurl=$(curl -s "${response%$'\r'}api/json" | jq -r '.executable.url') - buildurl="${buildurl%$'\r'}" - echo "**** Jenkins job build url: ${buildurl} ****" - echo "**** Attempting to change the Jenkins job description ****" - curl -iX POST \ - "${buildurl}submitDescription" \ - --user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} \ - --data-urlencode "description=GHA package trigger https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ - --data-urlencode "Submit=Submit" diff --git a/.github/workflows/package_trigger_scheduler.yml b/.github/workflows/package_trigger_scheduler.yml index 4a614ef..128414f 100644 --- a/.github/workflows/package_trigger_scheduler.yml +++ b/.github/workflows/package_trigger_scheduler.yml @@ -2,49 +2,102 @@ name: Package Trigger Scheduler on: schedule: - - cron: '31 4 * * 3' + - cron: '35 10 * * 4' workflow_dispatch: +permissions: + contents: read + jobs: package-trigger-scheduler: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.3 + - uses: linuxserver/github-workflows/.github/actions/checkout@v1 with: fetch-depth: '0' - name: Package Trigger Scheduler + env: + SKIP_PACKAGE_TRIGGER: ${{ vars.SKIP_PACKAGE_TRIGGER }} run: | - echo "**** Branches found: ****" - git for-each-ref --format='%(refname:short)' refs/remotes - echo "**** Pulling the yq docker image ****" - docker pull ghcr.io/linuxserver/yq - for br in $(git for-each-ref --format='%(refname:short)' refs/remotes) + printf "# Package trigger scheduler for docker-mastodon\n\n" >> $GITHUB_STEP_SUMMARY + printf "Found the branches:\n\n%s\n" "$(git for-each-ref --format='- %(refname:lstrip=3)' refs/remotes)" >> $GITHUB_STEP_SUMMARY + for br in $(git for-each-ref --format='%(refname:lstrip=3)' refs/remotes) do - br=$(echo "$br" | sed 's|origin/||g') - echo "**** Evaluating branch ${br} ****" - ls_branch=$(curl -sX GET https://raw.githubusercontent.com/linuxserver/docker-mastodon/${br}/jenkins-vars.yml \ - | docker run --rm -i --entrypoint yq ghcr.io/linuxserver/yq -r .ls_branch) - if [ "${br}" == "${ls_branch}" ]; then - echo "**** Branch ${br} appears to be live; checking workflow. ****" - if curl -sfX GET https://raw.githubusercontent.com/linuxserver/docker-mastodon/${br}/.github/workflows/package_trigger.yml > /dev/null 2>&1; then - echo "**** Workflow exists. Triggering package trigger workflow for branch ${br}. ****" - triggered_branches="${triggered_branches}${br} " - curl -iX POST \ - -H "Authorization: token ${{ secrets.CR_PAT }}" \ - -H "Accept: application/vnd.github.v3+json" \ - -d "{\"ref\":\"refs/heads/${br}\"}" \ - https://api.github.com/repos/linuxserver/docker-mastodon/actions/workflows/package_trigger.yml/dispatches - sleep 30 + if [[ "${br}" == "HEAD" ]]; then + printf "\nSkipping %s.\n" ${br} >> $GITHUB_STEP_SUMMARY + continue + fi + printf "\n## Evaluating \`%s\`\n\n" ${br} >> $GITHUB_STEP_SUMMARY + JENKINS_VARS=$(curl -sX GET https://raw.githubusercontent.com/linuxserver/docker-mastodon/${br}/jenkins-vars.yml) + if ! curl -sfX GET https://raw.githubusercontent.com/linuxserver/docker-mastodon/${br}/Jenkinsfile >/dev/null 2>&1; then + echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY + echo "> No Jenkinsfile found. Branch is either deprecated or is an early dev branch." >> $GITHUB_STEP_SUMMARY + skipped_branches="${skipped_branches}${br} " + elif [[ "${br}" == $(yq -r '.ls_branch' <<< "${JENKINS_VARS}") ]]; then + echo "Branch appears to be live; checking workflow." >> $GITHUB_STEP_SUMMARY + README_VARS=$(curl -sX GET https://raw.githubusercontent.com/linuxserver/docker-mastodon/${br}/readme-vars.yml) + if [[ $(yq -r '.project_deprecation_status' <<< "${README_VARS}") == "true" ]]; then + echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY + echo "> Branch appears to be deprecated; skipping trigger." >> $GITHUB_STEP_SUMMARY + skipped_branches="${skipped_branches}${br} " + elif [[ $(yq -r '.skip_package_check' <<< "${JENKINS_VARS}") == "true" ]]; then + echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY + echo "> Skipping branch ${br} due to \`skip_package_check\` being set in \`jenkins-vars.yml\`." >> $GITHUB_STEP_SUMMARY + skipped_branches="${skipped_branches}${br} " + elif grep -q "^mastodon_${br}" <<< "${SKIP_PACKAGE_TRIGGER}"; then + echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY + echo "> Github organizational variable \`SKIP_PACKAGE_TRIGGER\` contains \`mastodon_${br}\`; skipping trigger." >> $GITHUB_STEP_SUMMARY + skipped_branches="${skipped_branches}${br} " + elif [ $(curl -s https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-mastodon/job/${br}/lastBuild/api/json | jq -r '.building' 2>/dev/null) == "true" ]; then + echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY + echo "> There already seems to be an active build on Jenkins; skipping package trigger for ${br}" >> $GITHUB_STEP_SUMMARY + skipped_branches="${skipped_branches}${br} " else - echo "**** Workflow doesn't exist; skipping trigger. ****" + echo "> [!NOTE]" >> $GITHUB_STEP_SUMMARY + echo "> Triggering package trigger for branch ${br}" >> $GITHUB_STEP_SUMMARY + printf "> To disable, add \`mastodon_%s\` into the Github organizational variable \`SKIP_PACKAGE_TRIGGER\`.\n\n" "${br}" >> $GITHUB_STEP_SUMMARY + triggered_branches="${triggered_branches}${br} " + response=$(curl -iX POST \ + https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-mastodon/job/${br}/buildWithParameters?PACKAGE_CHECK=true \ + --user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} | grep -i location | sed "s|^[L|l]ocation: \(.*\)|\1|") + if [[ -z "${response}" ]]; then + echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY + echo "> Jenkins build could not be triggered. Skipping branch." + continue + fi + echo "Jenkins [job queue url](${response%$'\r'})" >> $GITHUB_STEP_SUMMARY + echo "Sleeping 10 seconds until job starts" >> $GITHUB_STEP_SUMMARY + sleep 10 + buildurl=$(curl -s "${response%$'\r'}api/json" | jq -r '.executable.url') + buildurl="${buildurl%$'\r'}" + echo "Jenkins job [build url](${buildurl})" >> $GITHUB_STEP_SUMMARY + echo "Attempting to change the Jenkins job description" >> $GITHUB_STEP_SUMMARY + if ! curl -ifX POST \ + "${buildurl}submitDescription" \ + --user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} \ + --data-urlencode "description=GHA package trigger https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ + --data-urlencode "Submit=Submit"; then + echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY + echo "> Unable to change the Jenkins job description." + fi + sleep 20 fi else - echo "**** ${br} appears to be a dev branch; skipping trigger. ****" + echo "Skipping branch ${br} due to being detected as dev branch." >> $GITHUB_STEP_SUMMARY fi done - echo "**** Package check build(s) triggered for branch(es): ${triggered_branches} ****" - echo "**** Notifying Discord ****" - curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903, - "description": "**Package Check Build(s) Triggered for mastodon** \n**Branch(es):** '"${triggered_branches}"' \n**Build URL:** '"https://ci.linuxserver.io/blue/organizations/jenkins/Docker-Pipeline-Builders%2Fdocker-mastodon/activity/"' \n"}], - "username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }} + if [[ -n "${triggered_branches}" ]] || [[ -n "${skipped_branches}" ]]; then + if [[ -n "${triggered_branches}" ]]; then + NOTIFY_BRANCHES="**Triggered:** ${triggered_branches} \n" + NOTIFY_BUILD_URL="**Build URL:** https://ci.linuxserver.io/blue/organizations/jenkins/Docker-Pipeline-Builders%2Fdocker-mastodon/activity/ \n" + echo "**** Package check build(s) triggered for branch(es): ${triggered_branches} ****" + fi + if [[ -n "${skipped_branches}" ]]; then + NOTIFY_BRANCHES="${NOTIFY_BRANCHES}**Skipped:** ${skipped_branches} \n" + fi + echo "**** Notifying Discord ****" + curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903, + "description": "**Package Check Build(s) for mastodon** \n'"${NOTIFY_BRANCHES}"''"${NOTIFY_BUILD_URL}"'"}], + "username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }} + fi diff --git a/.github/workflows/permissions.yml b/.github/workflows/permissions.yml new file mode 100644 index 0000000..02e1bdb --- /dev/null +++ b/.github/workflows/permissions.yml @@ -0,0 +1,12 @@ +name: Permission check +on: + pull_request_target: + paths: + - '**/run' + - '**/finish' + - '**/check' + - 'root/migrations/*' + +jobs: + permission_check: + uses: linuxserver/github-workflows/.github/workflows/init-svc-executable-permissions.yml@v1 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index 3b3846e..0000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Mark stale issues and pull requests - -on: - schedule: - - cron: "30 1 * * *" - -jobs: - stale: - - runs-on: ubuntu-latest - - steps: - - uses: actions/stale@v3 - with: - stale-issue-message: "This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions." - stale-pr-message: "This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions." - stale-issue-label: 'no-issue-activity' - stale-pr-label: 'no-pr-activity' - days-before-stale: 30 - days-before-close: 365 - exempt-issue-labels: 'awaiting-approval,work-in-progress' - exempt-pr-labels: 'awaiting-approval,work-in-progress' - repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..e9e5fea --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,127 @@ +<!-- DO NOT EDIT THIS FILE MANUALLY --> +<!-- This file is globally distributed to all container image projects from https://github.com/linuxserver/docker-jenkins-builder --> +# AGENTS.md - LinuxServer.io container image repository + +This file is for AI coding agents (and the humans driving them) working in a LinuxServer.io `docker-*` image repository. Read it fully before proposing or making any change. + +We welcome contributions, including AI-assisted ones, but this is a volunteer-run project that ships 150+ images to millions of users from one shared template. A change that looks like an improvement in isolation is often wrong for us. When this file and your instincts disagree, this file wins. When this file is silent, copy what the surrounding code already does. + +## 1. Decide where the change belongs before writing any code + +Our images are built for **broad consumption**. Every package, env var and init step we add is something we have to maintain, rebuild weekly and support forever, for every user, whether they use it or not. We do not ship Swiss Army Knife images. Work down this list and stop at the first match: + +1. **It is a bug or feature in the application itself** (not in our packaging): it belongs upstream with the app's developers. Do not patch, fork or work around upstream application behaviour in the image. +2. **It is an unsupported or reasonable-endeavours environment** (Podman, k8s, Portainer, Watchtower, NFS/SMB `/config`, LXC, custom entrypoints, etc. See the [Support Policy](https://docs.linuxserver.io/misc/support-policy/)): we will not add logic to the image to accommodate it. +3. **It only matters to one user or one setup**: use a private [custom script](https://docs.linuxserver.io/general/container-customization/#custom-scripts) in `/custom-cont-init.d` or [custom service](https://docs.linuxserver.io/general/container-customization/#custom-services) in `/custom-services.d`. No PR needed. +4. **It is useful to a subset of users** (an extra package, plugin dependency, alternative UI, hardware driver, third party integration, extra daemon, niche toggle): it is a **[Docker Mod](https://github.com/linuxserver/docker-mods)**, not a change to this repo. Check whether one already exists first (`universal-*` mods work on every image; `<image>-*` mods are image specific). If not, create one from the template in the docker-mods repo; each mod lives on its own branch there. +5. **The large majority of this image's users benefit, or the image is actually broken**: a PR to this repo is appropriate. Examples: the app fails to start, a new upstream release needs a new runtime dependency, a base image rebase, a permissions bug, a wrong default, incorrect docs in `readme-vars.yml`. + +If you are an agent and the requested change lands on 1-4, **stop and tell your operator** where it belongs instead of writing the PR. "It is only a few lines" is not a reason to put it in the image. If in doubt, a human should open an issue or ask in `#contibutor-discussion` on [Discord](https://linuxserver.io/discord) before doing the work. + +### If it is a mod + +Mods are the pressure valve that keeps the images small. Roughly what lives there today, and therefore does **not** belong in an image: extra OS/pip packages and language toolchains, GPU/hardware driver stacks, alternative web UIs and themes, third party plugins and scanners, integrations with external services (Cloudflare, CrowdSec, Apprise, GeoIP, VPN providers), Docker socket automation, sidecar daemons (redis, tunnels), post-processing scripts, and env-var-to-config-file shims. + +- Follow the README and `template` branch in [docker-mods](https://github.com/linuxserver/docker-mods). A mod is a `FROM scratch` single layer of files extracted over `/` at container start, wired into s6 as `init-mod-<image>-<mod>-*` / `svc-mod-<image>-<mod>` units. +- Mods never call `apk`/`apt`/`pip` directly; they append to `/mod-repo-packages-to-install.list` or `/mod-pip-packages-to-install.list` and let the base image do one batched install. Handle Alpine and Ubuntu package names where the mod is universal. +- Most good mods are a 10-40 line script. If yours is not, reconsider the approach. +- A mod is also the proving ground. If a mod becomes something nearly everyone uses, the team may absorb it into the image later and turn the mod into a no-op with a deprecation notice. That is the team's call, not a reason to skip the mod step. + +## 2. Repository layout and what you must not edit + +| Path | Notes | +| --- | --- | +| `Dockerfile`, `Dockerfile.aarch64` (sometimes `Dockerfile.riscv64`) | One per architecture. **Any change must be replicated to all of them.** They normally differ only in base image tag and arch strings. | +| `root/` | Copied to `/` in the image. s6-overlay v3 services live in `root/etc/s6-overlay/s6-rc.d/`, defaults in `root/defaults/`, one-time upgrade steps in `root/migrations/`. | +| `readme-vars.yml` | **Source of truth for the README, docs site, Unraid template and changelog.** Edit this. | +| `jenkins-vars.yml` | Build pipeline variables (version detection, CI test settings). Rarely needs touching. | +| `README.md` | **Generated. Never edit.** | +| `Jenkinsfile` | **Generated. Never edit.** | +| `package_versions.txt` | **Generated by CI. Never edit.** | +| `.github/**`, `.editorconfig`, `LICENSE`, `AGENTS.md` | **Generated / globally distributed. Never edit here.** Changes go to [docker-jenkins-builder](https://github.com/linuxserver/docker-jenkins-builder). | + +Do not add new top level files or tooling: no `docker-compose.yml`, `Makefile`, test suites, linter configs, pre-commit hooks, extra workflows, `CHANGELOG.md`, `SECURITY.md`, devcontainers, or helper scripts. The repo is intentionally small. + +Some repos have multiple live branches that publish different tags (`nightly`, `develop`, `libtorrentv1`, etc.). Each is maintained independently. Target the branch the change applies to, never merge one into another, and do not assume `master` or `main` is the only one that matters. + +## 3. Code style: keep it simple, match what is there + +The goal of every image is the thinnest possible layer between our base image and the upstream app: install it, drop a sane default config into `/config` on first run, fix permissions, start it. Prefer deleting logic to adding it. The base image already handles PUID/PGID, `UMASK`, `TZ`, `FILE__` secrets, mods, custom scripts, cron and device permissions; never reimplement those. + +### Dockerfiles + +- Base is always `ghcr.io/linuxserver/baseimage-*`. Do not change distro, switch to upstream/distroless images, or add multi-stage complexity unless a maintainer asked for it. Base image rebases are done by the team. +- Follow the existing shape exactly: a single `RUN` chain joined with `&& \`, each step announced with `echo "**** doing thing ****"`, two space indentation, a `**** cleanup ****` step at the end removing `/tmp/*` and package caches. +- Packages are listed **one per line in alphabetical order**. Build-only dependencies go in a `build-dependencies` virtual package (Alpine) or are purged (Ubuntu) in the same layer. +- Do not hardcode or pin the application version. Keep the `if [ -z ${APP_VERSION+x} ]; then ...` pattern; CI supplies the version as a build arg and `jenkins-vars.yml` defines how it is detected. +- Do not add `HEALTHCHECK`, `USER`, `ENTRYPOINT` or `CMD`. The base image owns init (`/init`), and the container must start as root unless the image already documents non-root support. +- Do not touch the `LABEL maintainer` or `build_version` lines. + +### Init scripts and services (`root/etc/s6-overlay/s6-rc.d/`) + +- Naming: `init-<app>-config` (oneshot) and `svc-<app>` (longrun). Wire them in using empty files in `dependencies.d/` and `user/contents.d/`, exactly as the existing ones do. Oneshots have `type`, `up` (the path to `run`) and `run`. No legacy `cont-init.d` / `services.d`. +- Every script starts with: + + ```bash + #!/usr/bin/with-contenv bash + # shellcheck shell=bash + ``` + +- Bash, four space indentation, `[[ ]]` tests, `"${VAR}"` quoting, short lowercase `#` comments. Scripts must be shellcheck clean. +- Use `lsiown` instead of `chown`, run the app as `abc` via `s6-setuidgid abc`, and `exec` the final process so s6 supervises it. Keep `s6-notifyoncheck` readiness checks where they exist. +- If `readme-vars.yml` has `nonroot_supported: true` or `readonly_supported: true`, every new privileged operation (chown, writing outside `/config` and `/run`, `s6-setuidgid`) must be guarded the same way the existing code does it (`if [[ -z ${LSIO_NON_ROOT_USER} ]]; then` etc.). Do not break those modes. +- User data and config live in `/config`. Copy defaults only if the file does not already exist; never overwrite user config on startup. If an existing user's config must change, add a numbered script in `root/migrations/`. +- Avoid recursive `lsiown` on large data paths (media, downloads); it makes startup take minutes for real users. +- New environment variables are a last resort. If the app can be configured through its own config file or UI, that is the answer. We do not wrap app settings in env vars. + +## 4. Documentation and changelog + +- All user-facing docs changes go in `readme-vars.yml` (`app_setup_block`, `param_env_vars`, `opt_param_*`, etc.). Reference: [`_container-vars-blank`](https://github.com/linuxserver/docker-jenkins-builder/blob/master/ansible/vars/_container-vars-blank). +- Any change to a Dockerfile or to anything under `root/` needs a new entry at the **top** of `changelogs:` in `readme-vars.yml`, one short factual line: + + ```yaml + - {date: "DD.MM.YY:", desc: "Add libfoo to fix thumbnail generation."} + ``` + +- Optionally regenerate the templated files to check your vars render (see the [jenkins-builder README](https://github.com/linuxserver/docker-jenkins-builder#running-against-local-project)), but do not hand edit the output. + +## 5. Test it for real + +A change that has not been built and run is not ready. At minimum: + +```bash +docker build --no-cache --pull -t lscr.io/linuxserver/<app>:test . +docker run --rm -e PUID=1000 -e PGID=1000 -e TZ=Etc/UTC -v "$(pwd)/testconfig:/config" -p <port>:<port> lscr.io/linuxserver/<app>:test +``` + +Confirm the init completes (`[ls.io-init] done.`), the app comes up, and it survives a restart against an **existing** `/config`, not just a fresh one. If you touched the aarch64 Dockerfile with anything arch specific, build that too (`lscr.io/linuxserver/qemu-static`). If you, the agent, cannot run Docker, say so plainly in your output; do not claim testing that did not happen. + +## 6. Pull requests + +- **Disclose AI use.** If any part of the PR (code, description, or the investigation behind it) was produced with an AI tool, say so in the PR description: which tool, and what it was used for. Agents: add this line yourself, do not leave it to the operator. Undisclosed AI-generated PRs will be closed. Disclosure does not count against a PR; a human who cannot explain their own PR does. +- **A human is accountable.** The person opening the PR must have read and understood every line, built and run the image, and be able to answer review questions in their own words. Do not paste maintainer questions into a chatbot and paste the answers back. Fully autonomous agents must not open PRs or issues on our repos. +- **One focused change per PR.** The smallest diff that fixes the problem. No drive-by refactors, reformatting, comment rewording, "modernisation", dependency shuffling, or fixes for things nobody reported. +- **No typo / wording-only PRs.** Open an issue instead and we will sort it out. +- **Finish before you open.** Do not open drafts and iterate in public with a stream of fixup commits. +- **Fill in the PR template honestly**, keep its structure, and tick the contributing checkbox only if it is true. Description, benefit to the wider userbase, how it was tested (real commands, real output), and links. Write it short and plain: no generated summaries, emoji headers, or bullet lists restating the diff. +- Reference the issue with `closes #<number>` when there is one. For anything non trivial, there should be an human-submitted issue or Discord discussion first. +- Commit messages are short, plain, imperative sentences (`Add libfoo for thumbnail support`). No conventional-commit prefixes, no emoji. +- A PR is a proposal; it may be declined even if it works. The most common reason is section 1 of this file. + +## 7. Issues + +- GitHub issues are for reproducible bugs in **our image** and for feature requests. +- Agents must not file issues on a user's behalf from a guess. An issue needs a real reproduction on the latest image, with mods and custom scripts disabled, the compose/run command and full container logs from startup, using the issue template. +- Do not submit AI-generated root cause analyses or "security audits" of the image as issues. Scanner output about CVEs in upstream or distro packages is not actionable; images are rebuilt regularly to pull in distro fixes. +- Support questions must always be submitted by a human and go to [Discord](https://linuxserver.io/discord) or the [forum](https://github.com/orgs/linuxserver/discussions); see [how to get support](https://docs.linuxserver.io/general/how-to-get-support/). + +## 8. Quick self check before you finish + +- [ ] This change benefits most users of this image, and is not a mod, custom script, or upstream issue. +- [ ] Only hand-maintained files were edited (`Dockerfile*`, `root/**`, `readme-vars.yml`, rarely `jenkins-vars.yml`). +- [ ] Every Dockerfile variant got the same change; packages are alphabetical. +- [ ] Style matches the neighbouring code; shebang and shellcheck directive present; non-root / read-only guards preserved. +- [ ] Changelog entry added at the top of `changelogs:` with today's date as `DD.MM.YY:`. +- [ ] Image was built and run, including against an existing `/config`. +- [ ] The diff contains nothing the task did not require. +- [ ] PR description discloses AI use and a human has reviewed everything. diff --git a/Dockerfile b/Dockerfile index 56e3216..616c1ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,64 +1,114 @@ -FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.15 +# syntax=docker/dockerfile:1 + +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.24 ARG BUILD_DATE ARG VERSION ARG MASTODON_VERSION LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" -LABEL maintainer="TheSpad" +LABEL maintainer="thespad" ENV RAILS_ENV="production" \ NODE_ENV="production" \ - PATH="${PATH}:/opt/ruby/bin:/opt/node/bin:/app/www/bin" + PATH="${PATH}:/app/www/bin" \ + S6_STAGE2_HOOK="/init-hook" \ + MASTODON_USE_LIBVIPS="true" RUN \ - apk add -U --upgrade --no-cache \ + apk add --no-cache \ ffmpeg \ file \ - icu-libs \ - imagemagick \ + gmp \ + libffi \ libpq \ libidn \ nodejs \ - ruby \ - ruby-bundler \ - yarn && \ + vips \ + vips-heif \ + yaml && \ apk add --no-cache --virtual=build-dependencies \ build-base \ - g++ \ - gcc \ + crane \ icu-dev \ - libidn-dev \ + libidn-dev \ libpq-dev \ libxml2-dev \ libxslt-dev \ - openssl-dev \ + linux-headers \ npm \ - ruby-dev && \ + openssl-dev \ + vips-dev \ + yaml-dev && \ echo "**** install mastodon ****" && \ mkdir -p /app/www && \ if [ -z ${MASTODON_VERSION+x} ]; then \ - MASTODON_VERSION=$(curl -sX GET "https://api.github.com/repos/mastodon/mastodon/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ + MASTODON_VERSION=$(curl -sX GET "https://api.github.com/repos/mastodon/mastodon/releases" \ + | jq -r 'first(.[] | select(.prerelease==true)) | .tag_name'); \ fi && \ curl -s -o \ /tmp/mastodon.tar.gz -L \ - "https://github.com/mastodon/mastodon/archive/refs/tags/${MASTODON_VERSION}.tar.gz" && \ + "https://github.com/mastodon/mastodon/archive/${MASTODON_VERSION}.tar.gz" && \ tar xf \ /tmp/mastodon.tar.gz -C \ /app/www/ --strip-components=1 && \ + echo "**** install ruby ****" && \ + RUBY_VERSION=$(cat /app/www/.ruby-version) && \ + ALPINE_VERSION=$(cat /etc/os-release | grep "VERSION_ID" | grep -oE "[[:digit:]]+.[[:digit:]]+") && \ + crane export --platform linux/amd64 library/ruby:${RUBY_VERSION}-alpine${ALPINE_VERSION} - | tar -xv -C / usr/local/ && \ cd /app/www && \ bundle config set --local deployment 'true' && \ - bundle config set --local without 'development test' && \ + bundle config set --local without 'development test exclude' && \ bundle config set silence_root_warning true && \ - bundle install -j"$(nproc)" && \ - yarn install --pure-lockfile && \ - OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile && \ + bundle install -j"$(nproc)" --no-cache && \ + npm install -g corepack && \ + corepack enable && \ + yarn workspaces focus --production @mastodon/mastodon && \ + ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=precompile_placeholder \ + ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=precompile_placeholder \ + ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY=precompile_placeholder \ + OTP_SECRET=precompile_placeholder \ + SECRET_KEY_BASE=precompile_placeholder \ + bundle exec rails assets:precompile && \ + bundle exec bootsnap precompile --gemfile app/ lib/ && \ + rm -rf /app/www/node_modules && \ + cd streaming && \ + yarn workspaces focus --production @mastodon/streaming && \ + printf "Linuxserver.io version: ${VERSION}\nBuild-date: ${BUILD_DATE}" > /build_version && \ echo "**** cleanup ****" && \ + yarn cache clean && \ apk del --purge \ build-dependencies && \ - yarn cache clean && \ + # Remove assets not needed in runtime because they were compiled & copied to public + rm -r \ + /app/www/app/javascript/fonts \ + /app/www/app/javascript/icons \ + /app/www/app/javascript/styles && \ rm -rf \ - /tmp/* + # Remove vendored sources for building native extensions. + /app/www/vendor/bundle/ruby/*/gems/hiredis-*/vendor/hiredis \ + /app/www/vendor/bundle/ruby/*/gems/nokogiri-*/gumbo-parser \ + /app/www/vendor/bundle/ruby/*/gems/nokogiri-*/patches \ + /app/www/vendor/bundle/ruby/*/gems/pghero-*/app/assets \ + # Remove build logs, temp files, and cache. + /app/www/vendor/bundle/ruby/*/build_info/ \ + /app/www/vendor/bundle/ruby/*/cache/ \ + /app/www/tmp/cache \ + $HOME/.bundle/cache \ + $HOME/.composer \ + /tmp/* && \ + find /app/www/vendor/bundle/ruby/*/extensions/ \( -name gem_make.out -o -name mkmf.log \) -delete && \ + # Remove tests, documentations and other useless files. + find /app/www/vendor/bundle/ruby/*/gems/ \( -name 'doc' \ + -o -name 'spec' \ + -o -name 'test' \) \ + -type d -maxdepth 2 -exec rm -fr "{}" + && \ + find /app/www/vendor/bundle/ruby/*/gems/ \( -name 'README*' \ + -o -name 'CHANGELOG*' \ + -o -name 'CONTRIBUT*' \ + -o -name '*LICENSE*' \ + -o -name 'Rakefile' \ + -o -name '.*' \) \ + -type f -delete COPY root/ / diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 6dbf5b9..d1c5ad4 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -1,67 +1,116 @@ -FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.15 +# syntax=docker/dockerfile:1 + +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.24 ARG BUILD_DATE ARG VERSION ARG MASTODON_VERSION LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" -LABEL maintainer="TheSpad" +LABEL maintainer="thespad" ENV RAILS_ENV="production" \ NODE_ENV="production" \ - PATH="${PATH}:/opt/ruby/bin:/opt/node/bin:/app/www/bin" + PATH="${PATH}:/app/www/bin" \ + S6_STAGE2_HOOK="/init-hook" \ + MASTODON_USE_LIBVIPS="true" RUN \ - apk add -U --upgrade --no-cache \ + apk add --no-cache \ ffmpeg \ file \ - icu-libs \ - imagemagick \ + gcompat \ + gmp \ + libffi \ libpq \ libidn \ nodejs \ - ruby \ - ruby-bundler \ - yarn && \ + vips \ + vips-heif \ + yaml && \ apk add --no-cache --virtual=build-dependencies \ build-base \ - g++ \ - gcc \ - gcompat \ + crane \ icu-dev \ - libidn-dev \ + libidn-dev \ libpq-dev \ libxml2-dev \ libxslt-dev \ - openssl-dev \ + linux-headers \ npm \ + openssl-dev \ python3-dev \ - ruby-dev && \ + vips-dev \ + yaml-dev && \ echo "**** install mastodon ****" && \ mkdir -p /app/www && \ if [ -z ${MASTODON_VERSION+x} ]; then \ - MASTODON_VERSION=$(curl -sX GET "https://api.github.com/repos/mastodon/mastodon/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ + MASTODON_VERSION=$(curl -sX GET "https://api.github.com/repos/mastodon/mastodon/releases" \ + | jq -r 'first(.[] | select(.prerelease==true)) | .tag_name'); \ fi && \ curl -s -o \ /tmp/mastodon.tar.gz -L \ - "https://github.com/mastodon/mastodon/archive/refs/tags/${MASTODON_VERSION}.tar.gz" && \ + "https://github.com/mastodon/mastodon/archive/${MASTODON_VERSION}.tar.gz" && \ tar xf \ /tmp/mastodon.tar.gz -C \ /app/www/ --strip-components=1 && \ + echo "**** install ruby ****" && \ + RUBY_VERSION=$(cat /app/www/.ruby-version) && \ + ALPINE_VERSION=$(cat /etc/os-release | grep "VERSION_ID" | grep -oE "[[:digit:]]+.[[:digit:]]+") && \ + crane export --platform linux/arm64 library/ruby:${RUBY_VERSION}-alpine${ALPINE_VERSION} - | tar -xv -C / usr/local/ && \ cd /app/www && \ - gem install nokogiri --platform=ruby -- --use-system-libraries && \ bundle config set --local deployment 'true' && \ - bundle config set --local without 'development test' && \ + bundle config set --local without 'development test exclude' && \ bundle config set silence_root_warning true && \ - bundle install -j"$(nproc)" && \ - yarn install --pure-lockfile && \ - OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile && \ + bundle install -j"$(nproc)" --no-cache && \ + npm install -g corepack && \ + corepack enable && \ + yarn workspaces focus --production @mastodon/mastodon && \ + ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=precompile_placeholder \ + ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=precompile_placeholder \ + ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY=precompile_placeholder \ + OTP_SECRET=precompile_placeholder \ + SECRET_KEY_BASE=precompile_placeholder \ + bundle exec rails assets:precompile && \ + bundle exec bootsnap precompile --gemfile app/ lib/ && \ + rm -rf /app/www/node_modules && \ + cd streaming && \ + yarn workspaces focus --production @mastodon/streaming && \ + printf "Linuxserver.io version: ${VERSION}\nBuild-date: ${BUILD_DATE}" > /build_version && \ echo "**** cleanup ****" && \ + yarn cache clean && \ apk del --purge \ build-dependencies && \ - yarn cache clean && \ + # Remove assets not needed in runtime because they were compiled & copied to public + rm -r \ + /app/www/app/javascript/fonts \ + /app/www/app/javascript/icons \ + /app/www/app/javascript/styles && \ rm -rf \ - /tmp/* + # Remove vendored sources for building native extensions. + /app/www/vendor/bundle/ruby/*/gems/hiredis-*/vendor/hiredis \ + /app/www/vendor/bundle/ruby/*/gems/nokogiri-*/gumbo-parser \ + /app/www/vendor/bundle/ruby/*/gems/nokogiri-*/patches \ + /app/www/vendor/bundle/ruby/*/gems/pghero-*/app/assets \ + # Remove build logs, temp files, and cache. + /app/www/vendor/bundle/ruby/*/build_info/ \ + /app/www/vendor/bundle/ruby/*/cache/ \ + /app/www/tmp/cache \ + $HOME/.bundle/cache \ + $HOME/.composer \ + /tmp/* && \ + find /app/www/vendor/bundle/ruby/*/extensions/ \( -name gem_make.out -o -name mkmf.log \) -delete && \ + # Remove tests, documentations and other useless files. + find /app/www/vendor/bundle/ruby/*/gems/ \( -name 'doc' \ + -o -name 'spec' \ + -o -name 'test' \) \ + -type d -maxdepth 2 -exec rm -fr "{}" + && \ + find /app/www/vendor/bundle/ruby/*/gems/ \( -name 'README*' \ + -o -name 'CHANGELOG*' \ + -o -name 'CONTRIBUT*' \ + -o -name '*LICENSE*' \ + -o -name 'Rakefile' \ + -o -name '.*' \) \ + -type f -delete COPY root/ / diff --git a/Dockerfile.armhf b/Dockerfile.armhf deleted file mode 100644 index a59cd03..0000000 --- a/Dockerfile.armhf +++ /dev/null @@ -1,11 +0,0 @@ -FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm32v7-3.15 - -ARG BUILD_DATE -ARG VERSION -ARG MASTODON_VERSION -LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" -LABEL maintainer="TheSpad" - -# This image does not support armhf - -COPY root/ / diff --git a/Jenkinsfile b/Jenkinsfile index 7dc69f9..6ccb956 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline { } // Input to determine if this is a package check parameters { - string(defaultValue: 'false', description: 'package check run', name: 'PACKAGE_CHECK') + string(defaultValue: 'false', description: 'package check run', name: 'PACKAGE_CHECK') } // Configuration for the variables used for this specific repo environment { @@ -16,7 +16,11 @@ pipeline { GITHUB_TOKEN=credentials('498b4638-2d02-4ce5-832d-8a57d01d97ab') GITLAB_TOKEN=credentials('b6f0f1dd-6952-4cf6-95d1-9c06380283f0') GITLAB_NAMESPACE=credentials('gitlab-namespace-id') - SCARF_TOKEN=credentials('scarf_api_key') + DOCKERHUB_TOKEN=credentials('docker-hub-ci-pat') + QUAYIO_API_TOKEN=credentials('quayio-repo-api-token') + GIT_SIGNING_KEY=credentials('484fbca6-9a4f-455e-b9e3-97ac98785f5f') + JSON_URL='https://api.github.com/repos/mastodon/mastodon/releases' + JSON_PATH='first(.[] | select(.prerelease==true)) | .tag_name' EXT_GIT_BRANCH = 'main' EXT_USER = 'mastodon' EXT_REPO = 'mastodon' @@ -33,19 +37,106 @@ pipeline { CI_WEB='false' CI_PORT='80' CI_SSL='false' - CI_DELAY='120' - CI_DOCKERENV='TZ=US/Pacific' + CI_DELAY='60' + CI_DOCKERENV='' CI_AUTH='' CI_WEBPATH='' } stages { + stage("Set git config"){ + steps{ + sh '''#!/bin/bash + cat ${GIT_SIGNING_KEY} > /config/.ssh/id_sign + chmod 600 /config/.ssh/id_sign + ssh-keygen -y -f /config/.ssh/id_sign > /config/.ssh/id_sign.pub + echo "Using $(ssh-keygen -lf /config/.ssh/id_sign) to sign commits" + git config --global gpg.format ssh + git config --global user.signingkey /config/.ssh/id_sign + git config --global commit.gpgsign true + ''' + } + } + /* ############################ + Bash Function For GHCR Retry + ############################ */ + // Create a reusable script for a ghcr retry bash function + stage("Create Bash Function"){ + steps{ + sh '''#! /bin/bash + # create our retry function + retry_ghcr() { + local max_attempts=7 + local base_delay=10 + local max_delay=90 + local attempt=1 + local errfile exit_code delay pause + errfile=$(mktemp) + while true; do + # run inside an if so a caller's set -e cannot abort before we get to retry + if "$@" 2> >(tee "${errfile}" >&2); then + exit_code=0 + else + exit_code=$? + fi + # make sure tee has finished writing before we read the file + wait $! 2>/dev/null || true + if [[ "${exit_code}" == "0" ]]; then + rm -f "${errfile}" + return 0 + elif ! grep -q -i -E "retry-after:|toomanyrequests|too many requests" "${errfile}"; then + rm -f "${errfile}" + return "${exit_code}" + elif (( attempt >= max_attempts )); then + rm -f "${errfile}" + echo "retry: $* failed after ${attempt} attempts (exit ${exit_code})" >&2 + return "${exit_code}" + else + # exponential delay: base * 2^(attempt-1), capped at max_delay + delay=$(( base_delay * 2 ** (attempt - 1) )) + (( delay > max_delay )) && delay="${max_delay}" + # jitter between half and full delay so parallel builds spread out + pause=$(( delay / 2 + RANDOM % (delay / 2 + 1) )) + echo "retry: attempt ${attempt}/${max_attempts} failed (exit ${exit_code}); waiting ${pause}s..." >&2 + sleep "${pause}" + ((attempt++)) + fi + done + } + + declare -f retry_ghcr > ${WORKSPACE}/retry_ghcr.sh + ''' + } + } // Setup all the basic environment variables needed for the build stage("Set ENV Variables base"){ steps{ + echo "Running on node: ${NODE_NAME}" + sh '''#! /bin/bash + echo "Pruning builder" + docker builder prune -f --builder container || : + containers=$(docker ps -q) + if [[ -n "${containers}" ]]; then + BUILDX_CONTAINER_ID=$(docker ps -qf 'name=buildx_buildkit') + for container in ${containers}; do + if [[ "${container}" == "${BUILDX_CONTAINER_ID}" ]]; then + echo "skipping buildx container in docker stop" + else + echo "Stopping container ${container}" + docker stop ${container} + fi + done + fi + docker system prune -f --volumes || : + docker image prune -af || : + ''' script{ env.EXIT_STATUS = '' + env.CI_TEST_ATTEMPTED = '' + env.PUSH_ATTEMPTED = '' env.LS_RELEASE = sh( - script: '''docker run --rm ghcr.io/linuxserver/alexeiled-skopeo sh -c 'skopeo inspect docker://docker.io/'${DOCKERHUB_IMAGE}':latest 2>/dev/null' | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''', + script: '''#! /bin/bash + source ${WORKSPACE}/retry_ghcr.sh + retry_ghcr docker run --rm quay.io/skopeo/stable:v1 inspect docker://ghcr.io/${LS_USER}/${CONTAINER_NAME}:develop | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''', returnStdout: true).trim() env.LS_RELEASE_NOTES = sh( script: '''cat readme-vars.yml | awk -F \\" '/date: "[0-9][0-9].[0-9][0-9].[0-9][0-9]:/ {print $4;exit;}' | sed -E ':a;N;$!ba;s/\\r{0,1}\\n/\\\\n/g' ''', @@ -56,11 +147,24 @@ pipeline { env.COMMIT_SHA = sh( script: '''git rev-parse HEAD''', returnStdout: true).trim() + env.GH_DEFAULT_BRANCH = sh( + script: '''git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||' ''', + returnStdout: true).trim() env.CODE_URL = 'https://github.com/' + env.LS_USER + '/' + env.LS_REPO + '/commit/' + env.GIT_COMMIT env.DOCKERHUB_LINK = 'https://hub.docker.com/r/' + env.DOCKERHUB_IMAGE + '/tags/' env.PULL_REQUEST = env.CHANGE_ID - env.TEMPLATED_FILES = 'Jenkinsfile README.md LICENSE .editorconfig ./.github/CONTRIBUTING.md ./.github/FUNDING.yml ./.github/ISSUE_TEMPLATE/config.yml ./.github/ISSUE_TEMPLATE/issue.bug.md ./.github/ISSUE_TEMPLATE/issue.feature.md ./.github/PULL_REQUEST_TEMPLATE.md ./.github/workflows/external_trigger_scheduler.yml ./.github/workflows/greetings.yml ./.github/workflows/package_trigger_scheduler.yml ./.github/workflows/stale.yml ./.github/workflows/external_trigger.yml ./.github/workflows/package_trigger.yml' + env.TEMPLATED_FILES = 'Jenkinsfile README.md LICENSE .editorconfig AGENTS.md ./.github/CONTRIBUTING.md ./.github/FUNDING.yml ./.github/ISSUE_TEMPLATE/config.yml ./.github/ISSUE_TEMPLATE/issue.bug.yml ./.github/ISSUE_TEMPLATE/issue.feature.yml ./.github/PULL_REQUEST_TEMPLATE.md ./.github/workflows/external_trigger_scheduler.yml ./.github/workflows/greetings.yml ./.github/workflows/package_trigger_scheduler.yml ./.github/workflows/call_issue_pr_tracker.yml ./.github/workflows/call_issues_cron.yml ./.github/workflows/permissions.yml ./.github/workflows/external_trigger.yml' + if ( env.SYFT_IMAGE_TAG == null ) { + env.SYFT_IMAGE_TAG = 'latest' + } + if ( env.GITLAB_TIMEOUT == null ) { + env.GITLAB_TIMEOUT = '600' + } } + echo "Using syft image tag ${SYFT_IMAGE_TAG}" + echo "Using gitlab registry timeout ${GITLAB_TIMEOUT}" + sh '''#! /bin/bash + echo "The default github branch detected as ${GH_DEFAULT_BRANCH}" ''' script{ env.LS_RELEASE_NUMBER = sh( script: '''echo ${LS_RELEASE} |sed 's/^.*-ls//g' ''', @@ -69,7 +173,7 @@ pipeline { script{ env.LS_TAG_NUMBER = sh( script: '''#! /bin/bash - tagsha=$(git rev-list -n 1 ${LS_RELEASE} 2>/dev/null) + tagsha=$(git rev-list -n 1 develop-${LS_RELEASE} 2>/dev/null) if [ "${tagsha}" == "${COMMIT_SHA}" ]; then echo ${LS_RELEASE_NUMBER} elif [ -z "${GIT_COMMIT}" ]; then @@ -102,21 +206,14 @@ pipeline { /* ######################## External Release Tagging ######################## */ - // If this is a stable github release use the latest endpoint from github to determine the ext tag - stage("Set ENV github_stable"){ + // If this is a custom json endpoint parse the return to get external tag + stage("Set ENV custom_json"){ steps{ script{ env.EXT_RELEASE = sh( - script: '''curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq -r '. | .tag_name' ''', + script: '''curl -s ${JSON_URL} | jq -r ". | ${JSON_PATH}" ''', returnStdout: true).trim() - } - } - } - // If this is a stable or devel github release generate the link for the build message - stage("Set ENV github_link"){ - steps{ - script{ - env.RELEASE_LINK = 'https://github.com/' + env.EXT_USER + '/' + env.EXT_REPO + '/releases/tag/' + env.EXT_RELEASE + env.RELEASE_LINK = env.JSON_URL } } } @@ -125,7 +222,7 @@ pipeline { steps{ script{ env.EXT_RELEASE_CLEAN = sh( - script: '''echo ${EXT_RELEASE} | sed 's/[~,%@+;:/]//g' ''', + script: '''echo ${EXT_RELEASE} | sed 's/[~,%@+;:/ ]//g' ''', returnStdout: true).trim() def semver = env.EXT_RELEASE_CLEAN =~ /(\d+)\.(\d+)\.(\d+)/ @@ -143,7 +240,7 @@ pipeline { } if (env.SEMVER != null) { - if (BRANCH_NAME != "master" && BRANCH_NAME != "main") { + if (BRANCH_NAME != "${env.GH_DEFAULT_BRANCH}") { env.SEMVER = "${env.SEMVER}-${BRANCH_NAME}" } println("SEMVER: ${env.SEMVER}") @@ -154,10 +251,10 @@ pipeline { } } } - // If this is a main build use live docker endpoints + // If this is a develop build use live docker endpoints stage("Set ENV live build"){ when { - branch "main" + branch "develop" environment name: 'CHANGE_ID', value: '' } steps { @@ -167,20 +264,22 @@ pipeline { env.GITLABIMAGE = 'registry.gitlab.com/linuxserver.io/' + env.LS_REPO + '/' + env.CONTAINER_NAME env.QUAYIMAGE = 'quay.io/linuxserver.io/' + env.CONTAINER_NAME if (env.MULTIARCH == 'true') { - env.CI_TAGS = 'amd64-' + env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER + '|arm32v7-' + env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER + '|arm64v8-' + env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER + env.CI_TAGS = 'amd64-develop-' + env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER + '|arm64v8-develop-' + env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER } else { - env.CI_TAGS = env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER + env.CI_TAGS = 'develop-' + env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER } env.VERSION_TAG = env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER - env.META_TAG = env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER - env.EXT_RELEASE_TAG = 'version-' + env.EXT_RELEASE_CLEAN + env.META_TAG = 'develop-' + env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER + env.EXT_RELEASE_TAG = 'develop-version-' + env.EXT_RELEASE_CLEAN + env.BUILDCACHE = 'docker.io/lsiodev/buildcache,registry.gitlab.com/linuxserver.io/docker-jenkins-builder/lsiodev-buildcache,ghcr.io/linuxserver/lsiodev-buildcache,quay.io/linuxserver.io/lsiodev-buildcache' + env.CITEST_IMAGETAG = 'latest' } } } // If this is a dev build use dev docker endpoints stage("Set ENV dev build"){ when { - not {branch "main"} + not {branch "develop"} environment name: 'CHANGE_ID', value: '' } steps { @@ -190,14 +289,16 @@ pipeline { env.GITLABIMAGE = 'registry.gitlab.com/linuxserver.io/' + env.LS_REPO + '/lsiodev-' + env.CONTAINER_NAME env.QUAYIMAGE = 'quay.io/linuxserver.io/lsiodev-' + env.CONTAINER_NAME if (env.MULTIARCH == 'true') { - env.CI_TAGS = 'amd64-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + '|arm32v7-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + '|arm64v8-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + env.CI_TAGS = 'amd64-develop-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + '|arm64v8-develop-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA } else { - env.CI_TAGS = env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + env.CI_TAGS = 'develop-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA } env.VERSION_TAG = env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA - env.META_TAG = env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA - env.EXT_RELEASE_TAG = 'version-' + env.EXT_RELEASE_CLEAN + env.META_TAG = 'develop-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + env.EXT_RELEASE_TAG = 'develop-version-' + env.EXT_RELEASE_CLEAN env.DOCKERHUB_LINK = 'https://hub.docker.com/r/' + env.DEV_DOCKERHUB_IMAGE + '/tags/' + env.BUILDCACHE = 'docker.io/lsiodev/buildcache,registry.gitlab.com/linuxserver.io/docker-jenkins-builder/lsiodev-buildcache,ghcr.io/linuxserver/lsiodev-buildcache,quay.io/linuxserver.io/lsiodev-buildcache' + env.CITEST_IMAGETAG = 'develop' } } } @@ -213,15 +314,17 @@ pipeline { env.GITLABIMAGE = 'registry.gitlab.com/linuxserver.io/' + env.LS_REPO + '/lspipepr-' + env.CONTAINER_NAME env.QUAYIMAGE = 'quay.io/linuxserver.io/lspipepr-' + env.CONTAINER_NAME if (env.MULTIARCH == 'true') { - env.CI_TAGS = 'amd64-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-pr-' + env.PULL_REQUEST + '|arm32v7-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-pr-' + env.PULL_REQUEST + '|arm64v8-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-pr-' + env.PULL_REQUEST + env.CI_TAGS = 'amd64-develop-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + '-pr-' + env.PULL_REQUEST + '|arm64v8-develop-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + '-pr-' + env.PULL_REQUEST } else { - env.CI_TAGS = env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-pr-' + env.PULL_REQUEST + env.CI_TAGS = 'develop-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + '-pr-' + env.PULL_REQUEST } - env.VERSION_TAG = env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-pr-' + env.PULL_REQUEST - env.META_TAG = env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-pr-' + env.PULL_REQUEST - env.EXT_RELEASE_TAG = 'version-' + env.EXT_RELEASE_CLEAN + env.VERSION_TAG = env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + '-pr-' + env.PULL_REQUEST + env.META_TAG = 'develop-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + '-pr-' + env.PULL_REQUEST + env.EXT_RELEASE_TAG = 'develop-version-' + env.EXT_RELEASE_CLEAN env.CODE_URL = 'https://github.com/' + env.LS_USER + '/' + env.LS_REPO + '/pull/' + env.PULL_REQUEST env.DOCKERHUB_LINK = 'https://hub.docker.com/r/' + env.PR_DOCKERHUB_IMAGE + '/tags/' + env.BUILDCACHE = 'docker.io/lsiodev/buildcache,registry.gitlab.com/linuxserver.io/docker-jenkins-builder/lsiodev-buildcache,ghcr.io/linuxserver/lsiodev-buildcache,quay.io/linuxserver.io/lsiodev-buildcache' + env.CITEST_IMAGETAG = 'develop' } } } @@ -238,26 +341,27 @@ pipeline { script{ env.SHELLCHECK_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/shellcheck-result.xml' } - sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-shellcheck/master/checkrun.sh | /bin/bash''' + sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-jenkins-builder/master/checkrun.sh | /bin/bash''' sh '''#! /bin/bash - set -e - docker pull ghcr.io/linuxserver/lsiodev-spaces-file-upload:latest + source ${WORKSPACE}/retry_ghcr.sh + retry_ghcr docker pull ghcr.io/linuxserver/baseimage-alpine:3.23 docker run --rm \ - -e DESTINATION=\"${IMAGE}/${META_TAG}/shellcheck-result.xml\" \ - -e FILE_NAME="shellcheck-result.xml" \ - -e MIMETYPE="text/xml" \ - -v ${WORKSPACE}:/mnt \ - -e SECRET_KEY=\"${S3_SECRET}\" \ - -e ACCESS_KEY=\"${S3_KEY}\" \ - -t ghcr.io/linuxserver/lsiodev-spaces-file-upload:latest \ - python /upload.py''' + -v ${WORKSPACE}:/mnt \ + -e AWS_ACCESS_KEY_ID=\"${S3_KEY}\" \ + -e AWS_SECRET_ACCESS_KEY=\"${S3_SECRET}\" \ + ghcr.io/linuxserver/baseimage-alpine:3.23 s6-envdir -fn -- /var/run/s6/container_environment /bin/bash -c "\ + apk add --no-cache python3 && \ + python3 -m venv /lsiopy && \ + pip install --no-cache-dir -U pip && \ + pip install --no-cache-dir s3cmd && \ + s3cmd put --no-preserve --acl-public -m text/xml /mnt/shellcheck-result.xml s3://ci-tests.linuxserver.io/${IMAGE}/${META_TAG}/shellcheck-result.xml" || :''' } } } // Use helper containers to render templated files stage('Update-Templates') { when { - branch "main" + branch "develop" environment name: 'CHANGE_ID', value: '' expression { env.CONTAINER_NAME != null @@ -267,27 +371,36 @@ pipeline { sh '''#! /bin/bash set -e TEMPDIR=$(mktemp -d) - docker pull ghcr.io/linuxserver/jenkins-builder:latest - docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH=main -v ${TEMPDIR}:/ansible/jenkins ghcr.io/linuxserver/jenkins-builder:latest - # Stage 1 - Jenkinsfile update + source ${WORKSPACE}/retry_ghcr.sh + retry_ghcr docker pull ghcr.io/linuxserver/jenkins-builder:latest + # Cloned repo paths for templating: + # ${TEMPDIR}/docker-${CONTAINER_NAME}: Cloned branch develop of ${LS_USER}/${LS_REPO} for running the jenkins builder on + # ${TEMPDIR}/repo/${LS_REPO}: Cloned branch develop of ${LS_USER}/${LS_REPO} for commiting various templated file changes and pushing back to Github + # ${TEMPDIR}/docs/docker-documentation: Cloned docs repo for pushing docs updates to Github + # ${TEMPDIR}/unraid/docker-templates: Cloned docker-templates repo to check for logos + # ${TEMPDIR}/unraid/templates: Cloned templates repo for commiting unraid template changes and pushing back to Github + git clone --branch develop --depth 1 https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/docker-${CONTAINER_NAME} + docker run --rm -v ${TEMPDIR}/docker-${CONTAINER_NAME}:/tmp -e LOCAL=true -e PUID=$(id -u) -e PGID=$(id -g) ghcr.io/linuxserver/jenkins-builder:latest + echo "Starting Stage 1 - Jenkinsfile update" if [[ "$(md5sum Jenkinsfile | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/Jenkinsfile | awk '{ print $1 }')" ]]; then mkdir -p ${TEMPDIR}/repo git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO} cd ${TEMPDIR}/repo/${LS_REPO} - git checkout -f main + git checkout -f develop cp ${TEMPDIR}/docker-${CONTAINER_NAME}/Jenkinsfile ${TEMPDIR}/repo/${LS_REPO}/ git add Jenkinsfile git commit -m 'Bot Updating Templated Files' - git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git --all + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git develop + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git develop echo "true" > /tmp/${COMMIT_SHA}-${BUILD_NUMBER} - echo "Updating Jenkinsfile" + echo "Updating Jenkinsfile and exiting build, new one will trigger based on commit" rm -Rf ${TEMPDIR} exit 0 else echo "Jenkinsfile is up to date." fi - # Stage 2 - Delete old templates - OLD_TEMPLATES=".github/ISSUE_TEMPLATE.md" + echo "Starting Stage 2 - Delete old templates" + OLD_TEMPLATES=".github/ISSUE_TEMPLATE.md .github/ISSUE_TEMPLATE/issue.bug.md .github/ISSUE_TEMPLATE/issue.feature.md .github/workflows/call_invalid_helper.yml .github/workflows/stale.yml .github/workflows/package_trigger.yml" for i in ${OLD_TEMPLATES}; do if [[ -f "${i}" ]]; then TEMPLATES_TO_DELETE="${i} ${TEMPLATES_TO_DELETE}" @@ -297,20 +410,51 @@ pipeline { mkdir -p ${TEMPDIR}/repo git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO} cd ${TEMPDIR}/repo/${LS_REPO} - git checkout -f main + git checkout -f develop for i in ${TEMPLATES_TO_DELETE}; do git rm "${i}" done git commit -m 'Bot Updating Templated Files' - git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git --all + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git develop + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git develop echo "true" > /tmp/${COMMIT_SHA}-${BUILD_NUMBER} - echo "Deleting old templates" + echo "Deleting old/deprecated templates and exiting build, new one will trigger based on commit" rm -Rf ${TEMPDIR} exit 0 else echo "No templates to delete" fi - # Stage 3 - Update templates + echo "Starting Stage 2.5 - Update init diagram" + if ! grep -q 'init_diagram:' readme-vars.yml; then + echo "Adding the key 'init_diagram' to readme-vars.yml" + sed -i '\\|^#.*changelog.*$|d' readme-vars.yml + sed -i 's|^changelogs:|# init diagram\\ninit_diagram:\\n\\n# changelog\\nchangelogs:|' readme-vars.yml + fi + mkdir -p ${TEMPDIR}/d2 + retry_ghcr docker pull ghcr.io/linuxserver/d2-builder:latest + docker run --rm -v ${TEMPDIR}/d2:/output -e PUID=$(id -u) -e PGID=$(id -g) -e RAW="true" ghcr.io/linuxserver/d2-builder:latest ${CONTAINER_NAME}:develop + ls -al ${TEMPDIR}/d2 + yq -ei ".init_diagram |= load_str(\\"${TEMPDIR}/d2/${CONTAINER_NAME}-develop.d2\\")" readme-vars.yml + if [[ $(md5sum readme-vars.yml | cut -c1-8) != $(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/readme-vars.yml | cut -c1-8) ]]; then + echo "'init_diagram' has been updated. Updating repo and exiting build, new one will trigger based on commit." + mkdir -p ${TEMPDIR}/repo + git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO} + cd ${TEMPDIR}/repo/${LS_REPO} + git checkout -f develop + cp ${WORKSPACE}/readme-vars.yml ${TEMPDIR}/repo/${LS_REPO}/readme-vars.yml + git add readme-vars.yml + git commit -m 'Bot Updating Templated Files' + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git develop + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git develop + echo "true" > /tmp/${COMMIT_SHA}-${BUILD_NUMBER} + echo "Updating templates and exiting build, new one will trigger based on commit" + rm -Rf ${TEMPDIR} + exit 0 + else + echo "false" > /tmp/${COMMIT_SHA}-${BUILD_NUMBER} + echo "Init diagram is unchanged" + fi + echo "Starting Stage 3 - Update templates" CURRENTHASH=$(grep -hs ^ ${TEMPLATED_FILES} | md5sum | cut -c1-8) cd ${TEMPDIR}/docker-${CONTAINER_NAME} NEWHASH=$(grep -hs ^ ${TEMPLATED_FILES} | md5sum | cut -c1-8) @@ -318,41 +462,63 @@ pipeline { mkdir -p ${TEMPDIR}/repo git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO} cd ${TEMPDIR}/repo/${LS_REPO} - git checkout -f main + git checkout -f develop cd ${TEMPDIR}/docker-${CONTAINER_NAME} mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/workflows mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/ISSUE_TEMPLATE cp --parents ${TEMPLATED_FILES} ${TEMPDIR}/repo/${LS_REPO}/ || : + cp --parents readme-vars.yml ${TEMPDIR}/repo/${LS_REPO}/ || : cd ${TEMPDIR}/repo/${LS_REPO}/ if ! grep -q '.jenkins-external' .gitignore 2>/dev/null; then echo ".jenkins-external" >> .gitignore git add .gitignore fi - git add ${TEMPLATED_FILES} + git add readme-vars.yml ${TEMPLATED_FILES} git commit -m 'Bot Updating Templated Files' - git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git --all + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git develop + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git develop echo "true" > /tmp/${COMMIT_SHA}-${BUILD_NUMBER} + echo "Updating templates and exiting build, new one will trigger based on commit" + rm -Rf ${TEMPDIR} + exit 0 else echo "false" > /tmp/${COMMIT_SHA}-${BUILD_NUMBER} + echo "No templates to update" fi - mkdir -p ${TEMPDIR}/gitbook - git clone https://github.com/linuxserver/docker-documentation.git ${TEMPDIR}/gitbook/docker-documentation - if [[ ("${BRANCH_NAME}" == "master") || ("${BRANCH_NAME}" == "main") ]] && [[ (! -f ${TEMPDIR}/gitbook/docker-documentation/images/docker-${CONTAINER_NAME}.md) || ("$(md5sum ${TEMPDIR}/gitbook/docker-documentation/images/docker-${CONTAINER_NAME}.md | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/docker-${CONTAINER_NAME}.md | awk '{ print $1 }')") ]]; then - cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/docker-${CONTAINER_NAME}.md ${TEMPDIR}/gitbook/docker-documentation/images/ - cd ${TEMPDIR}/gitbook/docker-documentation/ - git add images/docker-${CONTAINER_NAME}.md + echo "Starting Stage 4 - External repo updates: Docs, Unraid Template and Readme Sync to Docker Hub" + mkdir -p ${TEMPDIR}/docs + git clone --depth=1 https://github.com/linuxserver/docker-documentation.git ${TEMPDIR}/docs/docker-documentation + if [[ "${BRANCH_NAME}" == "${GH_DEFAULT_BRANCH}" ]] && [[ (! -f ${TEMPDIR}/docs/docker-documentation/docs/images/docker-${CONTAINER_NAME}.md) || ("$(md5sum ${TEMPDIR}/docs/docker-documentation/docs/images/docker-${CONTAINER_NAME}.md | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/docker-${CONTAINER_NAME}.md | awk '{ print $1 }')") ]]; then + cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/docker-${CONTAINER_NAME}.md ${TEMPDIR}/docs/docker-documentation/docs/images/ + cd ${TEMPDIR}/docs/docker-documentation + GH_DOCS_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||') + git add docs/images/docker-${CONTAINER_NAME}.md + echo "Updating docs repo" git commit -m 'Bot Updating Documentation' - git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git --all + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} --rebase + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} || \ + (MAXWAIT="10" && echo "Push to docs failed, trying again in ${MAXWAIT} seconds" && \ + sleep $((RANDOM % MAXWAIT)) && \ + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} --rebase && \ + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH}) + else + echo "Docs update not needed, skipping" fi mkdir -p ${TEMPDIR}/unraid - git clone https://github.com/linuxserver/docker-templates.git ${TEMPDIR}/unraid/docker-templates - git clone https://github.com/linuxserver/templates.git ${TEMPDIR}/unraid/templates + git clone --depth=1 https://github.com/linuxserver/docker-templates.git ${TEMPDIR}/unraid/docker-templates + git clone --depth=1 https://github.com/linuxserver/templates.git ${TEMPDIR}/unraid/templates if [[ -f ${TEMPDIR}/unraid/docker-templates/linuxserver.io/img/${CONTAINER_NAME}-logo.png ]]; then sed -i "s|master/linuxserver.io/img/linuxserver-ls-logo.png|master/linuxserver.io/img/${CONTAINER_NAME}-logo.png|" ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml + elif [[ -f ${TEMPDIR}/unraid/docker-templates/linuxserver.io/img/${CONTAINER_NAME}-icon.png ]]; then + sed -i "s|master/linuxserver.io/img/linuxserver-ls-logo.png|master/linuxserver.io/img/${CONTAINER_NAME}-icon.png|" ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml fi - if [[ ("${BRANCH_NAME}" == "master") || ("${BRANCH_NAME}" == "main") ]] && [[ (! -f ${TEMPDIR}/unraid/templates/unraid/${CONTAINER_NAME}.xml) || ("$(md5sum ${TEMPDIR}/unraid/templates/unraid/${CONTAINER_NAME}.xml | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml | awk '{ print $1 }')") ]]; then + if [[ "${BRANCH_NAME}" == "${GH_DEFAULT_BRANCH}" ]] && [[ (! -f ${TEMPDIR}/unraid/templates/unraid/${CONTAINER_NAME}.xml) || ("$(md5sum ${TEMPDIR}/unraid/templates/unraid/${CONTAINER_NAME}.xml | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml | awk '{ print $1 }')") ]]; then + echo "Updating Unraid template" cd ${TEMPDIR}/unraid/templates/ - if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then + GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||') + if grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then + echo "Image is on the ignore list, and already in the deprecation folder." + elif grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then echo "Image is on the ignore list, marking Unraid template as deprecated" cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/ git add -u unraid/${CONTAINER_NAME}.xml @@ -363,7 +529,42 @@ pipeline { git add unraid/${CONTAINER_NAME}.xml git commit -m 'Bot Updating Unraid Template' fi - git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/templates.git --all + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/templates.git ${GH_TEMPLATES_DEFAULT_BRANCH} --rebase + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/templates.git ${GH_TEMPLATES_DEFAULT_BRANCH} || \ + (MAXWAIT="10" && echo "Push to unraid templates failed, trying again in ${MAXWAIT} seconds" && \ + sleep $((RANDOM % MAXWAIT)) && \ + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/templates.git ${GH_TEMPLATES_DEFAULT_BRANCH} --rebase && \ + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/templates.git ${GH_TEMPLATES_DEFAULT_BRANCH}) + else + echo "No updates to Unraid template needed, skipping" + fi + if [[ "${BRANCH_NAME}" == "${GH_DEFAULT_BRANCH}" ]]; then + if [[ $(cat ${TEMPDIR}/docker-${CONTAINER_NAME}/README.md | wc -m) -gt 25000 ]]; then + echo "Readme is longer than 25,000 characters. Syncing the lite version to Docker Hub" + DH_README_SYNC_PATH="${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/README.lite" + else + echo "Syncing readme to Docker Hub" + DH_README_SYNC_PATH="${TEMPDIR}/docker-${CONTAINER_NAME}/README.md" + fi + if curl -s https://hub.docker.com/v2/namespaces/${DOCKERHUB_IMAGE%%/*}/repositories/${DOCKERHUB_IMAGE##*/}/tags | jq -r '.message' | grep -q 404; then + echo "Docker Hub endpoint doesn't exist. Creating endpoint first." + DH_TOKEN=$(curl -d '{"username":"linuxserverci", "password":"'${DOCKERHUB_TOKEN}'"}' -H "Content-Type: application/json" -X POST https://hub.docker.com/v2/users/login | jq -r '.token') + curl -s \ + -H "Authorization: JWT ${DH_TOKEN}" \ + -H "Content-Type: application/json" \ + -X POST \ + -d '{"name":"'${DOCKERHUB_IMAGE##*/}'", "namespace":"'${DOCKERHUB_IMAGE%%/*}'"}' \ + https://hub.docker.com/v2/repositories/ || : + fi + DH_TOKEN=$(curl -d '{"username":"linuxserverci", "password":"'${DOCKERHUB_TOKEN}'"}' -H "Content-Type: application/json" -X POST https://hub.docker.com/v2/users/login | jq -r '.token') + curl -s \ + -H "Authorization: JWT ${DH_TOKEN}" \ + -H "Content-Type: application/json" \ + -X PATCH \ + -d "{\\"full_description\\":$(jq -Rsa . ${DH_README_SYNC_PATH})}" \ + https://hub.docker.com/v2/repositories/${DOCKERHUB_IMAGE} || : + else + echo "Not the default Github branch. Skipping readme sync to Docker Hub." fi rm -Rf ${TEMPDIR}''' script{ @@ -376,7 +577,7 @@ pipeline { // Exit the build if the Templated files were just updated stage('Template-exit') { when { - branch "main" + branch "develop" environment name: 'CHANGE_ID', value: '' environment name: 'FILES_UPDATED', value: 'true' expression { @@ -389,54 +590,48 @@ pipeline { } } } - /* ####################### - GitLab Mirroring - ####################### */ - // Ping into Gitlab to mirror this repo and have a registry endpoint - stage("GitLab Mirror"){ + // If this is a develop build check the S6 service file perms + stage("Check S6 Service file Permissions"){ when { + branch "develop" + environment name: 'CHANGE_ID', value: '' environment name: 'EXIT_STATUS', value: '' } - steps{ - sh '''curl -H "Content-Type: application/json" -H "Private-Token: ${GITLAB_TOKEN}" -X POST https://gitlab.com/api/v4/projects \ - -d '{"namespace_id":'${GITLAB_NAMESPACE}',\ - "name":"'${LS_REPO}'", - "mirror":true,\ - "import_url":"https://github.com/linuxserver/'${LS_REPO}'.git",\ - "issues_access_level":"disabled",\ - "merge_requests_access_level":"disabled",\ - "repository_access_level":"enabled",\ - "visibility":"public"}' ''' - } + steps { + script{ + sh '''#! /bin/bash + WRONG_PERM=$(find ./ -path "./.git" -prune -o \\( -name "run" -o -name "finish" -o -name "check" \\) -not -perm -u=x,g=x,o=x -print) + if [[ -n "${WRONG_PERM}" ]]; then + echo "The following S6 service files are missing the executable bit; canceling the faulty build: ${WRONG_PERM}" + exit 1 + else + echo "S6 service file perms look good." + fi ''' + } + } } /* ####################### - Scarf.sh package registry + GitLab Mirroring and Quay.io Repo Visibility ####################### */ - // Add package to Scarf.sh and set permissions - stage("Scarf.sh package registry"){ + // Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public + stage("GitLab Mirror and Quay.io Visibility"){ when { - branch "main" environment name: 'EXIT_STATUS', value: '' } steps{ - sh '''#! /bin/bash - set -e - PACKAGE_UUID=$(curl -X GET -H "Authorization: Bearer ${SCARF_TOKEN}" https://scarf.sh/api/v1/organizations/linuxserver-ci/packages | jq -r '.[] | select(.name=="linuxserver/mastodon") | .uuid') - if [ -z "${PACKAGE_UUID}" ]; then - echo "Adding package to Scarf.sh" - curl -sX POST https://scarf.sh/api/v1/organizations/linuxserver-ci/packages \ - -H "Authorization: Bearer ${SCARF_TOKEN}" \ - -H "Content-Type: application/json" \ - -d '{"name":"linuxserver/mastodon",\ - "shortDescription":"example description",\ - "libraryType":"docker",\ - "website":"https://github.com/linuxserver/docker-mastodon",\ - "backendUrl":"https://ghcr.io/linuxserver/mastodon",\ - "publicUrl":"https://lscr.io/linuxserver/mastodon"}' || : - else - echo "Package already exists on Scarf.sh" - fi - ''' + sh '''curl -H "Content-Type: application/json" -H "Private-Token: ${GITLAB_TOKEN}" -X POST https://gitlab.com/api/v4/projects \ + -d '{"namespace_id":'${GITLAB_NAMESPACE}',\ + "name":"'${LS_REPO}'", + "mirror":true,\ + "import_url":"https://github.com/linuxserver/'${LS_REPO}'.git",\ + "issues_access_level":"disabled",\ + "merge_requests_access_level":"disabled",\ + "repository_access_level":"enabled",\ + "visibility":"public"}' ''' + sh '''curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \ + -d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" ''' + sh '''curl -H "Content-Type: application/json" -H "Authorization: Bearer ${QUAYIO_API_TOKEN}" -X POST "https://quay.io/api/v1/repository${QUAYIMAGE/quay.io/}/changevisibility" \ + -d '{"visibility":"public"}' ||: ''' } } /* ############### @@ -452,21 +647,79 @@ pipeline { } steps { echo "Running on node: ${NODE_NAME}" - sh "docker build \ - --label \"org.opencontainers.image.created=${GITHUB_DATE}\" \ - --label \"org.opencontainers.image.authors=linuxserver.io\" \ - --label \"org.opencontainers.image.url=https://github.com/linuxserver/docker-mastodon/packages\" \ - --label \"org.opencontainers.image.documentation=https://docs.linuxserver.io/images/docker-mastodon\" \ - --label \"org.opencontainers.image.source=https://github.com/linuxserver/docker-mastodon\" \ - --label \"org.opencontainers.image.version=${EXT_RELEASE_CLEAN}-ls${LS_TAG_NUMBER}\" \ - --label \"org.opencontainers.image.revision=${COMMIT_SHA}\" \ - --label \"org.opencontainers.image.vendor=linuxserver.io\" \ - --label \"org.opencontainers.image.licenses=GPL-3.0-only\" \ - --label \"org.opencontainers.image.ref.name=${COMMIT_SHA}\" \ - --label \"org.opencontainers.image.title=Mastodon\" \ - --label \"org.opencontainers.image.description=[Mastodon](https://github.com/mastodon/mastodon/) is a free, open-source social network server based on ActivityPub where users can follow friends and discover new ones.. \" \ - --no-cache --pull -t ${IMAGE}:${META_TAG} \ - --build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ." + sh "sed -r -i 's|(^FROM .*)|\\1\\n\\nENV LSIO_FIRST_PARTY=true|g' Dockerfile" + sh '''#! /bin/bash + source ${WORKSPACE}/retry_ghcr.sh + retry_ghcr docker buildx build \ + --label "org.opencontainers.image.created=${GITHUB_DATE}" \ + --label "org.opencontainers.image.authors=linuxserver.io" \ + --label "org.opencontainers.image.url=https://github.com/linuxserver/docker-mastodon/packages" \ + --label "org.opencontainers.image.documentation=https://docs.linuxserver.io/images/docker-mastodon" \ + --label "org.opencontainers.image.source=https://github.com/linuxserver/docker-mastodon" \ + --label "org.opencontainers.image.version=${EXT_RELEASE_CLEAN}-ls${LS_TAG_NUMBER}" \ + --label "org.opencontainers.image.revision=${COMMIT_SHA}" \ + --label "org.opencontainers.image.vendor=linuxserver.io" \ + --label "org.opencontainers.image.licenses=GPL-3.0-only" \ + --label "org.opencontainers.image.ref.name=${COMMIT_SHA}" \ + --label "org.opencontainers.image.title=Mastodon" \ + --label "org.opencontainers.image.description=[Mastodon](https://github.com/mastodon/mastodon/) is a free, open-source social network server based on ActivityPub where users can follow friends and discover new ones.. " \ + --no-cache --pull -t ${IMAGE}:${META_TAG} --platform=linux/amd64 \ + --provenance=true --sbom=true --builder=default --load \ + --build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION="${VERSION_TAG}" --build-arg BUILD_DATE=${GITHUB_DATE} . + ''' + sh '''#! /bin/bash + set -e + IFS=',' read -ra CACHE <<< "$BUILDCACHE" + for i in "${CACHE[@]}"; do + docker tag ${IMAGE}:${META_TAG} ${i}:amd64-${COMMIT_SHA}-${BUILD_NUMBER} + done + ''' + withCredentials([ + [ + $class: 'UsernamePasswordMultiBinding', + credentialsId: 'Quay.io-Robot', + usernameVariable: 'QUAYUSER', + passwordVariable: 'QUAYPASS' + ] + ]) { + retry_backoff(5,5) { + sh '''#! /bin/bash + set -e + # run a registry.gitlab.com command under what is left of the gitlab time budget + gitlab_timeout() { + local remaining=$(( GITLAB_DEADLINE - SECONDS )) + if (( remaining <= 0 )); then + echo "gitlab timeout budget of ${GITLAB_TIMEOUT}s used up, skipping: $*" >&2 + return 124 + fi + timeout "${remaining}" "$@" + } + GITLAB_DEADLINE=$(( SECONDS + GITLAB_TIMEOUT )) + + echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin + echo $GITHUB_TOKEN | docker login ghcr.io -u LinuxServer-CI --password-stdin + echo $GITLAB_TOKEN | docker login registry.gitlab.com -u LinuxServer.io --password-stdin + echo $QUAYPASS | docker login quay.io -u $QUAYUSER --password-stdin + + if [[ "${PACKAGE_CHECK}" != "true" ]]; then + declare -A pids + IFS=',' read -ra CACHE <<< "$BUILDCACHE" + for i in "${CACHE[@]}"; do + if [[ "${i}" == *"registry.gitlab.com"* ]]; then + TIMEOUT_CMD="gitlab_timeout" + else + TIMEOUT_CMD="" + fi + ${TIMEOUT_CMD} docker push ${i}:amd64-${COMMIT_SHA}-${BUILD_NUMBER} & + pids[$!]="$i" + done + for p in "${!pids[@]}"; do + wait "$p" || { if [[ "${pids[$p]}" != *"quay.io"* && "${pids[$p]}" != *"registry.gitlab.com"* ]]; then exit 1; fi; } + done + fi + ''' + } + } } } // Build MultiArch Docker containers for push to LS Repo @@ -482,55 +735,79 @@ pipeline { stage('Build X86') { steps { echo "Running on node: ${NODE_NAME}" - sh "docker build \ - --label \"org.opencontainers.image.created=${GITHUB_DATE}\" \ - --label \"org.opencontainers.image.authors=linuxserver.io\" \ - --label \"org.opencontainers.image.url=https://github.com/linuxserver/docker-mastodon/packages\" \ - --label \"org.opencontainers.image.documentation=https://docs.linuxserver.io/images/docker-mastodon\" \ - --label \"org.opencontainers.image.source=https://github.com/linuxserver/docker-mastodon\" \ - --label \"org.opencontainers.image.version=${EXT_RELEASE_CLEAN}-ls${LS_TAG_NUMBER}\" \ - --label \"org.opencontainers.image.revision=${COMMIT_SHA}\" \ - --label \"org.opencontainers.image.vendor=linuxserver.io\" \ - --label \"org.opencontainers.image.licenses=GPL-3.0-only\" \ - --label \"org.opencontainers.image.ref.name=${COMMIT_SHA}\" \ - --label \"org.opencontainers.image.title=Mastodon\" \ - --label \"org.opencontainers.image.description=[Mastodon](https://github.com/mastodon/mastodon/) is a free, open-source social network server based on ActivityPub where users can follow friends and discover new ones.. \" \ - --no-cache --pull -t ${IMAGE}:amd64-${META_TAG} \ - --build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ." - } - } - stage('Build ARMHF') { - agent { - label 'ARMHF' - } - steps { - echo "Running on node: ${NODE_NAME}" - echo 'Logging into Github' + sh "sed -r -i 's|(^FROM .*)|\\1\\n\\nENV LSIO_FIRST_PARTY=true|g' Dockerfile" sh '''#! /bin/bash - echo $GITHUB_TOKEN | docker login ghcr.io -u LinuxServer-CI --password-stdin + source ${WORKSPACE}/retry_ghcr.sh + retry_ghcr docker buildx build \ + --label "org.opencontainers.image.created=${GITHUB_DATE}" \ + --label "org.opencontainers.image.authors=linuxserver.io" \ + --label "org.opencontainers.image.url=https://github.com/linuxserver/docker-mastodon/packages" \ + --label "org.opencontainers.image.documentation=https://docs.linuxserver.io/images/docker-mastodon" \ + --label "org.opencontainers.image.source=https://github.com/linuxserver/docker-mastodon" \ + --label "org.opencontainers.image.version=${EXT_RELEASE_CLEAN}-ls${LS_TAG_NUMBER}" \ + --label "org.opencontainers.image.revision=${COMMIT_SHA}" \ + --label "org.opencontainers.image.vendor=linuxserver.io" \ + --label "org.opencontainers.image.licenses=GPL-3.0-only" \ + --label "org.opencontainers.image.ref.name=${COMMIT_SHA}" \ + --label "org.opencontainers.image.title=Mastodon" \ + --label "org.opencontainers.image.description=[Mastodon](https://github.com/mastodon/mastodon/) is a free, open-source social network server based on ActivityPub where users can follow friends and discover new ones.. " \ + --no-cache --pull -t ${IMAGE}:amd64-${META_TAG} --platform=linux/amd64 \ + --provenance=true --sbom=true --builder=default --load \ + --build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION="${VERSION_TAG}" --build-arg BUILD_DATE=${GITHUB_DATE} . + ''' + sh '''#! /bin/bash + set -e + IFS=',' read -ra CACHE <<< "$BUILDCACHE" + for i in "${CACHE[@]}"; do + docker tag ${IMAGE}:amd64-${META_TAG} ${i}:amd64-${COMMIT_SHA}-${BUILD_NUMBER} + done ''' - sh "docker build \ - --label \"org.opencontainers.image.created=${GITHUB_DATE}\" \ - --label \"org.opencontainers.image.authors=linuxserver.io\" \ - --label \"org.opencontainers.image.url=https://github.com/linuxserver/docker-mastodon/packages\" \ - --label \"org.opencontainers.image.documentation=https://docs.linuxserver.io/images/docker-mastodon\" \ - --label \"org.opencontainers.image.source=https://github.com/linuxserver/docker-mastodon\" \ - --label \"org.opencontainers.image.version=${EXT_RELEASE_CLEAN}-ls${LS_TAG_NUMBER}\" \ - --label \"org.opencontainers.image.revision=${COMMIT_SHA}\" \ - --label \"org.opencontainers.image.vendor=linuxserver.io\" \ - --label \"org.opencontainers.image.licenses=GPL-3.0-only\" \ - --label \"org.opencontainers.image.ref.name=${COMMIT_SHA}\" \ - --label \"org.opencontainers.image.title=Mastodon\" \ - --label \"org.opencontainers.image.description=[Mastodon](https://github.com/mastodon/mastodon/) is a free, open-source social network server based on ActivityPub where users can follow friends and discover new ones.. \" \ - --no-cache --pull -f Dockerfile.armhf -t ${IMAGE}:arm32v7-${META_TAG} \ - --build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ." - sh "docker tag ${IMAGE}:arm32v7-${META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER}" - retry(5) { - sh "docker push ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER}" + withCredentials([ + [ + $class: 'UsernamePasswordMultiBinding', + credentialsId: 'Quay.io-Robot', + usernameVariable: 'QUAYUSER', + passwordVariable: 'QUAYPASS' + ] + ]) { + retry_backoff(5,5) { + sh '''#! /bin/bash + set -e + # run a registry.gitlab.com command under what is left of the gitlab time budget + gitlab_timeout() { + local remaining=$(( GITLAB_DEADLINE - SECONDS )) + if (( remaining <= 0 )); then + echo "gitlab timeout budget of ${GITLAB_TIMEOUT}s used up, skipping: $*" >&2 + return 124 + fi + timeout "${remaining}" "$@" + } + GITLAB_DEADLINE=$(( SECONDS + GITLAB_TIMEOUT )) + + echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin + echo $GITHUB_TOKEN | docker login ghcr.io -u LinuxServer-CI --password-stdin + echo $GITLAB_TOKEN | docker login registry.gitlab.com -u LinuxServer.io --password-stdin + echo $QUAYPASS | docker login quay.io -u $QUAYUSER --password-stdin + + if [[ "${PACKAGE_CHECK}" != "true" ]]; then + declare -A pids + IFS=',' read -ra CACHE <<< "$BUILDCACHE" + for i in "${CACHE[@]}"; do + if [[ "${i}" == *"registry.gitlab.com"* ]]; then + TIMEOUT_CMD="gitlab_timeout" + else + TIMEOUT_CMD="" + fi + ${TIMEOUT_CMD} docker push ${i}:amd64-${COMMIT_SHA}-${BUILD_NUMBER} & + pids[$!]="$i" + done + for p in "${!pids[@]}"; do + wait "$p" || { if [[ "${pids[$p]}" != *"quay.io"* && "${pids[$p]}" != *"registry.gitlab.com"* ]]; then exit 1; fi; } + done + fi + ''' + } } - sh '''docker rmi \ - ${IMAGE}:arm32v7-${META_TAG} \ - ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} || :''' } } stage('Build ARM64') { @@ -539,32 +816,125 @@ pipeline { } steps { echo "Running on node: ${NODE_NAME}" - echo 'Logging into Github' + sh "sed -r -i 's|(^FROM .*)|\\1\\n\\nENV LSIO_FIRST_PARTY=true|g' Dockerfile.aarch64" + sh '''#! /bin/bash + # create our retry function + retry_ghcr() { + local max_attempts=7 + local base_delay=10 + local max_delay=90 + local attempt=1 + local errfile exit_code delay pause + errfile=$(mktemp) + while true; do + # run inside an if so a caller's set -e cannot abort before we get to retry + if "$@" 2> >(tee "${errfile}" >&2); then + exit_code=0 + else + exit_code=$? + fi + # make sure tee has finished writing before we read the file + wait $! 2>/dev/null || true + if [[ "${exit_code}" == "0" ]]; then + rm -f "${errfile}" + return 0 + elif ! grep -q -i -E "retry-after:|toomanyrequests|too many requests" "${errfile}"; then + rm -f "${errfile}" + return "${exit_code}" + elif (( attempt >= max_attempts )); then + rm -f "${errfile}" + echo "retry: $* failed after ${attempt} attempts (exit ${exit_code})" >&2 + return "${exit_code}" + else + # exponential delay: base * 2^(attempt-1), capped at max_delay + delay=$(( base_delay * 2 ** (attempt - 1) )) + (( delay > max_delay )) && delay="${max_delay}" + # jitter between half and full delay so parallel builds spread out + pause=$(( delay / 2 + RANDOM % (delay / 2 + 1) )) + echo "retry: attempt ${attempt}/${max_attempts} failed (exit ${exit_code}); waiting ${pause}s..." >&2 + sleep "${pause}" + ((attempt++)) + fi + done + } + + retry_ghcr docker buildx build \ + --label "org.opencontainers.image.created=${GITHUB_DATE}" \ + --label "org.opencontainers.image.authors=linuxserver.io" \ + --label "org.opencontainers.image.url=https://github.com/linuxserver/docker-mastodon/packages" \ + --label "org.opencontainers.image.documentation=https://docs.linuxserver.io/images/docker-mastodon" \ + --label "org.opencontainers.image.source=https://github.com/linuxserver/docker-mastodon" \ + --label "org.opencontainers.image.version=${EXT_RELEASE_CLEAN}-ls${LS_TAG_NUMBER}" \ + --label "org.opencontainers.image.revision=${COMMIT_SHA}" \ + --label "org.opencontainers.image.vendor=linuxserver.io" \ + --label "org.opencontainers.image.licenses=GPL-3.0-only" \ + --label "org.opencontainers.image.ref.name=${COMMIT_SHA}" \ + --label "org.opencontainers.image.title=Mastodon" \ + --label "org.opencontainers.image.description=[Mastodon](https://github.com/mastodon/mastodon/) is a free, open-source social network server based on ActivityPub where users can follow friends and discover new ones.. " \ + --no-cache --pull -f Dockerfile.aarch64 -t ${IMAGE}:arm64v8-${META_TAG} --platform=linux/arm64 \ + --provenance=true --sbom=true --builder=default --load \ + --build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION="${VERSION_TAG}" --build-arg BUILD_DATE=${GITHUB_DATE} . + ''' sh '''#! /bin/bash - echo $GITHUB_TOKEN | docker login ghcr.io -u LinuxServer-CI --password-stdin + set -e + IFS=',' read -ra CACHE <<< "$BUILDCACHE" + for i in "${CACHE[@]}"; do + docker tag ${IMAGE}:arm64v8-${META_TAG} ${i}:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} + done ''' - sh "docker build \ - --label \"org.opencontainers.image.created=${GITHUB_DATE}\" \ - --label \"org.opencontainers.image.authors=linuxserver.io\" \ - --label \"org.opencontainers.image.url=https://github.com/linuxserver/docker-mastodon/packages\" \ - --label \"org.opencontainers.image.documentation=https://docs.linuxserver.io/images/docker-mastodon\" \ - --label \"org.opencontainers.image.source=https://github.com/linuxserver/docker-mastodon\" \ - --label \"org.opencontainers.image.version=${EXT_RELEASE_CLEAN}-ls${LS_TAG_NUMBER}\" \ - --label \"org.opencontainers.image.revision=${COMMIT_SHA}\" \ - --label \"org.opencontainers.image.vendor=linuxserver.io\" \ - --label \"org.opencontainers.image.licenses=GPL-3.0-only\" \ - --label \"org.opencontainers.image.ref.name=${COMMIT_SHA}\" \ - --label \"org.opencontainers.image.title=Mastodon\" \ - --label \"org.opencontainers.image.description=[Mastodon](https://github.com/mastodon/mastodon/) is a free, open-source social network server based on ActivityPub where users can follow friends and discover new ones.. \" \ - --no-cache --pull -f Dockerfile.aarch64 -t ${IMAGE}:arm64v8-${META_TAG} \ - --build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ." - sh "docker tag ${IMAGE}:arm64v8-${META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}" - retry(5) { - sh "docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}" + withCredentials([ + [ + $class: 'UsernamePasswordMultiBinding', + credentialsId: 'Quay.io-Robot', + usernameVariable: 'QUAYUSER', + passwordVariable: 'QUAYPASS' + ] + ]) { + retry_backoff(5,5) { + sh '''#! /bin/bash + set -e + # run a registry.gitlab.com command under what is left of the gitlab time budget + gitlab_timeout() { + local remaining=$(( GITLAB_DEADLINE - SECONDS )) + if (( remaining <= 0 )); then + echo "gitlab timeout budget of ${GITLAB_TIMEOUT}s used up, skipping: $*" >&2 + return 124 + fi + timeout "${remaining}" "$@" + } + GITLAB_DEADLINE=$(( SECONDS + GITLAB_TIMEOUT )) + + echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin + echo $GITHUB_TOKEN | docker login ghcr.io -u LinuxServer-CI --password-stdin + echo $GITLAB_TOKEN | docker login registry.gitlab.com -u LinuxServer.io --password-stdin + echo $QUAYPASS | docker login quay.io -u $QUAYUSER --password-stdin + if [[ "${PACKAGE_CHECK}" != "true" ]]; then + declare -A pids + IFS=',' read -ra CACHE <<< "$BUILDCACHE" + for i in "${CACHE[@]}"; do + if [[ "${i}" == *"registry.gitlab.com"* ]]; then + TIMEOUT_CMD="gitlab_timeout" + else + TIMEOUT_CMD="" + fi + ${TIMEOUT_CMD} docker push ${i}:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} & + pids[$!]="$i" + done + for p in "${!pids[@]}"; do + wait "$p" || { if [[ "${pids[$p]}" != *"quay.io"* && "${pids[$p]}" != *"registry.gitlab.com"* ]]; then exit 1; fi; } + done + fi + ''' + } } - sh '''docker rmi \ - ${IMAGE}:arm64v8-${META_TAG} \ - ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} || :''' + sh '''#! /bin/bash + containers=$(docker ps -aq) + if [[ -n "${containers}" ]]; then + docker stop ${containers} + fi + docker system prune -f --volumes || : + docker image prune -af || : + ''' } } } @@ -572,7 +942,7 @@ pipeline { // Take the image we just built and dump package versions for comparison stage('Update-packages') { when { - branch "main" + branch "develop" environment name: 'CHANGE_ID', value: '' environment name: 'EXIT_STATUS', value: '' } @@ -580,42 +950,31 @@ pipeline { sh '''#! /bin/bash set -e TEMPDIR=$(mktemp -d) - if [ "${MULTIARCH}" == "true" ] && [ "${PACKAGE_CHECK}" == "false" ]; then + if [ "${MULTIARCH}" == "true" ] && [ "${PACKAGE_CHECK}" != "true" ]; then LOCAL_CONTAINER=${IMAGE}:amd64-${META_TAG} else LOCAL_CONTAINER=${IMAGE}:${META_TAG} fi - if [ "${DIST_IMAGE}" == "alpine" ]; then - docker run --rm --entrypoint '/bin/sh' -v ${TEMPDIR}:/tmp ${LOCAL_CONTAINER} -c '\ - apk info -v > /tmp/package_versions.txt && \ - sort -o /tmp/package_versions.txt /tmp/package_versions.txt && \ - chmod 777 /tmp/package_versions.txt' - elif [ "${DIST_IMAGE}" == "ubuntu" ]; then - docker run --rm --entrypoint '/bin/sh' -v ${TEMPDIR}:/tmp ${LOCAL_CONTAINER} -c '\ - apt list -qq --installed | sed "s#/.*now ##g" | cut -d" " -f1 > /tmp/package_versions.txt && \ - sort -o /tmp/package_versions.txt /tmp/package_versions.txt && \ - chmod 777 /tmp/package_versions.txt' - elif [ "${DIST_IMAGE}" == "fedora" ]; then - docker run --rm --entrypoint '/bin/sh' -v ${TEMPDIR}:/tmp ${LOCAL_CONTAINER} -c '\ - rpm -qa > /tmp/package_versions.txt && \ - sort -o /tmp/package_versions.txt /tmp/package_versions.txt && \ - chmod 777 /tmp/package_versions.txt' - elif [ "${DIST_IMAGE}" == "arch" ]; then - docker run --rm --entrypoint '/bin/sh' -v ${TEMPDIR}:/tmp ${LOCAL_CONTAINER} -c '\ - pacman -Q > /tmp/package_versions.txt && \ - chmod 777 /tmp/package_versions.txt' - fi + touch ${TEMPDIR}/package_versions.txt + source ${WORKSPACE}/retry_ghcr.sh + retry_ghcr docker pull ghcr.io/anchore/syft:${SYFT_IMAGE_TAG} + docker run --rm \ + -v /var/run/docker.sock:/var/run/docker.sock:ro \ + -v ${TEMPDIR}:/tmp \ + ghcr.io/anchore/syft:${SYFT_IMAGE_TAG} \ + ${LOCAL_CONTAINER} -o table=/tmp/package_versions.txt NEW_PACKAGE_TAG=$(md5sum ${TEMPDIR}/package_versions.txt | cut -c1-8 ) echo "Package tag sha from current packages in buit container is ${NEW_PACKAGE_TAG} comparing to old ${PACKAGE_TAG} from github" if [ "${NEW_PACKAGE_TAG}" != "${PACKAGE_TAG}" ]; then git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/${LS_REPO} - git --git-dir ${TEMPDIR}/${LS_REPO}/.git checkout -f main + git --git-dir ${TEMPDIR}/${LS_REPO}/.git checkout -f develop cp ${TEMPDIR}/package_versions.txt ${TEMPDIR}/${LS_REPO}/ cd ${TEMPDIR}/${LS_REPO}/ wait git add package_versions.txt git commit -m 'Bot Updating Package Versions' - git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git --all + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git develop + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git develop echo "true" > /tmp/packages-${COMMIT_SHA}-${BUILD_NUMBER} echo "Package tag updated, stopping build process" else @@ -633,19 +992,12 @@ pipeline { // Exit the build if the package file was just updated stage('PACKAGE-exit') { when { - branch "main" + branch "develop" environment name: 'CHANGE_ID', value: '' environment name: 'PACKAGE_UPDATED', value: 'true' environment name: 'EXIT_STATUS', value: '' } steps { - sh '''#! /bin/bash - echo "Packages were updated. Cleaning up the image and exiting." - if [ "${MULTIARCH}" == "true" ] && [ "${PACKAGE_CHECK}" == "false" ]; then - docker rmi ${IMAGE}:amd64-${META_TAG} - else - docker rmi ${IMAGE}:${META_TAG} - fi''' script{ env.EXIT_STATUS = 'ABORTED' } @@ -654,7 +1006,7 @@ pipeline { // Exit the build if this is just a package check and there are no changes to push stage('PACKAGECHECK-exit') { when { - branch "main" + branch "develop" environment name: 'CHANGE_ID', value: '' environment name: 'PACKAGE_UPDATED', value: 'false' environment name: 'EXIT_STATUS', value: '' @@ -663,13 +1015,6 @@ pipeline { } } steps { - sh '''#! /bin/bash - echo "There are no package updates. Cleaning up the image and exiting." - if [ "${MULTIARCH}" == "true" ] && [ "${PACKAGE_CHECK}" == "false" ]; then - docker rmi ${IMAGE}:amd64-${META_TAG} - else - docker rmi ${IMAGE}:${META_TAG} - fi''' script{ env.EXIT_STATUS = 'ABORTED' } @@ -691,23 +1036,33 @@ pipeline { ]) { script{ env.CI_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/index.html' + env.CI_JSON_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/report.json' + env.CI_TEST_ATTEMPTED = 'true' } sh '''#! /bin/bash set -e - docker pull ghcr.io/linuxserver/ci:latest + if grep -q 'docker-baseimage' <<< "${LS_REPO}"; then + echo "Detected baseimage, setting LSIO_FIRST_PARTY=true" + if [ -n "${CI_DOCKERENV}" ]; then + CI_DOCKERENV="LSIO_FIRST_PARTY=true|${CI_DOCKERENV}" + else + CI_DOCKERENV="LSIO_FIRST_PARTY=true" + fi + fi + source ${WORKSPACE}/retry_ghcr.sh + retry_ghcr docker pull ghcr.io/linuxserver/ci:${CITEST_IMAGETAG} if [ "${MULTIARCH}" == "true" ]; then - docker pull ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} - docker pull ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} - docker tag ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} ${IMAGE}:arm32v7-${META_TAG} + retry_ghcr docker pull ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} --platform=arm64 docker tag ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} ${IMAGE}:arm64v8-${META_TAG} fi docker run --rm \ --shm-size=1gb \ -v /var/run/docker.sock:/var/run/docker.sock \ -e IMAGE=\"${IMAGE}\" \ - -e DELAY_START=\"${CI_DELAY}\" \ + -e DOCKER_LOGS_TIMEOUT=\"${CI_DELAY}\" \ -e TAGS=\"${CI_TAGS}\" \ -e META_TAG=\"${META_TAG}\" \ + -e RELEASE_TAG=\"develop\" \ -e PORT=\"${CI_PORT}\" \ -e SSL=\"${CI_SSL}\" \ -e BASE=\"${DIST_IMAGE}\" \ @@ -717,9 +1072,11 @@ pipeline { -e WEB_SCREENSHOT=\"${CI_WEB}\" \ -e WEB_AUTH=\"${CI_AUTH}\" \ -e WEB_PATH=\"${CI_WEBPATH}\" \ - -e DO_REGION="ams3" \ - -e DO_BUCKET="lsio-ci" \ - -t ghcr.io/linuxserver/ci:latest \ + -e NODE_NAME=\"${NODE_NAME}\" \ + -e SYFT_IMAGE_TAG=\"${CI_SYFT_IMAGE_TAG:-${SYFT_IMAGE_TAG}}\" \ + -e COMMIT_SHA=\"${COMMIT_SHA}\" \ + -e BUILD_NUMBER=\"${BUILD_NUMBER}\" \ + -t ghcr.io/linuxserver/ci:${CITEST_IMAGETAG} \ python3 test_build.py''' } } @@ -734,54 +1091,44 @@ pipeline { environment name: 'EXIT_STATUS', value: '' } steps { - withCredentials([ - [ - $class: 'UsernamePasswordMultiBinding', - credentialsId: '3f9ba4d5-100d-45b0-a3c4-633fd6061207', - usernameVariable: 'DOCKERUSER', - passwordVariable: 'DOCKERPASS' - ], - [ - $class: 'UsernamePasswordMultiBinding', - credentialsId: 'Quay.io-Robot', - usernameVariable: 'QUAYUSER', - passwordVariable: 'QUAYPASS' - ] - ]) { - retry(5) { - sh '''#! /bin/bash - set -e - echo $DOCKERPASS | docker login -u $DOCKERUSER --password-stdin - echo $GITHUB_TOKEN | docker login ghcr.io -u LinuxServer-CI --password-stdin - echo $GITLAB_TOKEN | docker login registry.gitlab.com -u LinuxServer.io --password-stdin - echo $QUAYPASS | docker login quay.io -u $QUAYUSER --password-stdin - for PUSHIMAGE in "${GITHUBIMAGE}" "${GITLABIMAGE}" "${QUAYIMAGE}" "${IMAGE}"; do - docker tag ${IMAGE}:${META_TAG} ${PUSHIMAGE}:${META_TAG} - docker tag ${PUSHIMAGE}:${META_TAG} ${PUSHIMAGE}:latest - docker tag ${PUSHIMAGE}:${META_TAG} ${PUSHIMAGE}:${EXT_RELEASE_TAG} - if [ -n "${SEMVER}" ]; then - docker tag ${PUSHIMAGE}:${META_TAG} ${PUSHIMAGE}:${SEMVER} - fi - docker push ${PUSHIMAGE}:latest - docker push ${PUSHIMAGE}:${META_TAG} - docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG} - if [ -n "${SEMVER}" ]; then - docker push ${PUSHIMAGE}:${SEMVER} - fi - done - ''' - } + script{ + env.PUSH_ATTEMPTED = 'true' + } + retry_backoff(5,5) { sh '''#! /bin/bash - for DELETEIMAGE in "${GITHUBIMAGE}" "${GITLABIMAGE}" "${QUAYIMAGE}" "${IMAGE}"; do - docker rmi \ - ${DELETEIMAGE}:${META_TAG} \ - ${DELETEIMAGE}:${EXT_RELEASE_TAG} \ - ${DELETEIMAGE}:latest || : + set -e + # run a registry.gitlab.com command under what is left of the gitlab time budget + gitlab_timeout() { + local remaining=$(( GITLAB_DEADLINE - SECONDS )) + if (( remaining <= 0 )); then + echo "gitlab timeout budget of ${GITLAB_TIMEOUT}s used up, skipping: $*" >&2 + return 124 + fi + timeout "${remaining}" "$@" + } + GITLAB_DEADLINE=$(( SECONDS + GITLAB_TIMEOUT )) + + for PUSHIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do + if [[ "${PUSHIMAGE}" == "${GITLABIMAGE}" ]]; then + TIMEOUT_CMD="gitlab_timeout" + else + TIMEOUT_CMD="" + fi + [[ ${PUSHIMAGE%%/*} =~ \\. ]] && PUSHIMAGEPLUS="${PUSHIMAGE}" || PUSHIMAGEPLUS="docker.io/${PUSHIMAGE}" + IFS=',' read -ra CACHE <<< "$BUILDCACHE" + for i in "${CACHE[@]}"; do + if [[ "${PUSHIMAGEPLUS}" == "$(cut -d "/" -f1 <<< ${i})"* ]]; then + CACHEIMAGE=${i} + fi + done + ${TIMEOUT_CMD} docker buildx imagetools create --prefer-index=false -t ${PUSHIMAGE}:${META_TAG} -t ${PUSHIMAGE}:develop -t ${PUSHIMAGE}:${EXT_RELEASE_TAG} ${CACHEIMAGE}:amd64-${COMMIT_SHA}-${BUILD_NUMBER} || \ + { if [[ "${PUSHIMAGE}" != "${QUAYIMAGE}" && "${PUSHIMAGE}" != "${GITLABIMAGE}" ]]; then exit 1; fi; } if [ -n "${SEMVER}" ]; then - docker rmi ${DELETEIMAGE}:${SEMVER} || : + ${TIMEOUT_CMD} docker buildx imagetools create --prefer-index=false -t ${PUSHIMAGE}:${SEMVER} ${CACHEIMAGE}:amd64-${COMMIT_SHA}-${BUILD_NUMBER} || \ + { if [[ "${PUSHIMAGE}" != "${QUAYIMAGE}" && "${PUSHIMAGE}" != "${GITLABIMAGE}" ]]; then exit 1; fi; } fi done - ''' + ''' } } } @@ -792,119 +1139,76 @@ pipeline { environment name: 'EXIT_STATUS', value: '' } steps { - withCredentials([ - [ - $class: 'UsernamePasswordMultiBinding', - credentialsId: '3f9ba4d5-100d-45b0-a3c4-633fd6061207', - usernameVariable: 'DOCKERUSER', - passwordVariable: 'DOCKERPASS' - ], - [ - $class: 'UsernamePasswordMultiBinding', - credentialsId: 'Quay.io-Robot', - usernameVariable: 'QUAYUSER', - passwordVariable: 'QUAYPASS' - ] - ]) { - retry(5) { - sh '''#! /bin/bash - set -e - echo $DOCKERPASS | docker login -u $DOCKERUSER --password-stdin - echo $GITHUB_TOKEN | docker login ghcr.io -u LinuxServer-CI --password-stdin - echo $GITLAB_TOKEN | docker login registry.gitlab.com -u LinuxServer.io --password-stdin - echo $QUAYPASS | docker login quay.io -u $QUAYUSER --password-stdin - if [ "${CI}" == "false" ]; then - docker pull ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} - docker pull ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} - docker tag ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} ${IMAGE}:arm32v7-${META_TAG} - docker tag ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} ${IMAGE}:arm64v8-${META_TAG} + script{ + env.PUSH_ATTEMPTED = 'true' + } + retry_backoff(5,5) { + sh '''#! /bin/bash + set -e + # run a registry.gitlab.com command under what is left of the gitlab time budget + gitlab_timeout() { + local remaining=$(( GITLAB_DEADLINE - SECONDS )) + if (( remaining <= 0 )); then + echo "gitlab timeout budget of ${GITLAB_TIMEOUT}s used up, skipping: $*" >&2 + return 124 fi - for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do - docker tag ${IMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG} - docker tag ${IMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-${META_TAG} - docker tag ${IMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} - docker tag ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-latest - docker tag ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-latest - docker tag ${MANIFESTIMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-latest - docker tag ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} - docker tag ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-${EXT_RELEASE_TAG} - docker tag ${MANIFESTIMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG} - if [ -n "${SEMVER}" ]; then - docker tag ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-${SEMVER} - docker tag ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-${SEMVER} - docker tag ${MANIFESTIMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${SEMVER} - fi - docker push ${MANIFESTIMAGE}:amd64-${META_TAG} - docker push ${MANIFESTIMAGE}:arm32v7-${META_TAG} - docker push ${MANIFESTIMAGE}:arm64v8-${META_TAG} - docker push ${MANIFESTIMAGE}:amd64-latest - docker push ${MANIFESTIMAGE}:arm32v7-latest - docker push ${MANIFESTIMAGE}:arm64v8-latest - docker push ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} - docker push ${MANIFESTIMAGE}:arm32v7-${EXT_RELEASE_TAG} - docker push ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG} - if [ -n "${SEMVER}" ]; then - docker push ${MANIFESTIMAGE}:amd64-${SEMVER} - docker push ${MANIFESTIMAGE}:arm32v7-${SEMVER} - docker push ${MANIFESTIMAGE}:arm64v8-${SEMVER} - fi - docker manifest push --purge ${MANIFESTIMAGE}:latest || : - docker manifest create ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:amd64-latest ${MANIFESTIMAGE}:arm32v7-latest ${MANIFESTIMAGE}:arm64v8-latest - docker manifest annotate ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:arm32v7-latest --os linux --arch arm - docker manifest annotate ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:arm64v8-latest --os linux --arch arm64 --variant v8 - docker manifest push --purge ${MANIFESTIMAGE}:${META_TAG} || : - docker manifest create ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} - docker manifest annotate ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:arm32v7-${META_TAG} --os linux --arch arm - docker manifest annotate ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} --os linux --arch arm64 --variant v8 - docker manifest push --purge ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} || : - docker manifest create ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:arm32v7-${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG} - docker manifest annotate ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:arm32v7-${EXT_RELEASE_TAG} --os linux --arch arm - docker manifest annotate ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG} --os linux --arch arm64 --variant v8 - if [ -n "${SEMVER}" ]; then - docker manifest push --purge ${MANIFESTIMAGE}:${SEMVER} || : - docker manifest create ${MANIFESTIMAGE}:${SEMVER} ${MANIFESTIMAGE}:amd64-${SEMVER} ${MANIFESTIMAGE}:arm32v7-${SEMVER} ${MANIFESTIMAGE}:arm64v8-${SEMVER} - docker manifest annotate ${MANIFESTIMAGE}:${SEMVER} ${MANIFESTIMAGE}:arm32v7-${SEMVER} --os linux --arch arm - docker manifest annotate ${MANIFESTIMAGE}:${SEMVER} ${MANIFESTIMAGE}:arm64v8-${SEMVER} --os linux --arch arm64 --variant v8 - fi - docker manifest push --purge ${MANIFESTIMAGE}:latest - docker manifest push --purge ${MANIFESTIMAGE}:${META_TAG} - docker manifest push --purge ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} - if [ -n "${SEMVER}" ]; then - docker manifest push --purge ${MANIFESTIMAGE}:${SEMVER} - fi + timeout "${remaining}" "$@" + } + GITLAB_DEADLINE=$(( SECONDS + GITLAB_TIMEOUT )) + + for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do + if [[ "${MANIFESTIMAGE}" == "${GITLABIMAGE}" ]]; then + TIMEOUT_CMD="gitlab_timeout" + else + TIMEOUT_CMD="" + fi + if [[ "${MANIFESTIMAGE%%/*}" =~ \\. ]]; then + MANIFESTIMAGEPLUS="${MANIFESTIMAGE}" + else + MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}" + fi + IFS=',' read -ra CACHE <<< "$BUILDCACHE" + for i in "${CACHE[@]}"; do + if [[ "${MANIFESTIMAGEPLUS}" == "$(cut -d "/" -f1 <<< ${i})"* ]]; then + CACHEIMAGE=${i} + fi done - ''' - } - sh '''#! /bin/bash - for DELETEIMAGE in "${GITHUBIMAGE}" "${GITLABIMAGE}" "${QUAYIMAGE}" "${IMAGE}"; do - docker rmi \ - ${DELETEIMAGE}:amd64-${META_TAG} \ - ${DELETEIMAGE}:amd64-latest \ - ${DELETEIMAGE}:amd64-${EXT_RELEASE_TAG} \ - ${DELETEIMAGE}:arm32v7-${META_TAG} \ - ${DELETEIMAGE}:arm32v7-latest \ - ${DELETEIMAGE}:arm32v7-${EXT_RELEASE_TAG} \ - ${DELETEIMAGE}:arm64v8-${META_TAG} \ - ${DELETEIMAGE}:arm64v8-latest \ - ${DELETEIMAGE}:arm64v8-${EXT_RELEASE_TAG} || : + ${TIMEOUT_CMD} docker buildx imagetools create --prefer-index=false -t ${MANIFESTIMAGE}:amd64-${META_TAG} -t ${MANIFESTIMAGE}:amd64-develop -t ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} ${CACHEIMAGE}:amd64-${COMMIT_SHA}-${BUILD_NUMBER} || \ + { if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" && "${MANIFESTIMAGE}" != "${GITLABIMAGE}" ]]; then exit 1; fi; } + ${TIMEOUT_CMD} docker buildx imagetools create --prefer-index=false -t ${MANIFESTIMAGE}:arm64v8-${META_TAG} -t ${MANIFESTIMAGE}:arm64v8-develop -t ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG} ${CACHEIMAGE}:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} || \ + { if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" && "${MANIFESTIMAGE}" != "${GITLABIMAGE}" ]]; then exit 1; fi; } if [ -n "${SEMVER}" ]; then - docker rmi \ - ${DELETEIMAGE}:amd64-${SEMVER} \ - ${DELETEIMAGE}:arm32v7-${SEMVER} \ - ${DELETEIMAGE}:arm64v8-${SEMVER} || : + ${TIMEOUT_CMD} docker buildx imagetools create --prefer-index=false -t ${MANIFESTIMAGE}:amd64-${SEMVER} ${CACHEIMAGE}:amd64-${COMMIT_SHA}-${BUILD_NUMBER} || \ + { if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" && "${MANIFESTIMAGE}" != "${GITLABIMAGE}" ]]; then exit 1; fi; } + ${TIMEOUT_CMD} docker buildx imagetools create --prefer-index=false -t ${MANIFESTIMAGE}:arm64v8-${SEMVER} ${CACHEIMAGE}:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} || \ + { if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" && "${MANIFESTIMAGE}" != "${GITLABIMAGE}" ]]; then exit 1; fi; } fi done - docker rmi \ - ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} \ - ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} || : - ''' + for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do + if [[ "${MANIFESTIMAGE}" == "${GITLABIMAGE}" ]]; then + TIMEOUT_CMD="gitlab_timeout" + else + TIMEOUT_CMD="" + fi + ${TIMEOUT_CMD} docker buildx imagetools create -t ${MANIFESTIMAGE}:develop ${MANIFESTIMAGE}:amd64-develop ${MANIFESTIMAGE}:arm64v8-develop || \ + { if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" && "${MANIFESTIMAGE}" != "${GITLABIMAGE}" ]]; then exit 1; fi; } + ${TIMEOUT_CMD} docker buildx imagetools create -t ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} || \ + { if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" && "${MANIFESTIMAGE}" != "${GITLABIMAGE}" ]]; then exit 1; fi; } + ${TIMEOUT_CMD} docker buildx imagetools create -t ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG} || \ + { if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" && "${MANIFESTIMAGE}" != "${GITLABIMAGE}" ]]; then exit 1; fi; } + if [ -n "${SEMVER}" ]; then + ${TIMEOUT_CMD} docker buildx imagetools create -t ${MANIFESTIMAGE}:${SEMVER} ${MANIFESTIMAGE}:amd64-${SEMVER} ${MANIFESTIMAGE}:arm64v8-${SEMVER} || \ + { if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" && "${MANIFESTIMAGE}" != "${GITLABIMAGE}" ]]; then exit 1; fi; } + fi + done + ''' } } } // If this is a public release tag it in the LS Github stage('Github-Tag-Push-Release') { when { - branch "main" + branch "develop" expression { env.LS_RELEASE != env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER } @@ -912,94 +1216,253 @@ pipeline { environment name: 'EXIT_STATUS', value: '' } steps { - echo "Pushing New tag for current commit ${META_TAG}" - sh '''curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/git/tags \ - -d '{"tag":"'${META_TAG}'",\ - "object": "'${COMMIT_SHA}'",\ - "message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to main",\ - "type": "commit",\ - "tagger": {"name": "LinuxServer Jenkins","email": "jenkins@linuxserver.io","date": "'${GITHUB_DATE}'"}}' ''' - echo "Pushing New release for Tag" sh '''#! /bin/bash - curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq '. |.body' | sed 's:^.\\(.*\\).$:\\1:' > releasebody.json - echo '{"tag_name":"'${META_TAG}'",\ - "target_commitish": "main",\ - "name": "'${META_TAG}'",\ - "body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n\\n**'${EXT_REPO}' Changes:**\\n\\n' > start - printf '","draft": false,"prerelease": false}' >> releasebody.json - paste -d'\\0' start releasebody.json > releasebody.json.done - curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases -d @releasebody.json.done''' + echo "Auto-generating release notes" + if [ "$(git tag --points-at HEAD)" != "" ]; then + echo "Existing tag points to current commit, suggesting no new LS changes" + AUTO_RELEASE_NOTES="No changes" + else + AUTO_RELEASE_NOTES=$(curl -fsL -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept: application/vnd.github+json" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases/generate-notes \ + -d '{"tag_name":"'${META_TAG}'",\ + "target_commitish": "develop"}' \ + | jq -r '.body' | sed 's|## What.s Changed||') + fi + echo "Pushing New tag for current commit ${META_TAG}" + curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/git/tags \ + -d '{"tag":"'${META_TAG}'",\ + "object": "'${COMMIT_SHA}'",\ + "message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to develop",\ + "type": "commit",\ + "tagger": {"name": "LinuxServer-CI","email": "ci@linuxserver.io","date": "'${GITHUB_DATE}'"}}' + echo "Pushing New release for Tag" + curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/mastodon/mastodon/releases/tags/${EXT_RELEASE} | jq -r '. |.body' | sed -E 's|#([0-9]+)|[#\\1](https://github.com/mastodon/mastodon/pull/\\1)|g' | sed -E "s|(srcs?e?t?=\\")\\./|\\1https://github.com/mastodon/mastodon/raw/${EXT_RELEASE}/|g" > releasebody.json + jq -n \ + --arg tag_name "$META_TAG" \ + --arg target_commitish "develop" \ + --arg ci_url "${CI_URL:-N/A}" \ + --arg ls_notes "$AUTO_RELEASE_NOTES" \ + --arg remote_notes "$(cat releasebody.json)" \ + '{ + "tag_name": $tag_name, + "target_commitish": $target_commitish, + "name": $tag_name, + "body": ("**CI Report:**\\n\\n" + $ci_url + "\\n\\n**LinuxServer Changes:**\\n\\n" + $ls_notes + "\\n\\n**Remote Changes:**\\n\\n" + $remote_notes), + "draft": false, + "prerelease": true }' > releasebody.json.done + curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases -d @releasebody.json.done + ''' } } - // Use helper container to sync the current README on master to the dockerhub endpoint - stage('Sync-README') { + // Add protection to the release branch + stage('Github-Release-Branch-Protection') { when { + branch "develop" environment name: 'CHANGE_ID', value: '' environment name: 'EXIT_STATUS', value: '' } steps { - withCredentials([ - [ - $class: 'UsernamePasswordMultiBinding', - credentialsId: '3f9ba4d5-100d-45b0-a3c4-633fd6061207', - usernameVariable: 'DOCKERUSER', - passwordVariable: 'DOCKERPASS' - ] - ]) { - sh '''#! /bin/bash - set -e - TEMPDIR=$(mktemp -d) - docker pull ghcr.io/linuxserver/jenkins-builder:latest - docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH="${BRANCH_NAME}" -v ${TEMPDIR}:/ansible/jenkins ghcr.io/linuxserver/jenkins-builder:latest - docker pull ghcr.io/linuxserver/readme-sync - docker run --rm=true \ - -e DOCKERHUB_USERNAME=$DOCKERUSER \ - -e DOCKERHUB_PASSWORD=$DOCKERPASS \ - -e GIT_REPOSITORY=${LS_USER}/${LS_REPO} \ - -e DOCKER_REPOSITORY=${IMAGE} \ - -e GIT_BRANCH=master \ - -v ${TEMPDIR}/docker-${CONTAINER_NAME}:/mnt \ - ghcr.io/linuxserver/readme-sync bash -c 'node sync' - rm -Rf ${TEMPDIR} ''' - } - } - } - // If this is a Pull request send the CI link as a comment on it - stage('Pull Request Comment') { - when { - not {environment name: 'CHANGE_ID', value: ''} - environment name: 'CI', value: 'true' - environment name: 'EXIT_STATUS', value: '' - } - steps { - sh '''curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/issues/${PULL_REQUEST}/comments \ - -d '{"body": "I am a bot, here are the test results for this PR: \\n'${CI_URL}' \\n'${SHELLCHECK_URL}'"}' ''' + echo "Setting up protection for release branch develop" + sh '''#! /bin/bash + curl -H "Authorization: token ${GITHUB_TOKEN}" -X PUT https://api.github.com/repos/${LS_USER}/${LS_REPO}/branches/develop/protection \ + -d $(jq -c . << EOF + { + "required_status_checks": null, + "enforce_admins": false, + "required_pull_request_reviews": { + "dismiss_stale_reviews": false, + "require_code_owner_reviews": false, + "require_last_push_approval": false, + "required_approving_review_count": 1 + }, + "restrictions": null, + "required_linear_history": false, + "allow_force_pushes": false, + "allow_deletions": false, + "block_creations": false, + "required_conversation_resolution": true, + "lock_branch": false, + "allow_fork_syncing": false, + "required_signatures": false + } +EOF + ) ''' } } } /* ###################### - Send status to Discord + Comment on PR and Send status to Discord ###################### */ post { always { - script{ + script { + env.JOB_DATE = sh( + script: '''date '+%Y-%m-%dT%H:%M:%S%:z' ''', + returnStdout: true).trim() if (env.EXIT_STATUS == "ABORTED"){ sh 'echo "build aborted"' - } - else if (currentBuild.currentResult == "SUCCESS"){ - sh ''' curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://wiki.jenkins-ci.org/download/attachments/2916393/headshot.png","embeds": [{"color": 1681177,\ - "description": "**Build:** '${BUILD_NUMBER}'\\n**CI Results:** '${CI_URL}'\\n**ShellCheck Results:** '${SHELLCHECK_URL}'\\n**Status:** Success\\n**Job:** '${RUN_DISPLAY_URL}'\\n**Change:** '${CODE_URL}'\\n**External Release:**: '${RELEASE_LINK}'\\n**DockerHub:** '${DOCKERHUB_LINK}'\\n"}],\ + }else{ + if (currentBuild.currentResult == "SUCCESS"){ + if (env.GITHUBIMAGE =~ /lspipepr/){ + env.JOB_WEBHOOK_STATUS='Success' + env.JOB_WEBHOOK_COLOUR=3957028 + env.JOB_WEBHOOK_FOOTER='PR Build' + }else if (env.GITHUBIMAGE =~ /lsiodev/){ + env.JOB_WEBHOOK_STATUS='Success' + env.JOB_WEBHOOK_COLOUR=3957028 + env.JOB_WEBHOOK_FOOTER='Dev Build' + }else{ + env.JOB_WEBHOOK_STATUS='Success' + env.JOB_WEBHOOK_COLOUR=1681177 + env.JOB_WEBHOOK_FOOTER='Live Build' + } + }else{ + if (env.GITHUBIMAGE =~ /lspipepr/){ + env.JOB_WEBHOOK_STATUS='Failure' + env.JOB_WEBHOOK_COLOUR=12669523 + env.JOB_WEBHOOK_FOOTER='PR Build' + }else if (env.GITHUBIMAGE =~ /lsiodev/){ + env.JOB_WEBHOOK_STATUS='Failure' + env.JOB_WEBHOOK_COLOUR=12669523 + env.JOB_WEBHOOK_FOOTER='Dev Build' + }else{ + env.JOB_WEBHOOK_STATUS='Failure' + env.JOB_WEBHOOK_COLOUR=16711680 + env.JOB_WEBHOOK_FOOTER='Live Build' + } + } + sh ''' curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/jenkins-avatar.png","embeds": [{"'color'": '${JOB_WEBHOOK_COLOUR}',\ + "footer": {"text" : "'"${JOB_WEBHOOK_FOOTER}"'"},\ + "timestamp": "'${JOB_DATE}'",\ + "description": "**Build:** '${BUILD_NUMBER}'\\n**CI Results:** '${CI_URL}'\\n**ShellCheck Results:** '${SHELLCHECK_URL}'\\n**Status:** '${JOB_WEBHOOK_STATUS}'\\n**Job:** '${RUN_DISPLAY_URL}'\\n**Change:** '${CODE_URL}'\\n**External Release:**: '${RELEASE_LINK}'\\n**DockerHub:** '${DOCKERHUB_LINK}'\\n"}],\ "username": "Jenkins"}' ${BUILDS_DISCORD} ''' } - else { - sh ''' curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://wiki.jenkins-ci.org/download/attachments/2916393/headshot.png","embeds": [{"color": 16711680,\ - "description": "**Build:** '${BUILD_NUMBER}'\\n**CI Results:** '${CI_URL}'\\n**ShellCheck Results:** '${SHELLCHECK_URL}'\\n**Status:** failure\\n**Job:** '${RUN_DISPLAY_URL}'\\n**Change:** '${CODE_URL}'\\n**External Release:**: '${RELEASE_LINK}'\\n**DockerHub:** '${DOCKERHUB_LINK}'\\n"}],\ - "username": "Jenkins"}' ${BUILDS_DISCORD} ''' + } + script { + if (env.GITHUBIMAGE =~ /lspipepr/){ + if (env.CI_TEST_ATTEMPTED == "true" || env.PUSH_ATTEMPTED == "true"){ + sh '''#! /bin/bash + # Function to retrieve JSON data from URL + get_json() { + local url="$1" + local response=$(curl -s "$url") + if [ $? -ne 0 ]; then + echo "Failed to retrieve JSON data from $url" + return 1 + fi + local json=$(echo "$response" | jq .) + if [ $? -ne 0 ]; then + echo "Failed to parse JSON data from $url" + return 1 + fi + echo "$json" + } + + build_table() { + local data="$1" + + # Get the keys in the JSON data + local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]') + + # Check if keys are empty + if [ -z "$keys" ]; then + echo "JSON report data does not contain any keys or the report does not exist." + return 1 + fi + + # Build table header + local header="| Tag | Passed |\\n| --- | --- |\\n" + + # Loop through the JSON data to build the table rows + local rows="" + for build in $keys; do + local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success") + if [ "$status" = "true" ]; then + status="✅" + else + status="❌" + fi + local row="| "$build" | "$status" |\\n" + rows="${rows}${row}" + done + + local table="${header}${rows}" + local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g') + echo "$escaped_table" + } + + if [[ "${CI}" = "true" ]]; then + # Retrieve JSON data from URL + data=$(get_json "$CI_JSON_URL") + # Create table from JSON data + table=$(build_table "$data") + echo -e "$table" + + curl -X POST -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \ + -d "{\\"body\\": \\"I am a bot, here are the test results for this PR for commit ${COMMIT_SHA:0:7} : \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}" + else + curl -X POST -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \ + -d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR for commit ${COMMIT_SHA:0:7} : \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}" + fi + ''' + } else { + sh '''#! /bin/bash + curl -X POST -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \ + -d "{\\"body\\": \\"I am a bot, the build for PR commit ${COMMIT_SHA:0:7} failed and as a result no CI test was attempted and no images were pushed.\\"}" + ''' + } } } + sh '''#!/bin/bash + rm -rf /config/.ssh/id_sign + rm -rf /config/.ssh/id_sign.pub + git config --global --unset gpg.format + git config --global --unset user.signingkey + git config --global --unset commit.gpgsign + ''' } cleanup { + sh '''#! /bin/bash + echo "Pruning builder!!" + docker builder prune -f --builder container || : + containers=$(docker ps -q) + if [[ -n "${containers}" ]]; then + BUILDX_CONTAINER_ID=$(docker ps -qf 'name=buildx_buildkit') + for container in ${containers}; do + if [[ "${container}" == "${BUILDX_CONTAINER_ID}" ]]; then + echo "skipping buildx container in docker stop" + else + echo "Stopping container ${container}" + docker stop ${container} + fi + done + fi + docker system prune -f --volumes || : + docker image prune -af || : + ''' cleanWs() } } } + +def retry_backoff(int max_attempts, int power_base, Closure c) { + int n = 0 + while (n < max_attempts) { + try { + c() + return + } catch (err) { + if ((n + 1) >= max_attempts) { + throw err + } + sleep(power_base ** n) + n++ + } + } + return +} diff --git a/README.md b/README.md index eef39b7..f3e03da 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,10 @@ -<!-- DO NOT EDIT THIS FILE MANUALLY --> -<!-- Please read the https://github.com/linuxserver/docker-mastodon/blob/main/.github/CONTRIBUTING.md --> - +<!-- DO NOT EDIT THIS FILE MANUALLY --> +<!-- Please read https://github.com/linuxserver/docker-mastodon/blob/develop/.github/CONTRIBUTING.md --> [![linuxserver.io](https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/linuxserver_medium.png)](https://linuxserver.io) [![Blog](https://img.shields.io/static/v1.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=linuxserver.io&message=Blog)](https://blog.linuxserver.io "all the things you can do with our containers including How-To guides, opinions and much more!") -[![Discord](https://img.shields.io/discord/354974912613449730.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=Discord&logo=discord)](https://discord.gg/YWrKVTn "realtime support / chat with the community and the team.") -[![Discourse](https://img.shields.io/discourse/https/discourse.linuxserver.io/topics.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=discourse)](https://discourse.linuxserver.io "post on our community forum.") -[![Fleet](https://img.shields.io/static/v1.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=linuxserver.io&message=Fleet)](https://fleet.linuxserver.io "an online web interface which displays all of our maintained images.") +[![Discord](https://img.shields.io/discord/354974912613449730.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=Discord&logo=discord)](https://linuxserver.io/discord "realtime support / chat with the community and the team.") +[![Discussions](https://img.shields.io/badge/Github-Discussions-94398d?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/orgs/linuxserver/discussions "post on our community forum.") [![GitHub](https://img.shields.io/static/v1.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=linuxserver.io&message=GitHub&logo=github)](https://github.com/linuxserver "view the source for all of our repositories.") [![Open Collective](https://img.shields.io/opencollective/all/linuxserver.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=Supporters&logo=open%20collective)](https://opencollective.com/linuxserver "please consider helping us by either donating or contributing to our budget") @@ -21,15 +19,14 @@ The [LinuxServer.io](https://linuxserver.io) team brings you another container r Find us at: * [Blog](https://blog.linuxserver.io) - all the things you can do with our containers including How-To guides, opinions and much more! -* [Discord](https://discord.gg/YWrKVTn) - realtime support / chat with the community and the team. -* [Discourse](https://discourse.linuxserver.io) - post on our community forum. -* [Fleet](https://fleet.linuxserver.io) - an online web interface which displays all of our maintained images. +* [Discord](https://linuxserver.io/discord) - realtime support / chat with the community and the team. +* [Discussions](https://github.com/orgs/linuxserver/discussions) - post on our community forum. * [GitHub](https://github.com/linuxserver) - view the source for all of our repositories. * [Open Collective](https://opencollective.com/linuxserver) - please consider helping us by either donating or contributing to our budget # [linuxserver/mastodon](https://github.com/linuxserver/docker-mastodon) -[![Scarf.io pulls](https://scarf.sh/installs-badge/linuxserver-ci/linuxserver%2Fmastodon?color=94398d&label-color=555555&logo-color=ffffff&style=for-the-badge&package-type=docker)](https://scarf.sh/gateway/linuxserver-ci/docker/linuxserver%2Fmastodon) +[![Scarf.io pulls](https://scarf.sh/installs-badge/linuxserver-ci/linuxserver%2Fmastodon?color=94398d&label-color=555555&logo-color=ffffff&style=for-the-badge&package-type=docker)](https://scarf.sh) [![GitHub Stars](https://img.shields.io/github/stars/linuxserver/docker-mastodon.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/linuxserver/docker-mastodon) [![GitHub Release](https://img.shields.io/github/release/linuxserver/docker-mastodon.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/linuxserver/docker-mastodon/releases) [![GitHub Package Repository](https://img.shields.io/static/v1.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=linuxserver.io&message=GitHub%20Package&logo=github)](https://github.com/linuxserver/docker-mastodon/packages) @@ -37,7 +34,7 @@ Find us at: [![Quay.io](https://img.shields.io/static/v1.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=linuxserver.io&message=Quay.io)](https://quay.io/repository/linuxserver.io/mastodon) [![Docker Pulls](https://img.shields.io/docker/pulls/linuxserver/mastodon.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=pulls&logo=docker)](https://hub.docker.com/r/linuxserver/mastodon) [![Docker Stars](https://img.shields.io/docker/stars/linuxserver/mastodon.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=stars&logo=docker)](https://hub.docker.com/r/linuxserver/mastodon) -[![Jenkins Build](https://img.shields.io/jenkins/build?labelColor=555555&logoColor=ffffff&style=for-the-badge&jobUrl=https%3A%2F%2Fci.linuxserver.io%2Fjob%2FDocker-Pipeline-Builders%2Fjob%2Fdocker-mastodon%2Fjob%2Fmain%2F&logo=jenkins)](https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-mastodon/job/main/) +[![Jenkins Build](https://img.shields.io/jenkins/build?labelColor=555555&logoColor=ffffff&style=for-the-badge&jobUrl=https%3A%2F%2Fci.linuxserver.io%2Fjob%2FDocker-Pipeline-Builders%2Fjob%2Fdocker-mastodon%2Fjob%2Fdevelop%2F&logo=jenkins)](https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-mastodon/job/develop/) [Mastodon](https://github.com/mastodon/mastodon/) is a free, open-source social network server based on ActivityPub where users can follow friends and discover new ones.. @@ -45,9 +42,9 @@ Find us at: ## Supported Architectures -We utilise the docker manifest for multi-platform awareness. More information is available from docker [here](https://github.com/docker/distribution/blob/master/docs/spec/manifest-v2-2.md#manifest-list) and our announcement [here](https://blog.linuxserver.io/2019/02/21/the-lsio-pipeline-project/). +We utilise the docker manifest for multi-platform awareness. More information is available from docker [here](https://distribution.github.io/distribution/spec/manifest-v2-2/#manifest-list) and our announcement [here](https://blog.linuxserver.io/2019/02/21/the-lsio-pipeline-project/). -Simply pulling `lscr.io/linuxserver/mastodon:latest` should retrieve the correct image for your arch, but you can also pull specific arch images via tags. +Simply pulling `lscr.io/linuxserver/mastodon:develop` should retrieve the correct image for your arch, but you can also pull specific arch images via tags. The architectures supported by this image are: @@ -55,13 +52,32 @@ The architectures supported by this image are: | :----: | :----: | ---- | | x86-64 | ✅ | amd64-\<version tag\> | | arm64 | ✅ | arm64v8-\<version tag\> | -| armhf| ❌ | | + +## Version Tags + +This image provides various versions that are available via tags. Please read the descriptions carefully and exercise caution when using unstable or development tags. + +| Tag | Available | Description | +| :----: | :----: |--- | +| latest | ✅ | Stable releases. | +| develop | ✅ | Pre-releases *only*. | +| glitch | ✅ | [glitch-soc](https://github.com/glitch-soc/mastodon) fork releases. | ## Application Setup -To generate keys for `SECRET_KEY_BASE` & `OTP_SECRET` run `docker run --rm -it -w /app/www --entrypoint rake lscr.io/linuxserver/mastodon secret` once for each. +We provide aliases for the common commands that execute in the correct context so that environment variables from secrets are available to them: + +* To generate keys for `SECRET_KEY_BASE` & `OTP_SECRET` run `docker run --rm -it --entrypoint /bin/bash lscr.io/linuxserver/mastodon:develop generate-secret` once for each. + +* To generate keys for `VAPID_PRIVATE_KEY` & `VAPID_PUBLIC_KEY` run `docker run --rm -it --entrypoint /bin/bash lscr.io/linuxserver/mastodon:develop generate-vapid` -To generate keys for `VAPID_PRIVATE_KEY` & `VAPID_PUBLIC_KEY` run `docker run --rm -it -w /app/www --entrypoint rake lscr.io/linuxserver/mastodon mastodon:webpush:generate_vapid_key` +* To generate keys for `ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY`, `ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT`, & `ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY` run `docker run --rm -it --entrypoint /bin/bash lscr.io/linuxserver/mastodon:develop generate-active-record` + +Both of the secret generation aliases above can be run without any other setup having been carried out. + +* To use `tootctl` you can run something like `docker exec -it lscr.io/linuxserver/mastodon /tootctl <command>` + +Using `tootctl` requires you to complete the initial Mastodon configuration first. This container *requires* separate postgres and redis instances to run. @@ -69,23 +85,41 @@ We support all of the official [environment variables](https://docs.joinmastodon For more information check out the [mastodon documentation](https://docs.joinmastodon.org/). +### Running separate sidekiq instances + +It is currently only supported to run a single queue per container instance *or* all queues in a single container instance. + +All containers must share the same `/config` mount and be on a common docker network. + +### NO_CHOWN Option + +On larger Mastodon instances, our init process to verify that permissions are set correctly can noticeably slow down the container startup. If you are experiencing this, you can set `NO_CHOWN` to `true` to skip that step of the init. + +*Do NOT set this on first run of the container. If you enable this option you are taking full responsibility for ensuring that the permissions in your /config mount are correct. If you're even slightly unsure, don't set it.* + +### Strict reverse proxies + +This image automatically redirects to https with a self-signed certificate. If you are using a reverse proxy which validates certificates, you need to [disable this check for the container](https://docs.linuxserver.io/faq#strict-proxy). + ## Usage -Here are some example snippets to help you get started creating a container. +To help you get started creating a container from this image you can either use docker-compose or the docker cli. + +>[!NOTE] +>Unless a parameter is flagged as 'optional', it is *mandatory* and a value must be provided. ### docker-compose (recommended, [click here for more info](https://docs.linuxserver.io/general/docker-compose)) ```yaml --- -version: "2.1" services: mastodon: - image: lscr.io/linuxserver/mastodon:latest + image: lscr.io/linuxserver/mastodon:develop container_name: mastodon environment: - PUID=1000 - PGID=1000 - - TZ=America/New_York + - TZ=Etc/UTC - LOCAL_DOMAIN=example.com - REDIS_HOST=redis - REDIS_PORT=6379 @@ -95,6 +129,9 @@ services: - DB_PASS=mastodon - DB_PORT=5432 - ES_ENABLED=false + - ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY= + - ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY= + - ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT= - SECRET_KEY_BASE= - OTP_SECRET= - VAPID_PRIVATE_KEY= @@ -114,11 +151,19 @@ services: - AWS_ACCESS_KEY_ID= #optional - AWS_SECRET_ACCESS_KEY= #optional - S3_ALIAS_HOST= #optional + - SIDEKIQ_ONLY=false #optional + - SIDEKIQ_QUEUE= #optional + - SIDEKIQ_DEFAULT=false #optional + - SIDEKIQ_THREADS=5 #optional + - DB_POOL=5 #optional + - NO_CHOWN= #optional + - MASTODON_PROMETHEUS_EXPORTER_ENABLED= #optional volumes: - - /path/to/appdata/config:/config + - /path/to/mastodon/config:/config ports: - 80:80 - 443:443 + - 9394:9394 #optional restart: unless-stopped ``` @@ -129,7 +174,7 @@ docker run -d \ --name=mastodon \ -e PUID=1000 \ -e PGID=1000 \ - -e TZ=America/New_York \ + -e TZ=Etc/UTC \ -e LOCAL_DOMAIN=example.com \ -e REDIS_HOST=redis \ -e REDIS_PORT=6379 \ @@ -139,6 +184,9 @@ docker run -d \ -e DB_PASS=mastodon \ -e DB_PORT=5432 \ -e ES_ENABLED=false \ + -e ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY= \ + -e ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY= \ + -e ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT= \ -e SECRET_KEY_BASE= \ -e OTP_SECRET= \ -e VAPID_PRIVATE_KEY= \ @@ -158,24 +206,33 @@ docker run -d \ -e AWS_ACCESS_KEY_ID= `#optional` \ -e AWS_SECRET_ACCESS_KEY= `#optional` \ -e S3_ALIAS_HOST= `#optional` \ + -e SIDEKIQ_ONLY=false `#optional` \ + -e SIDEKIQ_QUEUE= `#optional` \ + -e SIDEKIQ_DEFAULT=false `#optional` \ + -e SIDEKIQ_THREADS=5 `#optional` \ + -e DB_POOL=5 `#optional` \ + -e NO_CHOWN= `#optional` \ + -e MASTODON_PROMETHEUS_EXPORTER_ENABLED= `#optional` \ -p 80:80 \ -p 443:443 \ - -v /path/to/appdata/config:/config \ + -p 9394:9394 `#optional` \ + -v /path/to/mastodon/config:/config \ --restart unless-stopped \ - lscr.io/linuxserver/mastodon:latest + lscr.io/linuxserver/mastodon:develop ``` ## Parameters -Container images are configured using parameters passed at runtime (such as those above). These parameters are separated by a colon and indicate `<external>:<internal>` respectively. For example, `-p 8080:80` would expose port `80` from inside the container to be accessible from the host's IP on port `8080` outside the container. +Containers are configured using parameters passed at runtime (such as those above). These parameters are separated by a colon and indicate `<external>:<internal>` respectively. For example, `-p 8080:80` would expose port `80` from inside the container to be accessible from the host's IP on port `8080` outside the container. | Parameter | Function | | :----: | --- | -| `-p 80` | Port for web frontend | -| `-p 443` | Port for web frontend | +| `-p 80:80` | Port for web frontend | +| `-p 443:443` | Port for web frontend | +| `-p 9394` | Port for Prometheus metrics | | `-e PUID=1000` | for UserID - see below for explanation | | `-e PGID=1000` | for GroupID - see below for explanation | -| `-e TZ=America/New_York` | Specify a timezone to use EG America/New_York | +| `-e TZ=Etc/UTC` | specify a timezone to use, see this [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List). | | `-e LOCAL_DOMAIN=example.com` | This is the unique identifier of your server in the network. It cannot be safely changed later. | | `-e REDIS_HOST=redis` | Redis server hostname | | `-e REDIS_PORT=6379` | Redis port | @@ -183,8 +240,11 @@ Container images are configured using parameters passed at runtime (such as thos | `-e DB_USER=mastodon` | Postgres username | | `-e DB_NAME=mastodon` | Postgres db name | | `-e DB_PASS=mastodon` | Postgres password | -| `-e DB_PORT=5432` | Portgres port | +| `-e DB_PORT=5432` | Postgres port | | `-e ES_ENABLED=false` | Enable or disable Elasticsearch (requires a separate ES instance) | +| `-e ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY=` | Primary key for [Active Record Encryption](https://github.com/mastodon/mastodon/pull/29831/files). | +| `-e ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=` | Deterministic key for [Active Record Encryption](https://github.com/mastodon/mastodon/pull/29831/files). | +| `-e ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=` | Derivation salt for [Active Record Encryption](https://github.com/mastodon/mastodon/pull/29831/files). | | `-e SECRET_KEY_BASE=` | Browser session secret. Changing it will break all active browser sessions. | | `-e OTP_SECRET=` | MFA secret. Changing it will break two-factor authentication. | | `-e VAPID_PRIVATE_KEY=` | Push notification private key. Changing it will break push notifications. | @@ -195,7 +255,7 @@ Container images are configured using parameters passed at runtime (such as thos | `-e SMTP_PASSWORD=` | SMTP password | | `-e SMTP_FROM_ADDRESS=notifications@example.com` | From address for emails send from Mastodon | | `-e S3_ENABLED=false` | Enable or disable S3 storage of uploaded files | -| `-e WEB_DOMAIN=mastodon.example.com` | This can be set if you want your server identifier to be different to the subdomain hosting Mastodon. See https://docs.joinmastodon.org/admin/config/#basic | +| `-e WEB_DOMAIN=mastodon.example.com` | This can be set if you want your server identifier to be different to the subdomain hosting Mastodon. See [https://docs.joinmastodon.org/admin/config/#basic](https://docs.joinmastodon.org/admin/config/#basic) | | `-e ES_HOST=es` | Elasticsearch server hostname | | `-e ES_PORT=9200` | Elasticsearch port | | `-e ES_USER=elastic` | Elasticsearch username | @@ -204,6 +264,13 @@ Container images are configured using parameters passed at runtime (such as thos | `-e AWS_ACCESS_KEY_ID=` | S3 bucket access key ID | | `-e AWS_SECRET_ACCESS_KEY=` | S3 bucket secret access key | | `-e S3_ALIAS_HOST=` | Alternate hostname for object fetching if you are front the S3 connections. | +| `-e SIDEKIQ_ONLY=false` | Only run the sidekiq service in this container instance. For large scale instances that need better queue handling. | +| `-e SIDEKIQ_QUEUE=` | The name of the sidekiq queue to run in this container. See [notes](https://docs.joinmastodon.org/admin/scaling/#sidekiq-queues). | +| `-e SIDEKIQ_DEFAULT=false` | Set to `true` on the main container if you're running additional sidekiq instances. It will run the `default` queue. | +| `-e SIDEKIQ_THREADS=5` | The number of threads for sidekiq to use. See [notes](https://docs.joinmastodon.org/admin/scaling/#sidekiq-threads). | +| `-e DB_POOL=5` | The size of the DB connection pool, must be *at least* the same as `SIDEKIQ_THREADS`. See [notes](https://docs.joinmastodon.org/admin/scaling/#sidekiq-threads). | +| `-e NO_CHOWN=` | Set to `true` to skip chown of /config on init. *READ THE APPLICATION NOTES BEFORE SETTING THIS*. | +| `-e MASTODON_PROMETHEUS_EXPORTER_ENABLED=` | If set to `true`, Mastodon’s Ruby processes (web & Sidekiq) will enable the Prometheus instrumentation. | | `-v /config` | Contains all relevant configuration files. | ## Environment variables from files (Docker secrets) @@ -213,10 +280,10 @@ You can set any environment variable from a file by using a special prepend `FIL As an example: ```bash --e FILE__PASSWORD=/run/secrets/mysecretpassword +-e FILE__MYVAR=/run/secrets/mysecretvariable ``` -Will set the environment variable `PASSWORD` based on the contents of the `/run/secrets/mysecretpassword` file. +Will set the environment variable `MYVAR` based on the contents of the `/run/secrets/mysecretvariable` file. ## Umask for running applications @@ -225,15 +292,20 @@ Keep in mind umask is not chmod it subtracts from permissions based on it's valu ## User / Group Identifiers -When using volumes (`-v` flags) permissions issues can arise between the host OS and the container, we avoid this issue by allowing you to specify the user `PUID` and group `PGID`. +When using volumes (`-v` flags), permissions issues can arise between the host OS and the container, we avoid this issue by allowing you to specify the user `PUID` and group `PGID`. Ensure any volume directories on the host are owned by the same user you specify and any permissions issues will vanish like magic. -In this instance `PUID=1000` and `PGID=1000`, to find yours use `id user` as below: +In this instance `PUID=1000` and `PGID=1000`, to find yours use `id your_user` as below: ```bash - $ id username - uid=1000(dockeruser) gid=1000(dockergroup) groups=1000(dockergroup) +id your_user +``` + +Example output: + +```text +uid=1000(your_user) gid=1000(your_user) groups=1000(your_user) ``` ## Docker Mods @@ -244,53 +316,101 @@ We publish various [Docker Mods](https://github.com/linuxserver/docker-mods) to ## Support Info -* Shell access whilst the container is running: `docker exec -it mastodon /bin/bash` -* To monitor the logs of the container in realtime: `docker logs -f mastodon` -* container version number - * `docker inspect -f '{{ index .Config.Labels "build_version" }}' mastodon` -* image version number - * `docker inspect -f '{{ index .Config.Labels "build_version" }}' lscr.io/linuxserver/mastodon:latest` +* Shell access whilst the container is running: + + ```bash + docker exec -it mastodon /bin/bash + ``` + +* To monitor the logs of the container in realtime: + + ```bash + docker logs -f mastodon + ``` + +* Container version number: + + ```bash + docker inspect -f '{{ index .Config.Labels "build_version" }}' mastodon + ``` + +* Image version number: + + ```bash + docker inspect -f '{{ index .Config.Labels "build_version" }}' lscr.io/linuxserver/mastodon:develop + ``` ## Updating Info -Most of our images are static, versioned, and require an image update and container recreation to update the app inside. With some exceptions (ie. nextcloud, plex), we do not recommend or support updating apps inside the container. Please consult the [Application Setup](#application-setup) section above to see if it is recommended for the image. +Most of our images are static, versioned, and require an image update and container recreation to update the app inside. With some exceptions (noted in the relevant readme.md), we do not recommend or support updating apps inside the container. Please consult the [Application Setup](#application-setup) section above to see if it is recommended for the image. Below are the instructions for updating containers: ### Via Docker Compose -* Update all images: `docker-compose pull` - * or update a single image: `docker-compose pull mastodon` -* Let compose update all containers as necessary: `docker-compose up -d` - * or update a single container: `docker-compose up -d mastodon` -* You can also remove the old dangling images: `docker image prune` +* Update images: + * All images: + + ```bash + docker-compose pull + ``` + + * Single image: + + ```bash + docker-compose pull mastodon + ``` + +* Update containers: + * All containers: + + ```bash + docker-compose up -d + ``` + + * Single container: + + ```bash + docker-compose up -d mastodon + ``` + +* You can also remove the old dangling images: + + ```bash + docker image prune + ``` ### Via Docker Run -* Update the image: `docker pull lscr.io/linuxserver/mastodon:latest` -* Stop the running container: `docker stop mastodon` -* Delete the container: `docker rm mastodon` -* Recreate a new container with the same docker run parameters as instructed above (if mapped correctly to a host folder, your `/config` folder and settings will be preserved) -* You can also remove the old dangling images: `docker image prune` +* Update the image: + + ```bash + docker pull lscr.io/linuxserver/mastodon:develop + ``` -### Via Watchtower auto-updater (only use if you don't remember the original parameters) +* Stop the running container: -* Pull the latest image at its tag and replace it with the same env variables in one run: + ```bash + docker stop mastodon + ``` - ```bash - docker run --rm \ - -v /var/run/docker.sock:/var/run/docker.sock \ - containrrr/watchtower \ - --run-once mastodon - ``` +* Delete the container: -* You can also remove the old dangling images: `docker image prune` + ```bash + docker rm mastodon + ``` + +* Recreate a new container with the same docker run parameters as instructed above (if mapped correctly to a host folder, your `/config` folder and settings will be preserved) +* You can also remove the old dangling images: -**Note:** We do not endorse the use of Watchtower as a solution to automated updates of existing Docker containers. In fact we generally discourage automated updates. However, this is a useful tool for one-time manual updates of containers where you have forgotten the original parameters. In the long term, we highly recommend using [Docker Compose](https://docs.linuxserver.io/general/docker-compose). + ```bash + docker image prune + ``` ### Image Update Notifications - Diun (Docker Image Update Notifier) -* We recommend [Diun](https://crazymax.dev/diun/) for update notifications. Other tools that automatically update containers unattended are not recommended or supported. +>[!TIP] +>We recommend [Diun](https://crazymax.dev/diun/) for update notifications. Other tools that automatically update containers unattended are not recommended or supported. ## Building locally @@ -302,17 +422,29 @@ cd docker-mastodon docker build \ --no-cache \ --pull \ - -t lscr.io/linuxserver/mastodon:latest . + -t lscr.io/linuxserver/mastodon:develop . ``` -The ARM variants can be built on x86_64 hardware using `multiarch/qemu-user-static` +The ARM variants can be built on x86_64 hardware and vice versa using `lscr.io/linuxserver/qemu-static` ```bash -docker run --rm --privileged multiarch/qemu-user-static:register --reset +docker run --rm --privileged lscr.io/linuxserver/qemu-static --reset ``` Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64`. ## Versions +* **29.11.26:** - Fetch Ruby from library image to match the version required by upstream. +* **18.11.26:** - Build Ruby from source to match the version required by upstream. +* **05.07.26:** - Rebase to Alpine 3.24. +* **21.10.25:** - Add prometheus exporter support. +* **20.10.25:** - Add vips-heif. +* **06.06.25:** - Rebase to Alpine 3.22, replace deprecated imagemagick with vips. +* **26.08.24:** - Rebase to Alpine 3.20, enable [Active Record Encryption](https://github.com/mastodon/mastodon/pull/29831/files). Existing users should update their nginx confs to avoid http2 deprecation warnings. +* **08.08.23:** - Rebase to Alpine 3.18, migrate to s6v3 +* **09.02.23:** - Add Glitch branch. +* **26.01.23:** - Add aliases for key generation & tootctl to better support secrets. +* **19.12.22:** - Support separate sidekiq queue instances. +* **08.11.22:** - Add develop branch. * **05.11.22:** - Initial Release. diff --git a/jenkins-vars.yml b/jenkins-vars.yml index aa21006..479b372 100644 --- a/jenkins-vars.yml +++ b/jenkins-vars.yml @@ -2,11 +2,16 @@ # jenkins variables project_name: docker-mastodon -external_type: github_stable -release_type: stable -release_tag: latest -ls_branch: main +external_type: custom_json +custom_release_notes_command: |- + curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/mastodon/mastodon/releases/tags/${EXT_RELEASE} | jq -r '. |.body' | sed -E 's|#([0-9]+)|[#\\1](https://github.com/mastodon/mastodon/pull/\\1)|g' | sed -E "s|(srcs?e?t?=\\")\\./|\\1https://github.com/mastodon/mastodon/raw/${EXT_RELEASE}/|g" > releasebody.json +release_type: prerelease +release_tag: develop +ls_branch: develop +image_builder: default repo_vars: + - JSON_URL='https://api.github.com/repos/mastodon/mastodon/releases' + - JSON_PATH='first(.[] | select(.prerelease==true)) | .tag_name' - EXT_GIT_BRANCH = 'main' - EXT_USER = 'mastodon' - EXT_REPO = 'mastodon' @@ -23,8 +28,7 @@ repo_vars: - CI_WEB='false' - CI_PORT='80' - CI_SSL='false' - - CI_DELAY='120' - - CI_DOCKERENV='TZ=US/Pacific' + - CI_DELAY='60' + - CI_DOCKERENV='' - CI_AUTH='' - CI_WEBPATH='' - \ No newline at end of file diff --git a/package_versions.txt b/package_versions.txt index c27c12a..3c432d0 100755 --- a/package_versions.txt +++ b/package_versions.txt @@ -1,158 +1,849 @@ -alpine-baselayout-3.2.0-r18 -alpine-keys-2.4-r1 -alsa-lib-1.2.5.1-r1 -aom-libs-3.2.0-r0 -apache2-utils-2.4.54-r0 -apk-tools-2.12.7-r3 -apr-1.7.0-r1 -apr-util-1.6.1-r11 -argon2-libs-20190702-r1 -avahi-libs-0.8-r5 -bash-5.1.16-r0 -brotli-libs-1.0.9-r5 -busybox-1.34.1-r7 -c-ares-1.18.1-r0 -ca-certificates-20220614-r0 -ca-certificates-bundle-20220614-r0 -cairo-1.16.0-r5 -cairo-gobject-1.16.0-r5 -coreutils-9.0-r2 -cups-libs-2.3.3-r6 -curl-7.80.0-r4 -dbus-libs-1.12.24-r0 -expat-2.5.0-r0 -ffmpeg-4.4.1-r2 -ffmpeg-libs-4.4.1-r2 -file-5.41-r0 -fontconfig-2.13.1-r4 -freetype-2.11.1-r2 -fribidi-1.0.11-r0 -gdbm-1.22-r0 -gdk-pixbuf-2.42.8-r0 -ghostscript-9.55.0-r0 -git-2.34.5-r0 -glib-2.70.1-r0 -gmp-6.2.1-r1 -gnutls-3.7.1-r1 -graphite2-1.3.14-r0 -harfbuzz-3.0.0-r2 -icu-libs-69.1-r1 -imagemagick-7.1.0.16-r0 -imagemagick-libs-7.1.0.16-r0 -jbig2dec-0.19-r0 -lame-3.100-r0 -lcms2-2.12-r1 -libacl-2.2.53-r0 -libass-0.15.2-r0 -libattr-2.5.1-r1 -libblkid-2.37.4-r0 -libbsd-0.11.3-r1 -libbz2-1.0.8-r1 -libc-utils-0.7.2-r3 -libcrypto1.1-1.1.1s-r1 -libcurl-7.80.0-r4 -libdav1d-0.9.2-r0 -libde265-1.0.8-r2 -libdrm-2.4.109-r0 -libedit-20210910.3.1-r0 -libffi-3.4.2-r1 -libgcc-10.3.1_git20211027-r0 -libgomp-10.3.1_git20211027-r0 -libheif-1.12.0-r2 -libidn-1.38-r0 -libintl-0.21-r0 -libjpeg-turbo-2.1.2-r0 -libltdl-2.4.6-r7 -libmagic-5.41-r0 -libmd-1.0.3-r0 -libmount-2.37.4-r0 -libogg-1.3.5-r0 -libpciaccess-0.16-r0 -libpng-1.6.37-r1 -libpq-14.5-r0 -libproc-3.3.17-r0 -libretls-3.3.4-r3 -librsvg-2.50.7-r1 -libsrt-1.4.2-r1 -libssh-0.9.6-r1 -libssl1.1-1.1.1s-r1 -libstdc++-10.3.1_git20211027-r0 -libtasn1-4.18.0-r0 -libtheora-1.1.1-r16 -libucontext-1.1-r0 -libunistring-0.9.10-r1 -libuuid-2.37.4-r0 -libva-2.13.0-r0 -libvdpau-1.4-r0 -libvorbis-1.3.7-r0 -libvpx-1.10.0-r0 -libwebp-1.2.2-r0 -libx11-1.7.3.1-r0 -libxau-1.0.9-r0 -libxcb-1.14-r2 -libxdmcp-1.1.3-r0 -libxext-1.3.4-r0 -libxfixes-6.0.0-r0 -libxft-2.3.4-r0 -libxml2-2.9.14-r2 -libxrender-0.9.10-r3 -linux-pam-1.5.2-r0 -logrotate-3.18.1-r4 -musl-1.2.2-r7 -musl-utils-1.2.2-r7 -nano-5.9-r0 -ncurses-libs-6.3_p20211120-r1 -ncurses-terminfo-base-6.3_p20211120-r1 -nettle-3.7.3-r0 -nghttp2-libs-1.46.0-r0 -nginx-1.20.2-r1 -nodejs-16.17.1-r0 -oniguruma-6.9.7.1-r0 -openssl-1.1.1s-r1 -opus-1.3.1-r1 -p11-kit-0.24.0-r1 -pango-1.48.10-r0 -pcre-8.45-r1 -pcre2-10.40-r0 -php8-8.0.25-r0 -php8-common-8.0.25-r0 -php8-fileinfo-8.0.25-r0 -php8-fpm-8.0.25-r0 -php8-mbstring-8.0.25-r0 -php8-openssl-8.0.25-r0 -php8-session-8.0.25-r0 -php8-simplexml-8.0.25-r0 -php8-xml-8.0.25-r0 -php8-xmlwriter-8.0.25-r0 -pixman-0.40.0-r4 -pkgconf-1.8.0-r0 -popt-1.18-r0 -procps-3.3.17-r0 -readline-8.1.1-r0 -ruby-3.0.4-r0 -ruby-bundler-2.2.33-r0 -ruby-libs-3.0.4-r0 -s6-ipcserver-2.11.0.0-r0 -scanelf-1.3.3-r0 -sdl2-2.0.16-r4 -shadow-4.8.1-r1 -shared-mime-info-2.1-r1 -skalibs-2.11.0.0-r0 -soxr-0.1.3-r2 -ssl_client-1.34.1-r7 -tiff-4.4.0-r0 -tzdata-2022c-r0 -utmps-0.1.0.3-r0 -v4l-utils-libs-1.22.1-r1 -vidstab-1.1.0-r1 -vulkan-loader-1.2.196-r0 -wayland-libs-client-1.19.0-r1 -x264-libs-20210613-r0 -x265-libs-3.5-r0 -xvidcore-1.3.7-r1 -xz-5.2.5-r1 -xz-libs-5.2.5-r1 -yaml-0.2.5-r0 -yarn-1.22.17-r0 -zlib-1.2.12-r3 -zstd-libs-1.5.0-r0 +NAME VERSION TYPE +@exodus/bytes 1.16.0 npm +@ioredis/commands 2.0.0 npm +@mastodon/mastodon UNKNOWN npm +@mastodon/streaming UNKNOWN npm +@opentelemetry/api 1.10.0 npm +@pinojs/redact 0.4.0 npm +@prometheus-io/client 0.16.1 npm +@rails/actiontext 8.1.401 npm +abbrev 0.1.2 gem +accepts 2.0.0 npm +acl-libs 2.3.2-r1 apk +action_text-trix 2.1.19 gem +actioncable 8.1.4.1 gem +actionmailbox 8.1.4.1 gem +actionmailer 8.1.4.1 gem +actionpack 8.1.4.1 gem +actiontext 8.1.4.1 gem +actionview 8.1.4.1 gem +active_model_serializers 0.10.16 gem +activejob 8.1.4.1 gem +activemodel 8.1.4.1 gem +activerecord 8.1.4.1 gem +activestorage 8.1.4.1 gem +activesupport 8.1.4.1 gem +ada-libs 4.0.0-r0 apk +addressable 2.10.0 gem +aes_key_wrap 1.1.0 gem +aligned 0.4.2 rust-crate +aligned-vec 0.6.4 rust-crate +alpine-baselayout 3.7.2-r1 apk +alpine-baselayout-data 3.7.2-r1 apk +alpine-keys 2.6-r0 apk +alpine-release 3.24.4-r0 apk +alsa-lib 1.2.15.3-r0 apk +android_key_attestation 0.3.0 gem +anstream 0.6.19 rust-crate +anstyle 1.0.11 rust-crate +anstyle-parse 0.2.7 rust-crate +anstyle-query 1.1.3 rust-crate +anyhow 1.0.98 rust-crate (+1 duplicate) +aom-libs 3.14.1-r0 apk +apache2-utils 2.4.71-r0 apk +apk-tools 3.0.9-r0 apk +apr 1.7.6-r0 apk +apr-util 1.6.4-r0 apk +arg_enum_proc_macro 0.3.4 rust-crate +argon2-libs 20190702-r5 apk +arrayvec 0.7.4 rust-crate +arrayvec 0.7.6 rust-crate +as-slice 0.2.1 rust-crate +async-function 1.0.0 npm +async-generator-function 1.0.0 npm +atomic-sleep 1.0.0 npm +attr_required 1.0.2 gem +av-metrics 0.9.1 rust-crate +av-scenechange 0.14.1 rust-crate +av1-grain 0.2.4 rust-crate +aws-eventstream 1.4.1 gem +aws-partitions 1.1312.0 gem +aws-sdk-core 3.272.0 gem +aws-sdk-kms 1.145.0 gem +aws-sdk-s3 1.245.2 gem +aws-sigv4 1.12.1 gem +azure-blob 0.5.9.1 gem +base58 0.2.3 gem +base64 0.3.0 gem (+1 duplicate) +bash 5.3.9-r1 apk +bcp-47 2.1.2 npm +bcp-47-match 2.0.3 npm +bcp47_spec 0.2.1 gem +bcrypt 3.1.22 gem +benchmark 0.5.0 gem (+1 duplicate) +bigdecimal 3.3.1 gem +bigdecimal 4.0.1 gem +bindata 2.5.1 gem +bintrees 1.0.2 npm +bitflags 2.4.1 rust-crate +bitflags 2.9.1 rust-crate +bitstream-io 2.6.0 rust-crate +bitstream-io 4.2.0 rust-crate +bitvec 1.0.1 rust-crate +bitvec_helpers 3.1.6 rust-crate +bloom_fit 1.2.0 gem +blurhash 0.1.8 gem +body-parser 2.4.0 npm +bootsnap 1.26.2 gem +brotli-libs 1.2.1-r0 apk +browser 6.2.0 gem +bubblewrap 0.12.0-r0 apk +builder 3.3.0 gem +bundler 4.0.20 gem +bundler 4.1.1 gem +busybox 1.37.0-r31 apk +busybox-binsh 1.37.0-r31 apk +bytemuck 1.14.0 rust-crate +bytes 3.1.2 npm +c-ares 1.34.9-r0 apk +ca-certificates 20261020-r0 apk +ca-certificates-bundle 20261020-r0 apk +cairo 1.18.4-r1 apk +call-bind-apply-helpers 1.0.2 npm +call-bound 1.0.4 npm +case_transform 0.2 gem +catatonit 0.2.1-r0 apk +cbor 0.6.2.2 gem +cfg-if 1.0.0 rust-crate +cfg-if 1.0.1 rust-crate +cfitsio 4.6.4-r0 apk +cgi 0.5.2 gem +cgif 0.5.4-r0 apk +charlock_holmes 0.7.9 gem +chewy 8.4.1 gem +chunky_png 1.4.0 gem +cjson 1.7.19-r1 apk +clap 4.5.40 rust-crate +clap_builder 4.5.40 rust-crate +clap_complete 4.5.54 rust-crate +clap_lex 0.7.5 rust-crate +climate_control 1.2.0 gem +cluster-key-slot 1.1.1 npm +cocoon 1.2.15 gem +color_diff 0.2 gem +colorchoice 1.0.4 rust-crate +composer 2.11.3 binary +concurrent-ruby 1.3.8 gem +concurrent_ruby UNKNOWN java-archive +connection_pool 3.0.3 gem +console 0.15.11 rust-crate +content-disposition 2.0.1 npm +content-type 2.1.0 npm +cookie 0.7.2 npm +cookie-signature 1.2.2 npm +core2 0.4.0 rust-crate +corepack 0.36.0 npm +coreutils 9.11-r0 apk +coreutils-env 9.11-r0 apk +coreutils-fmt 9.11-r0 apk +coreutils-sha512sum 9.11-r0 apk +cors 2.8.6 npm +cose 1.4.0 gem +crass 1.0.8 gem +crc 3.3.0 rust-crate +crc-catalog 2.4.0 rust-crate +crossbeam 0.8.4 rust-crate +crossbeam-channel 0.5.15 rust-crate +crossbeam-deque 0.8.3 rust-crate +crossbeam-deque 0.8.6 rust-crate +crossbeam-epoch 0.9.15 rust-crate +crossbeam-epoch 0.9.18 rust-crate +crossbeam-queue 0.3.12 rust-crate +crossbeam-utils 0.8.16 rust-crate +crossbeam-utils 0.8.21 rust-crate +css_parser 3.4.0 gem +csv 3.3.5 gem +csv 3.3.7 gem +curl 8.23.0-r0 apk +data-urls 8.0.0 npm +date 3.5.1 gem +date 3.6.0 gem +dbus-libs 1.16.2-r2 apk +debug 1.11.1 gem +debug 4.4.3 npm +decimal.js 10.6.0 npm +delegate 0.6.1 gem +denque 2.1.0 npm +depd 2.0.0 npm +devise 5.0.4 gem +devise-two-factor 6.4.1 gem +did_you_mean 2.0.0 gem +digest 3.2.1 gem +discard 2.0.0 gem +dolby_vision 3.3.2 rust-crate +domain_name 0.7.20261117 gem +doorkeeper 5.9.10 gem +dotenv 18.0.10 npm +dotenv 3.2.0 gem +drb 2.2.3 gem (+1 duplicate) +dunder-proto 1.0.1 npm +ee-first 1.1.1 npm +either 1.15.0 rust-crate +either 1.9.0 rust-crate +elastic-transport 8.6.0 gem +elasticsearch 8.19.3 gem +elasticsearch-api 8.19.3 gem +elasticsearch-dsl 0.1.10 gem +encodeurl 2.0.3 npm +english 0.8.1 gem +entities 9.0.0 npm +equator 0.4.2 rust-crate +erb 6.0.7 gem (+1 duplicate) +errno 0.3.12 rust-crate +error_highlight 0.7.2 gem +erubi 1.13.1 gem +es-define-property 1.0.1 npm +es-errors 1.3.0 npm +es-object-atoms 1.1.2 npm +escape-html 1.0.3 npm +et-orbi 1.4.2 gem +etag 1.8.1 npm +etc 1.4.6 gem +excon 1.12.0 gem +express 5.3.0 npm +faraday 2.15.1 gem +faraday-follow_redirects 0.5.0 gem +faraday-httpclient 2.0.2 gem +faraday-net_http 3.5.0 gem +fast_blank 1.0.1 gem +fastimage 2.4.3 gem +fcntl 1.3.0 gem +fern 0.7.1 rust-crate +ffi 1.17.4 gem +ffi-compiler 1.4.3 gem +ffmpeg 8.1.3-r0 apk +ffmpeg-libavcodec 8.1.3-r0 apk +ffmpeg-libavdevice 8.1.3-r0 apk +ffmpeg-libavfilter 8.1.3-r0 apk +ffmpeg-libavformat 8.1.3-r0 apk +ffmpeg-libavutil 8.1.3-r0 apk +ffmpeg-libswresample 8.1.3-r0 apk +ffmpeg-libswscale 8.1.3-r0 apk +fftw-double-libs 3.3.11-r0 apk +fiddle 1.1.8 gem +file 5.47-r2 apk +fileutils 1.8.0 gem +finalhandler 2.1.1 npm +find 0.2.0 gem +findutils 4.10.0-r1 apk +fog-core 2.6.0 gem +fog-json 1.5.0 gem +fog-openstack 1.1.5 gem +fontconfig 2.17.1-r1 apk +formatador 1.2.3 gem +forwardable 1.4.0 gem (+1 duplicate) +forwarded 0.2.0 npm +freetype 2.14.3-r0 apk +fresh 2.0.0 npm +fribidi 1.0.16-r3 apk +fugit 1.14.0 gem +function-bind 1.1.2 npm +funty 2.0.0 rust-crate +gdk-pixbuf 2.44.7-r1 apk +generator-function 2.0.1 npm +get-caller-file 2.0.5 npm +get-intrinsic 1.3.1 npm +get-proto 1.0.1 npm +getoptlong 0.2.1 gem +getrandom 0.3.3 rust-crate +git 2.54.1-r0 apk +git-init-template 2.54.1-r0 apk +glib 2.88.4-r0 apk +globalid 1.4.0 gem +glslang-libs 1.4.341.0-r0 apk +glycin-image-rs 2.1.5-r0 apk +glycin-svg 2.1.5-r0 apk +gmp 6.3.0-r4 apk +google-protobuf 4.36.2 gem +googleapis-common-protos-types 1.25.0 gem +gopd 1.2.0 npm +graphite2 1.3.14-r6 apk +haml 7.5.2 gem +haml-rails 3.1.0 gem +harfbuzz 13.2.1-r0 apk +has-symbols 1.1.0 npm +hashie 5.2.0 gem +hasown 2.0.4 npm +hcaptcha 7.1.0 gem +hiredis-client 0.31.0 gem +hkdf 0.3.0 gem +html-encoding-sniffer 7.0.0 npm +htmlentities 4.4.2 gem +http 5.3.1 gem +http-cookie 1.1.6 gem +http-errors 2.0.1 npm +http-form_data 2.3.0 gem +http_accept_language 2.1.1 gem +httpclient 2.11.0 gem +httplog 1.8.0 gem +hwdata-pci 0.408-r0 apk +i18n 1.15.2 gem +iconv-lite 0.7.3 npm +icu-data-en 78.1-r0 apk +icu-libs 78.1-r0 apk +idn-ruby 0.1.5 gem +imagequant 4.2.2 rust-crate +imagequant-sys 4.0.3 rust-crate +imath 3.2.2-r1 apk +inherits 2.0.4 npm +inline_svg 1.10.0 gem +interpolate_name 0.2.4 rust-crate +io-console 0.8.2 gem +io-console 0.9.5 gem +io-nonblock 0.3.2 gem +io-wait 0.4.0 gem +ioredis 6.0.0 npm +ipaddr 1.2.8 gem +ipaddr 1.3.1 gem +ipaddr.js 1.9.1 npm +irb 1.16.0 gem +irb 1.19.0 gem +is-alphabetical 2.0.1 npm +is-alphanumerical 2.0.1 npm +is-decimal 2.0.1 npm +is-potential-custom-element-name 1.0.1 npm +is-promise 4.0.0 npm +is_terminal_polyfill 1.70.1 rust-crate +itertools 0.10.5 rust-crate +itertools 0.14.0 rust-crate +ivf 0.1.4 rust-crate +jd-paperclip-azure 3.0.0 gem +jmespath 1.6.2 gem +jq 1.8.2-r0 apk +jsdom 31.0.1 npm +json 2.18.3 gem +json 2.21.2 gem +json-c 0.18-r1 apk +json-canonicalization 1.0.0 gem +json-jwt 1.17.2 gem +json-ld 3.3.2 gem +json-ld-preloaded 3.3.2 gem +jsonapi-renderer 0.2.2 gem +jwt 2.10.3 gem +kaminari 1.3.3 gem +kaminari-actionview 1.3.3 gem +kaminari-activerecord 1.3.3 gem +kaminari-core 1.3.3 gem +kt-paperclip 8.0.1 gem +lab 0.11.0 rust-crate +lame-libs 3.100-r5 apk +lcms2 2.19-r0 apk +libSvtAv1Enc 4.1.0-r0 apk +libapk 3.0.9-r0 apk +libarchive 3.8.11-r0 apk +libass 0.17.4-r1 apk +libasyncns 0.8-r5 apk +libattr 2.5.2-r2 apk +libblkid 2.42.3-r1 apk +libbluray 1.4.0-r0 apk +libbsd 0.12.2-r0 apk +libbz2 1.0.8-r6 apk +libc 0.2.154 rust-crate +libc 0.2.172 rust-crate (+1 duplicate) +libcap2 2.78-r0 apk +libcrypto3 3.5.9-r2 apk +libcurl 8.23.0-r0 apk +libdav1d 1.5.3-r0 apk +libde265 1.1.3-r0 apk +libdeflate 1.25-r0 apk +libdovi 3.3.2-r0 apk +libdrm 2.4.134-r0 apk +libdvdcss 1.4.3-r0 apk +libdvdnav 6.1.1-r1 apk +libdvdread 6.1.3-r2 apk +libeconf 0.8.3-r0 apk +libedit 20260508.3.1-r1 apk +libexif 0.6.26-r0 apk +libexpat 2.11.0-r0 apk +libffi 3.8.2-r0 apk +libflac 1.4.3-r2 apk +libgcc 15.2.0-r5 apk +libglycin 2.1.5-r0 apk +libgomp 15.2.0-r5 apk +libheif 1.23.7-r0 apk +libheif-aom 1.23.7-r0 apk +libheif-dav1d 1.23.7-r0 apk +libheif-ffmpeg 1.23.7-r0 apk +libheif-jpeg 1.23.7-r0 apk +libheif-libde265 1.23.7-r0 apk +libheif-openjpeg 1.23.7-r0 apk +libheif-rav1e 1.23.7-r0 apk +libheif-svtenc 1.23.7-r0 apk +libheif-x264 1.23.7-r0 apk +libheif-x265 1.23.7-r0 apk +libhwy 1.3.0-r0 apk +libidn 1.43-r0 apk +libidn2 2.3.8-r0 apk +libimagequant 4.2.2-r0 apk +libintl 1.0-r0 apk +libjpeg-turbo 3.1.3-r0 apk +libjxl 0.11.2-r1 apk +libltdl 2.6.0-r1 apk +libmagic 5.47-r2 apk +libmd 1.2.0-r0 apk +libmount 2.42.3-r1 apk +libncursesw 6.6_p20260516-r0 apk +libogg 1.3.6-r0 apk +libopenmpt 0.8.10-r0 apk +libpciaccess 0.19-r0 apk +libplacebo 7.360.1-r0 apk +libpng 1.6.59-r0 apk +libpq 18.7-r0 apk +libproc2 4.0.6-r0 apk +libpsl 0.21.5-r3 apk +libpulse 17.0-r7 apk +librist 0.2.15-r0 apk +librsvg 2.62.3-r0 apk +libseccomp 2.6.1-r0 apk +libsharpyuv 1.6.0-r0 apk +libsndfile 1.2.2-r2 apk +libsodium 1.0.22-r0 apk +libsrt 1.5.3-r1 apk +libssh 0.12.2-r0 apk +libssl3 3.5.9-r2 apk +libstdc++ 15.2.0-r5 apk +libtheora 1.2.0-r1 apk +libudfread 1.2.0-r1 apk +libunibreak 6.1-r0 apk +libunistring 1.4.2-r0 apk +libuuid 2.42.3-r1 apk +libva 2.23.0-r0 apk +libvdpau 1.5-r4 apk +libvorbis 1.3.7-r2 apk +libvpl 2.15.0-r1 apk +libvpx 1.15.2-r1 apk +libwebp 1.6.0-r0 apk +libwebpdemux 1.6.0-r0 apk +libwebpmux 1.6.0-r0 apk +libx11 1.8.14-r0 apk +libxau 1.0.12-r0 apk +libxcb 1.17.0-r2 apk +libxdmcp 1.1.5-r1 apk +libxext 1.3.7-r0 apk +libxfixes 6.0.2-r0 apk +libxft 2.3.9-r0 apk +libxml2 2.13.9-r5 apk +libxrender 0.9.13-r0 apk +libzip 1.11.4-r2 apk +libzmq 4.3.5-r2 apk +lilv-libs 0.24.26-r1 apk +link_header 0.0.8 gem +linux-pam 1.7.1-r2 apk +linux-raw-sys 0.9.4 rust-crate +linzer 0.8.1 gem +llhttp-ffi 0.5.1 gem +log 0.4.27 rust-crate +logger 1.7.0 gem (+1 duplicate) +lograge 0.16.0 gem +logrotate 3.22.0-r0 apk +loofah 2.25.3 gem +lru-cache 11.5.3 npm +lz4-libs 1.10.0-r1 apk +mail 2.9.1 gem +marcel 1.2.1 gem +mario-redis-lock 1.2.1 gem +math-intrinsics 1.1.0 npm +matrix 0.4.3 gem +maybe-rayon 0.1.1 rust-crate +mbedtls3 3.6.8-r0 apk +media-typer 1.1.1 npm +memchr 2.7.5 rust-crate +memoffset 0.9.0 rust-crate +merge-descriptors 2.0.0 npm +mime-db 1.54.0 npm +mime-types 3.0.2 npm +mime-types 3.7.0 gem +mime-types-data 3.2026.1103 gem +mini_mime 1.1.5 gem +minimal-lexical 0.2.1 rust-crate +minitest 6.0.0 gem +minitest 6.1.0 gem +mpg123-libs 1.33.5-r0 apk +ms 2.1.3 npm +msgpack 1.8.7 gem +multi_json 1.21.2 gem +musl 1.2.6-r3 apk +musl-utils 1.2.6-r3 apk +mutex_m 0.3.0 gem (+1 duplicate) +nano 9.3-r0 apk +ncurses-terminfo-base 6.6_p20260516-r0 apk +negotiator 1.1.0 npm +net-ftp 0.3.9 gem +net-http 0.9.1 gem (+1 duplicate) +net-imap 0.6.4.1 gem +net-imap 0.6.8 gem +net-ldap 0.21.0 gem +net-pop 0.1.2 gem (+1 duplicate) +net-protocol 0.2.2 gem +net-protocol 0.4.0 gem +net-smtp 0.5.1 gem +net-smtp 0.5.2 gem +netcat-openbsd 1.234.1-r0 apk +new_debug_unreachable 1.0.6 rust-crate +nghttp2-libs 1.70.0-r0 apk +nginx 1.30.8-r0 apk +nio4r 2.7.5 gem +nkf 0.2.0 gem +nodejs 24.22.3-r0 apk +nokogiri 1.19.7 gem +nom 7.1.3 rust-crate +nom 8.0.0 rust-crate +noop_proc_macro 0.3.0 rust-crate +num-bigint 0.4.6 rust-crate +num-derive 0.4.2 rust-crate +num-integer 0.1.46 rust-crate +num-rational 0.4.2 rust-crate +num-traits 0.2.19 rust-crate +numactl 2.0.19-r0 apk +object-assign 4.1.1 npm +object-inspect 1.14.0 npm +observer 0.1.2 gem +omniauth 2.4.2 gem +omniauth-cas 3.0.2 gem +omniauth-rails_csrf_protection 2.0.1 gem +omniauth-saml 2.2.5 gem +omniauth_openid_connect 0.8.0 gem +on-exit-leak-free 2.1.2 npm +on-finished 2.4.2 npm +once 1.4.0 npm +once_cell 1.18.0 rust-crate +once_cell 1.21.3 rust-crate +oniguruma 6.9.10-r0 apk +open-uri 0.5.0 gem +open3 0.2.1 gem +openexr-libiex 3.4.15-r0 apk +openexr-libilmthread 3.4.15-r0 apk +openexr-libopenexr 3.4.15-r0 apk +openexr-libopenexrcore 3.4.15-r0 apk +openid_connect 2.5.0 gem +openjpeg 2.5.4-r2 apk +openssl 3.5.9-r2 apk +openssl 4.0.2 gem (+1 duplicate) +openssl-signature_algorithm 1.3.0 gem +opentelemetry-api 1.11.1 gem +opentelemetry-common 0.25.2 gem +opentelemetry-exporter-otlp 0.37.0 gem +opentelemetry-exporter-otlp-common 0.4.0 gem +opentelemetry-helpers-sql 0.4.0 gem +opentelemetry-helpers-sql-processor 0.5.1 gem +opentelemetry-instrumentation-action_mailer 0.8.1 gem +opentelemetry-instrumentation-action_pack 0.18.1 gem +opentelemetry-instrumentation-action_view 0.13.0 gem +opentelemetry-instrumentation-active_job 0.13.0 gem +opentelemetry-instrumentation-active_model_serializers 0.25.0 gem +opentelemetry-instrumentation-active_record 0.13.0 gem +opentelemetry-instrumentation-active_storage 0.5.1 gem +opentelemetry-instrumentation-active_support 0.12.1 gem +opentelemetry-instrumentation-base 0.27.0 gem +opentelemetry-instrumentation-concurrent_ruby 0.25.0 gem +opentelemetry-instrumentation-excon 0.29.1 gem +opentelemetry-instrumentation-faraday 0.33.0 gem +opentelemetry-instrumentation-http 0.30.0 gem +opentelemetry-instrumentation-http_client 0.29.1 gem +opentelemetry-instrumentation-net_http 0.30.0 gem +opentelemetry-instrumentation-pg 0.37.1 gem +opentelemetry-instrumentation-rack 0.32.0 gem +opentelemetry-instrumentation-rails 0.42.0 gem +opentelemetry-instrumentation-redis 0.29.0 gem +opentelemetry-instrumentation-sidekiq 0.29.0 gem +opentelemetry-logs-api 0.7.0 gem +opentelemetry-metrics-api 0.10.0 gem +opentelemetry-registry 0.6.3 gem +opentelemetry-sdk 1.13.1 gem +opentelemetry-semantic_conventions 1.44.0 gem +optparse 0.8.1 gem +opus 1.6.1-r0 apk +orc 0.4.41-r0 apk +orm_adapter 0.5.0 gem +ostruct 0.6.3 gem (+1 duplicate) +ox 2.14.30 gem +pango 1.57.1-r0 apk +parse5 8.1.1 npm +parse5-parser-stream 8.1.1 npm +parseurl 1.3.3 npm +parslet 2.0.0 gem +paste 1.0.15 rust-crate +pastel 0.8.0 gem +pastey 0.1.0 rust-crate +path-to-regexp 8.4.2 npm +pcre2 10.49-r0 apk +pg 1.7.0 gem +pg 8.23.1 npm +pg-cloudflare 1.4.1 npm +pg-connection-string 2.14.1 npm +pg-int8 1.0.1 npm +pg-pool 3.14.0 npm +pg-protocol 1.16.1 npm +pg-types 2.2.0 npm +pghero 4.1.0 gem +pgpass 1.0.5 npm +php85 8.5.13-r0 apk +php85-common 8.5.13-r0 apk +php85-ctype 8.5.13-r0 apk +php85-curl 8.5.13-r0 apk +php85-fileinfo 8.5.13-r0 apk +php85-fpm 8.5.13-r0 apk +php85-iconv 8.5.13-r0 apk +php85-mbstring 8.5.13-r0 apk +php85-openssl 8.5.13-r0 apk +php85-phar 8.5.13-r0 apk +php85-session 8.5.13-r0 apk +php85-simplexml 8.5.13-r0 apk +php85-xml 8.5.13-r0 apk +php85-xmlwriter 8.5.13-r0 apk +php85-zip 8.5.13-r0 apk +pino 10.4.0 npm +pino-abstract-transport 3.0.0 npm +pino-http 11.0.0 npm +pino-std-serializers 7.1.0 npm +pixman 0.46.4-r0 apk +pkgconf 2.5.1-r0 apk +popt 1.19-r4 apk +postgres-array 2.0.0 npm +postgres-bytea 1.0.1 npm +postgres-date 1.0.7 npm +postgres-interval 1.2.0 npm +power_assert 3.0.1 gem +pp 0.6.3 gem +pp 0.6.4 gem +ppv-lite86 0.2.21 rust-crate +premailer 1.33.0 gem +premailer-rails 1.12.0 gem +prettyprint 0.2.0 gem +prettyprint 0.2.1 gem +prime 0.1.4 gem +prism 1.8.2 gem +prism 2.1.0 gem +proc-macro2 1.0.95 rust-crate +process-warning 5.1.1 npm +procps-ng 4.0.6-r0 apk +profiling 1.0.16 rust-crate +prometheus_exporter 2.3.1 gem +propshaft 1.3.2 gem +proxy-addr 2.0.8 npm +pstore 0.2.1 gem +psych 5.3.1 gem +public_suffix 7.1.0 gem +puma 8.1.3 gem +pundit 2.5.2 gem +punycode 2.3.1 npm +qs 6.17.1 npm +quick-format-unescaped 4.0.4 npm +quote 1.0.40 rust-crate +raabro 1.5.0 gem +racc 1.8.1 gem (+1 duplicate) +rack 3.2.9 gem +rack-attack 6.8.0 gem +rack-cors 3.0.0 gem +rack-oauth2 2.3.0 gem +rack-protection 4.2.2 gem +rack-proxy 2.0.2 gem +rack-session 2.1.2 gem +rack-test 2.3.0 gem +rackup 2.3.1 gem +radium 0.7.0 rust-crate +rails 8.1.4.1 gem +rails-dom-testing 2.3.0 gem +rails-html-sanitizer 1.7.2 gem +rails-i18n 8.1.0 gem +railties 8.1.4.1 gem +rainbow 3.1.1 gem +rake 13.3.1 gem +rake 13.4.2 gem +rand 0.9.1 rust-crate +rand_chacha 0.9.0 rust-crate +rand_core 0.9.3 rust-crate +range-parser 1.3.0 npm +rav1e 0.8.1 rust-crate +rav1e-libs 0.8.1-r0 apk +raw-body 3.0.2 npm +rayon 1.10.0 rust-crate +rayon 1.8.0 rust-crate +rayon-core 1.12.0 rust-crate +rayon-core 1.12.1 rust-crate +rbs 3.10.0 gem +rbs 4.2.0 gem +rdf 3.3.4 gem +rdf-normalize 0.7.0 gem +rdoc 7.0.4 gem +rdoc 8.1.0 gem +readline 0.0.4 gem (+1 duplicate) +readline 8.3.3-r1 apk +real-require 1.0.0 npm +redcarpet 3.6.1 gem +redis 6.1.1 gem +redis-client 0.31.0 gem +redis-errors 1.2.0 npm +reline 0.6.3 gem +reline 0.7.0 gem +repl_type_completor 0.1.12 gem +request_store 1.7.0 gem +resolv 0.7.2 gem +resolv-replace 0.1.1 gem +responders 3.2.1 gem +rexml 3.4.4 gem (+1 duplicate) +rgb 0.8.36 rust-crate +rinda 0.2.0 gem +rotp 6.4.0 gem +router 2.3.0 npm +rqrcode 3.2.0 gem +rqrcode_core 2.1.0 gem +rss 0.3.2 gem +ruby 4.0.10 binary +ruby-progressbar 1.13.0 gem +ruby-saml 1.18.1 gem +ruby-vips 2.3.0 gem +ruby2_keywords 0.0.5 gem +rubyzip 3.7.0 gem +rufus-scheduler 3.9.2 gem +rustix 1.0.7 rust-crate +safe-stable-stringify 2.5.0 npm +safer-buffer 2.1.2 npm +safety_net_attestation 0.5.0 gem +sanitize 7.0.2 gem +saxes 6.0.0 npm +scan_fmt 0.2.6 rust-crate +scanelf 1.3.9-r1 apk +scenic 1.9.0 gem +scopeguard 1.2.0 rust-crate +securerandom 0.4.1 gem (+1 duplicate) +send 1.2.1 npm +serd-libs 0.32.8-r0 apk +serve-static 2.2.1 npm +setprototypeof 1.2.0 npm +shaderc 2026.1-r0 apk +shadow 4.18.0-r1 apk +shared-mime-info 2.4-r7 apk +shellwords 0.2.2 gem +side-channel 1.1.1 npm +side-channel-list 1.0.1 npm +side-channel-map 1.0.1 npm +side-channel-weakmap 1.0.2 npm +sidekiq 8.1.7 gem +sidekiq-bulk 0.2.0 gem +sidekiq-scheduler 6.0.2 gem +sidekiq-unique-jobs 8.1.0 gem +signal-hook 0.3.18 rust-crate +signal-hook-registry 1.4.5 rust-crate +simd_helpers 0.1.0 rust-crate +simdjson 4.2.4-r0 apk +simdutf 9.0.0-r0 apk +simple-navigation 4.5.0 gem +simple_form 5.4.1 gem +simpleidn 0.3.0 gem +singleton 0.3.0 gem +skalibs-libs 2.15.0.0-r0 apk +sonic-boom 4.2.1 npm +sord-libs 0.16.22-r0 apk +soxr 0.1.3-r7 apk +speexdsp 1.2.1-r2 apk +spirv-tools 1.4.341.0-r0 apk +split2 4.2.0 npm +sqlite-libs 3.53.4-r0 apk +sratom 0.6.20-r0 apk +ssl_client 1.37.0-r31 apk +ssrf_filter 1.6.0 gem +stable_deref_trait 1.2.0 rust-crate +standard-as-callback 2.1.0 npm +starry 0.2.0 gem +statuses 2.0.2 npm +stoplight 6.0.1 gem +stringio 3.2.0 gem +strong_migrations 2.8.0 gem +strscan 3.1.6 gem +swd 2.0.3 gem +syn 2.0.102 rust-crate +syntax_suggest 2.0.3 gem +syslog 0.3.0 gem +tap 1.0.1 rust-crate +tdb-libs 1.4.15-r1 apk +tdigest 0.1.3 npm +tempfile 0.3.1 gem +temple 0.10.7 gem +terminal_size 0.4.2 rust-crate +terrapin 1.1.1 gem +test-unit 3.7.5 gem +thiserror 1.0.69 rust-crate +thiserror 2.0.12 rust-crate +thor 1.5.0 gem +thread-stream 4.2.1 npm +thread_local 1.1.7 rust-crate +tiff 4.7.2-r0 apk +tilt 2.9.0 gem +time 0.4.2 gem +timeout 0.6.0 gem +timeout 0.6.1 gem +tinyvec 1.9.0 rust-crate +tldts 7.5.5 npm +tldts-core 7.5.5 npm +tmpdir 0.3.1 gem +toidentifier 1.0.1 npm +tough-cookie 6.1.0 npm +tpm-key_attestation 0.14.2 gem +tr46 7.0.0 npm +transport 0.0.1 npm +tsort 0.2.0 gem (+1 duplicate) +tty-color 0.6.0 gem +tty-cursor 0.7.1 gem +tty-prompt 0.23.1 gem +tty-reader 0.9.0 gem +tty-screen 0.8.2 gem +type-is 2.1.0 npm +typeprof 0.31.1 gem +tzdata 2026f-r0 apk +tzinfo 2.0.6 gem +tzinfo-data 1.2026.6 gem +un 0.3.0 gem +undici 8.13.1 npm +unicode-ident 1.0.18 rust-crate +unicode-width 0.2.1 rust-crate +unpipe 1.0.0 npm +uri 1.1.1 gem +uri 1.1.2 gem +useragent 0.16.11 gem +utf8parse 0.2.2 rust-crate +utmps-libs 0.1.3.3-r0 apk +uts58 0.2.6 gem +v4l-utils-libs 1.32.0-r1 apk +v_frame 0.3.9 rust-crate +validate_url 1.0.15 gem +vary 1.1.2 npm +vidstab 1.1.1-r0 apk +vips 8.18.2-r0 apk +vips-heif 8.18.2-r0 apk +vips-jxl 8.18.2-r0 apk +vulkan-loader 1.4.347-r0 apk +w3c-xmlserializer 6.0.0 npm +warden 1.2.9 gem +wayland-libs-client 1.25.0-r0 apk +weakref 0.1.4 gem +webauthn 3.5.1 gem +webfinger 2.1.3 gem +webidl-conversions 8.0.1 npm +webrick 1.9.2 gem +websocket-driver 0.9.1 gem +websocket-extensions 0.3.0 gem +whatwg-mimetype 5.0.0 npm +whatwg-url 17.3.0 npm +wisper 2.0.1 gem +wrappy 1.0.2 npm +ws 8.23.0 npm +wyz 0.5.1 rust-crate +x264-libs 0.164.3108-r1 apk +x265-libs 4.1-r0 apk +xml-name-validator 5.0.0 npm +xmlchars 2.2.0 npm +xorcist 1.1.3 gem +xtend 4.0.2 npm +xvidcore 1.3.7-r2 apk +xz-libs 5.8.4-r0 apk +y4m 0.8.0 rust-crate +yaml 0.2.5-r2 apk +yaml 0.4.0 gem +zeitwerk 2.8.3 gem +zerocopy 0.8.25 rust-crate +zimg 3.0.6-r0 apk +zix-libs 0.8.0-r0 apk +zlib 1.4-r0 apk +zlib 3.2.3 gem +zstd-libs 1.6.0-r1 apk diff --git a/readme-vars.yml b/readme-vars.yml index edd4167..9042979 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -6,68 +6,88 @@ project_url: "https://github.com/mastodon/mastodon/" project_logo: "https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/mastodon-banner.png" project_blurb: | [{{ project_name|capitalize }}]({{ project_url }}) is a free, open-source social network server based on ActivityPub where users can follow friends and discover new ones.. - project_lsio_github_repo_url: "https://github.com/linuxserver/docker-{{ project_name }}" - # supported architectures available_architectures: - - { arch: "{{ arch_x86_64 }}", tag: "amd64-latest"} - - { arch: "{{ arch_arm64 }}", tag: "arm64v8-latest"} - + - {arch: "{{ arch_x86_64 }}", tag: "amd64-latest"} + - {arch: "{{ arch_arm64 }}", tag: "arm64v8-latest"} +# development version +development_versions: true +development_versions_items: + - {tag: "latest", desc: "Stable releases."} + - {tag: "develop", desc: "Pre-releases *only*."} + - {tag: "glitch", desc: "[glitch-soc](https://github.com/glitch-soc/mastodon) fork releases."} # container parameters common_param_env_vars_enabled: true param_container_name: "{{ project_name }}" - param_usage_include_env: true param_env_vars: - - { env_var: "TZ", env_value: "America/New_York", desc: "Specify a timezone to use EG America/New_York"} - - { env_var: "LOCAL_DOMAIN", env_value: "example.com", desc: "This is the unique identifier of your server in the network. It cannot be safely changed later."} - - { env_var: "REDIS_HOST", env_value: "redis", desc: "Redis server hostname"} - - { env_var: "REDIS_PORT", env_value: "6379", desc: "Redis port"} - - { env_var: "DB_HOST", env_value: "db", desc: "Postgres database hostname"} - - { env_var: "DB_USER", env_value: "mastodon", desc: "Postgres username"} - - { env_var: "DB_NAME", env_value: "mastodon", desc: "Postgres db name"} - - { env_var: "DB_PASS", env_value: "mastodon", desc: "Postgres password"} - - { env_var: "DB_PORT", env_value: "5432", desc: "Portgres port"} - - { env_var: "ES_ENABLED", env_value: "false", desc: "Enable or disable Elasticsearch (requires a separate ES instance)"} - - { env_var: "SECRET_KEY_BASE", env_value: "", desc: "Browser session secret. Changing it will break all active browser sessions."} - - { env_var: "OTP_SECRET", env_value: "", desc: "MFA secret. Changing it will break two-factor authentication."} - - { env_var: "VAPID_PRIVATE_KEY", env_value: "", desc: "Push notification private key. Changing it will break push notifications."} - - { env_var: "VAPID_PUBLIC_KEY", env_value: "", desc: "Push notification public key. Changing it will break push notifications."} - - { env_var: "SMTP_SERVER", env_value: "mail.example.com", desc: "SMTP server for email notifications"} - - { env_var: "SMTP_PORT", env_value: "25", desc: "SMTP server port"} - - { env_var: "SMTP_LOGIN", env_value: "", desc: "SMTP username"} - - { env_var: "SMTP_PASSWORD", env_value: "", desc: "SMTP password"} - - { env_var: "SMTP_FROM_ADDRESS", env_value: "notifications@example.com", desc: "From address for emails send from Mastodon"} - - { env_var: "S3_ENABLED", env_value: "false", desc: "Enable or disable S3 storage of uploaded files"} - + - {env_var: "LOCAL_DOMAIN", env_value: "example.com", desc: "This is the unique identifier of your server in the network. It cannot be safely changed later."} + - {env_var: "REDIS_HOST", env_value: "redis", desc: "Redis server hostname"} + - {env_var: "REDIS_PORT", env_value: "6379", desc: "Redis port"} + - {env_var: "DB_HOST", env_value: "db", desc: "Postgres database hostname"} + - {env_var: "DB_USER", env_value: "mastodon", desc: "Postgres username"} + - {env_var: "DB_NAME", env_value: "mastodon", desc: "Postgres db name"} + - {env_var: "DB_PASS", env_value: "mastodon", desc: "Postgres password"} + - {env_var: "DB_PORT", env_value: "5432", desc: "Postgres port"} + - {env_var: "ES_ENABLED", env_value: "false", desc: "Enable or disable Elasticsearch (requires a separate ES instance)"} + - {env_var: "ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY", env_value: "", desc: "Primary key for [Active Record Encryption](https://github.com/mastodon/mastodon/pull/29831/files)."} + - {env_var: "ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY", env_value: "", desc: "Deterministic key for [Active Record Encryption](https://github.com/mastodon/mastodon/pull/29831/files)."} + - {env_var: "ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT", env_value: "", desc: "Derivation salt for [Active Record Encryption](https://github.com/mastodon/mastodon/pull/29831/files)."} + - {env_var: "SECRET_KEY_BASE", env_value: "", desc: "Browser session secret. Changing it will break all active browser sessions."} + - {env_var: "OTP_SECRET", env_value: "", desc: "MFA secret. Changing it will break two-factor authentication."} + - {env_var: "VAPID_PRIVATE_KEY", env_value: "", desc: "Push notification private key. Changing it will break push notifications."} + - {env_var: "VAPID_PUBLIC_KEY", env_value: "", desc: "Push notification public key. Changing it will break push notifications."} + - {env_var: "SMTP_SERVER", env_value: "mail.example.com", desc: "SMTP server for email notifications"} + - {env_var: "SMTP_PORT", env_value: "25", desc: "SMTP server port"} + - {env_var: "SMTP_LOGIN", env_value: "", desc: "SMTP username"} + - {env_var: "SMTP_PASSWORD", env_value: "", desc: "SMTP password"} + - {env_var: "SMTP_FROM_ADDRESS", env_value: "notifications@example.com", desc: "From address for emails send from Mastodon"} + - {env_var: "S3_ENABLED", env_value: "false", desc: "Enable or disable S3 storage of uploaded files"} opt_param_usage_include_env: true opt_param_env_vars: - - { env_var: "WEB_DOMAIN", env_value: "mastodon.example.com", desc: "This can be set if you want your server identifier to be different to the subdomain hosting Mastodon. See https://docs.joinmastodon.org/admin/config/#basic"} - - { env_var: "ES_HOST", env_value: "es", desc: "Elasticsearch server hostname"} - - { env_var: "ES_PORT", env_value: "9200", desc: "Elasticsearch port"} - - { env_var: "ES_USER", env_value: "elastic", desc: "Elasticsearch username"} - - { env_var: "ES_PASS", env_value: "elastic", desc: "Elasticsearch password"} - - { env_var: "S3_BUCKET", env_value: "", desc: "S3 bucket hostname"} - - { env_var: "AWS_ACCESS_KEY_ID", env_value: "", desc: "S3 bucket access key ID"} - - { env_var: "AWS_SECRET_ACCESS_KEY", env_value: "", desc: "S3 bucket secret access key"} - - { env_var: "S3_ALIAS_HOST", env_value: "", desc: "Alternate hostname for object fetching if you are front the S3 connections."} - + - {env_var: "WEB_DOMAIN", env_value: "mastodon.example.com", desc: "This can be set if you want your server identifier to be different to the subdomain hosting Mastodon. See [https://docs.joinmastodon.org/admin/config/#basic](https://docs.joinmastodon.org/admin/config/#basic)"} + - {env_var: "ES_HOST", env_value: "es", desc: "Elasticsearch server hostname"} + - {env_var: "ES_PORT", env_value: "9200", desc: "Elasticsearch port"} + - {env_var: "ES_USER", env_value: "elastic", desc: "Elasticsearch username"} + - {env_var: "ES_PASS", env_value: "elastic", desc: "Elasticsearch password"} + - {env_var: "S3_BUCKET", env_value: "", desc: "S3 bucket hostname"} + - {env_var: "AWS_ACCESS_KEY_ID", env_value: "", desc: "S3 bucket access key ID"} + - {env_var: "AWS_SECRET_ACCESS_KEY", env_value: "", desc: "S3 bucket secret access key"} + - {env_var: "S3_ALIAS_HOST", env_value: "", desc: "Alternate hostname for object fetching if you are front the S3 connections."} + - {env_var: "SIDEKIQ_ONLY", env_value: "false", desc: "Only run the sidekiq service in this container instance. For large scale instances that need better queue handling."} + - {env_var: "SIDEKIQ_QUEUE", env_value: "", desc: "The name of the sidekiq queue to run in this container. See [notes](https://docs.joinmastodon.org/admin/scaling/#sidekiq-queues)."} + - {env_var: "SIDEKIQ_DEFAULT", env_value: "false", desc: "Set to `true` on the main container if you're running additional sidekiq instances. It will run the `default` queue."} + - {env_var: "SIDEKIQ_THREADS", env_value: "5", desc: "The number of threads for sidekiq to use. See [notes](https://docs.joinmastodon.org/admin/scaling/#sidekiq-threads)."} + - {env_var: "DB_POOL", env_value: "5", desc: "The size of the DB connection pool, must be *at least* the same as `SIDEKIQ_THREADS`. See [notes](https://docs.joinmastodon.org/admin/scaling/#sidekiq-threads)."} + - {env_var: "NO_CHOWN", env_value: "", desc: "Set to `true` to skip chown of /config on init. *READ THE APPLICATION NOTES BEFORE SETTING THIS*."} + - {env_var: "MASTODON_PROMETHEUS_EXPORTER_ENABLED", env_value: "", desc: "If set to `true`, Mastodon’s Ruby processes (web & Sidekiq) will enable the Prometheus instrumentation."} param_usage_include_ports: true param_ports: - - { external_port: "80", internal_port: "80", port_desc: "Port for web frontend" } - - { external_port: "443", internal_port: "443", port_desc: "Port for web frontend" } - + - {external_port: "80", internal_port: "80", port_desc: "Port for web frontend"} + - {external_port: "443", internal_port: "443", port_desc: "Port for web frontend"} +opt_param_usage_include_ports: true +opt_param_ports: + - {external_port: "9394", internal_port: "9394", port_desc: "Port for Prometheus metrics"} param_usage_include_vols: true param_volumes: - - { vol_path: "/config", vol_host_path: "/path/to/appdata/config", desc: "Contains all relevant configuration files." } - + - {vol_path: "/config", vol_host_path: "/path/to/{{ project_name }}/config", desc: "Contains all relevant configuration files."} # application setup block app_setup_block_enabled: true app_setup_block: | - To generate keys for `SECRET_KEY_BASE` & `OTP_SECRET` run `docker run --rm -it -w /app/www --entrypoint rake lscr.io/linuxserver/mastodon secret` once for each. + We provide aliases for the common commands that execute in the correct context so that environment variables from secrets are available to them: + + * To generate keys for `SECRET_KEY_BASE` & `OTP_SECRET` run `docker run --rm -it --entrypoint /bin/bash lscr.io/linuxserver/mastodon:{{ release_tag }} generate-secret` once for each. + + * To generate keys for `VAPID_PRIVATE_KEY` & `VAPID_PUBLIC_KEY` run `docker run --rm -it --entrypoint /bin/bash lscr.io/linuxserver/mastodon:{{ release_tag }} generate-vapid` + + * To generate keys for `ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY`, `ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT`, & `ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY` run `docker run --rm -it --entrypoint /bin/bash lscr.io/linuxserver/mastodon:{{ release_tag }} generate-active-record` - To generate keys for `VAPID_PRIVATE_KEY` & `VAPID_PUBLIC_KEY` run `docker run --rm -it -w /app/www --entrypoint rake lscr.io/linuxserver/mastodon mastodon:webpush:generate_vapid_key` + Both of the secret generation aliases above can be run without any other setup having been carried out. + + * To use `tootctl` you can run something like `docker exec -it lscr.io/linuxserver/mastodon /tootctl <command>` + + Using `tootctl` requires you to complete the initial Mastodon configuration first. This container *requires* separate postgres and redis instances to run. @@ -75,6 +95,100 @@ app_setup_block: | For more information check out the [mastodon documentation](https://docs.joinmastodon.org/). + ### Upgrade from 4.7 to 5.0 + + * Stop your running 4.7 container and pull the new image, make sure the DB and Redis are still running + * Run `docker compose run --rm -e SKIP_POST_DEPLOYMENT_MIGRATIONS=true --entrypoint /bin/bash mastodon migrate` + * Once the migrations are complete, start the Mastodon container as normal + + ### Running separate sidekiq instances + + It is currently only supported to run a single queue per container instance *or* all queues in a single container instance. + + All containers must share the same `/config` mount and be on a common docker network. + + ### NO_CHOWN Option + + On larger Mastodon instances, our init process to verify that permissions are set correctly can noticeably slow down the container startup. If you are experiencing this, you can set `NO_CHOWN` to `true` to skip that step of the init. + + *Do NOT set this on first run of the container. If you enable this option you are taking full responsibility for ensuring that the permissions in your /config mount are correct. If you're even slightly unsure, don't set it.* + + ### Strict reverse proxies + + This image automatically redirects to https with a self-signed certificate. If you are using a reverse proxy which validates certificates, you need to [disable this check for the container](https://docs.linuxserver.io/faq#strict-proxy). +# init diagram +init_diagram: | + "mastodon:develop": { + docker-mods + base { + fix-attr +\nlegacy cont-init + } + docker-mods -> base + legacy-services + custom services + init-services -> legacy-services + init-services -> custom services + custom services -> legacy-services + legacy-services -> ci-service-check + init-migrations -> init-adduser + init-nginx-end -> init-config + init-os-end -> init-config + init-config -> init-config-end + init-crontab-config -> init-config-end + init-mastodon-config -> init-config-end + init-config -> init-crontab-config + init-mods-end -> init-custom-files + init-adduser -> init-device-perms + base -> init-envfile + init-os-end -> init-folders + init-php -> init-keygen + init-nginx-end -> init-mastodon-config + base -> init-migrations + init-config-end -> init-mods + init-mods-package-install -> init-mods-end + init-mods -> init-mods-package-install + init-samples -> init-nginx + init-version-checks -> init-nginx-end + init-adduser -> init-os-end + init-device-perms -> init-os-end + init-envfile -> init-os-end + init-keygen -> init-permissions + init-nginx -> init-php + init-folders -> init-samples + init-custom-files -> init-services + init-permissions -> init-version-checks + init-services -> svc-cron + svc-cron -> legacy-services + init-services -> svc-mastodon + svc-mastodon -> legacy-services + init-services -> svc-nginx + svc-nginx -> legacy-services + init-services -> svc-php-fpm + svc-php-fpm -> legacy-services + init-services -> svc-prom + svc-prom -> legacy-services + init-services -> svc-sidekiq + svc-sidekiq -> legacy-services + init-services -> svc-streaming + svc-streaming -> legacy-services + } + Base Images: { + "baseimage-alpine-nginx:3.24" <- "baseimage-alpine:3.24" + } + "mastodon:develop" <- Base Images # changelog changelogs: - - { date: "05.11.22:", desc: "Initial Release." } \ No newline at end of file + - {date: "03.12.26:", desc: "Add migration helper for major version upgrades."} + - {date: "29.11.26:", desc: "Fetch Ruby from library image to match the version required by upstream."} + - {date: "18.11.26:", desc: "Build Ruby from source to match the version required by upstream."} + - {date: "05.07.26:", desc: "Rebase to Alpine 3.24."} + - {date: "21.10.25:", desc: "Add prometheus exporter support."} + - {date: "20.10.25:", desc: "Add vips-heif."} + - {date: "06.06.25:", desc: "Rebase to Alpine 3.22, replace deprecated imagemagick with vips."} + - {date: "26.08.24:", desc: "Rebase to Alpine 3.20, enable [Active Record Encryption](https://github.com/mastodon/mastodon/pull/29831/files). Existing users should update their nginx confs to avoid http2 deprecation warnings."} + - {date: "08.08.23:", desc: "Rebase to Alpine 3.18, migrate to s6v3"} + - {date: "09.02.23:", desc: "Add Glitch branch."} + - {date: "26.01.23:", desc: "Add aliases for key generation & tootctl to better support secrets."} + - {date: "19.12.22:", desc: "Support separate sidekiq queue instances."} + - {date: "08.11.22:", desc: "Add develop branch."} + - {date: "05.11.22:", desc: "Initial Release."} diff --git a/root-armhf/etc/cont-init.d/50-armless b/root-armhf/etc/cont-init.d/50-armless deleted file mode 100755 index a778fee..0000000 --- a/root-armhf/etc/cont-init.d/50-armless +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/with-contenv bash -# shellcheck shell=bash - -cat <<-EOF - ******************************************************** - ******************************************************** - * * - * !!!! * - * This Mastodon image does not support * - * 32 bit ARM for performance reasons * - * * - * * - ******************************************************** - ******************************************************** -EOF diff --git a/root/defaults/nginx/site-confs/default.conf.sample b/root/defaults/nginx/site-confs/default.conf.sample index 9c3fd5a..12a5ce2 100644 --- a/root/defaults/nginx/site-confs/default.conf.sample +++ b/root/defaults/nginx/site-confs/default.conf.sample @@ -1,4 +1,4 @@ -## Version 2022/11/07 - Changelog: https://github.com/linuxserver/docker-mastodon/commits/main/root/defaults/nginx/site-confs/default.conf.sample +## Version 2024/08/26 - Changelog: https://github.com/linuxserver/docker-mastodon/commits/develop/root/defaults/nginx/site-confs/default.conf.sample map $http_upgrade $connection_upgrade { default upgrade; @@ -18,12 +18,13 @@ proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=CACHE:10m inactive=7d max server { listen 80 default_server; listen [::]:80 default_server; - - listen 443 ssl http2 default_server; - listen [::]:443 ssl http2 default_server; + listen 443 ssl default_server; + listen [::]:443 ssl default_server; server_name _; + include /config/nginx/ssl.conf; + root /app/www/public; gzip on; @@ -95,7 +96,7 @@ server { try_files $uri =404; } - location ^~ /api/v1/streaming/ { + location ^~ /api/v1/streaming { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config deleted file mode 100755 index 28a0db1..0000000 --- a/root/etc/cont-init.d/50-config +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/with-contenv bash -# shellcheck shell=bash - -mkdir -p \ - /app/www/tmp \ - /config/mastodon/public/system - -chown -R abc:abc \ - /app/www/tmp - -ln -s /config/mastodon/public/system /app/www/public/system - -cd /app/www/ || exit 1 - -s6-setuidgid abc /usr/bin/bundle exec rails db:prepare - -chown -R abc:abc \ - /config diff --git a/root/etc/s6-overlay/s6-rc.d/init-config-end/dependencies.d/init-mastodon-config b/root/etc/s6-overlay/s6-rc.d/init-config-end/dependencies.d/init-mastodon-config new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/init-mastodon-config/dependencies.d/init-nginx-end b/root/etc/s6-overlay/s6-rc.d/init-mastodon-config/dependencies.d/init-nginx-end new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/init-mastodon-config/run b/root/etc/s6-overlay/s6-rc.d/init-mastodon-config/run new file mode 100755 index 0000000..add9f0d --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mastodon-config/run @@ -0,0 +1,45 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +mkdir -p \ + /app/www/tmp \ + /config/mastodon/public/system + +lsiown -R abc:abc \ + /app/www/tmp + +# Remove old pid in the event of an unclean shutdown +if [[ -f /app/www/tmp/pids/server.pid ]]; then + rm /app/www/tmp/pids/server.pid +fi + +if [[ -z "${ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY}" ]] || [[ -z "${ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT}" ]] || [[ -z "${ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY}" ]]; then +# shellcheck disable=SC2016 + echo 'Mastodon now requires that these variables are set: + + - ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY + - ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT + - ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY + +Run `docker run --rm -it --entrypoint /bin/bash lscr.io/linuxserver/mastodon:develop generate-active-record` +to generate new secrets, assign the environment variables, and recreate the container. + ' + sleep infinity +fi + +if [[ ! -L "/app/www/public/system" ]]; then + rm -rf "/app/www/public/system" + ln -s "/config/mastodon/public/system" "/app/www/public/system" +fi + +cd /app/www/ || exit 1 + +# Don't run DB prep if this is a sidekiq-only container +if [[ ${SIDEKIQ_ONLY,,} != "true" ]]; then + s6-setuidgid abc /usr/local/bin/bundle exec rails db:prepare +fi + +if [[ ${NO_CHOWN,,} != "true" ]]; then + lsiown -R abc:abc \ + /config +fi diff --git a/root/etc/s6-overlay/s6-rc.d/init-mastodon-config/type b/root/etc/s6-overlay/s6-rc.d/init-mastodon-config/type new file mode 100644 index 0000000..bdd22a1 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mastodon-config/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-mastodon-config/up b/root/etc/s6-overlay/s6-rc.d/init-mastodon-config/up new file mode 100644 index 0000000..577609e --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mastodon-config/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-mastodon-config/run diff --git a/root/etc/s6-overlay/s6-rc.d/svc-mastodon/dependencies.d/init-services b/root/etc/s6-overlay/s6-rc.d/svc-mastodon/dependencies.d/init-services new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/services.d/mastodon/notification-fd b/root/etc/s6-overlay/s6-rc.d/svc-mastodon/notification-fd similarity index 100% rename from root/etc/services.d/mastodon/notification-fd rename to root/etc/s6-overlay/s6-rc.d/svc-mastodon/notification-fd diff --git a/root/etc/s6-overlay/s6-rc.d/svc-mastodon/run b/root/etc/s6-overlay/s6-rc.d/svc-mastodon/run new file mode 100755 index 0000000..50caa9e --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-mastodon/run @@ -0,0 +1,10 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +export RAILS_ENV=production +export PATH="${PATH}:/app/www/bin" +export RAILS_SERVE_STATIC_FILES=false + +exec \ + s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost 3000" \ + cd /app/www s6-setuidgid abc /usr/local/bin/bundle exec rails s -p 3000 diff --git a/root/etc/s6-overlay/s6-rc.d/svc-mastodon/type b/root/etc/s6-overlay/s6-rc.d/svc-mastodon/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-mastodon/type @@ -0,0 +1 @@ +longrun diff --git a/root/etc/s6-overlay/s6-rc.d/svc-prom/dependencies.d/init-services b/root/etc/s6-overlay/s6-rc.d/svc-prom/dependencies.d/init-services new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/svc-prom/notification-fd b/root/etc/s6-overlay/s6-rc.d/svc-prom/notification-fd new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-prom/notification-fd @@ -0,0 +1 @@ +5 diff --git a/root/etc/s6-overlay/s6-rc.d/svc-prom/run b/root/etc/s6-overlay/s6-rc.d/svc-prom/run new file mode 100755 index 0000000..1dc567a --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-prom/run @@ -0,0 +1,10 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +export RAILS_ENV=production +export HOME=/config +export PATH="${PATH}:/app/www/bin" + +exec \ + s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost ${PROMETHEUS_EXPORTER_PORT:-9394}" \ + cd /app/www s6-setuidgid abc /app/www/bin/prometheus_exporter diff --git a/root/etc/s6-overlay/s6-rc.d/svc-prom/type b/root/etc/s6-overlay/s6-rc.d/svc-prom/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-prom/type @@ -0,0 +1 @@ +longrun diff --git a/root/etc/s6-overlay/s6-rc.d/svc-sidekiq/dependencies.d/init-services b/root/etc/s6-overlay/s6-rc.d/svc-sidekiq/dependencies.d/init-services new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/svc-sidekiq/run b/root/etc/s6-overlay/s6-rc.d/svc-sidekiq/run new file mode 100755 index 0000000..77a6e94 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-sidekiq/run @@ -0,0 +1,30 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +export RAILS_ENV=production +export PATH="${PATH}:/app/www/bin" + +if [[ -n ${SIDEKIQ_THREADS} ]]; then + SIDEKIQ_THREADS=$(printf '%d' "${SIDEKIQ_THREADS}") +else + SIDEKIQ_THREADS=$(printf '%d' 5) +fi + +cd /app/www || exit 1 + +if [[ ${SIDEKIQ_ONLY,,} == "true" ]] && [[ -n ${SIDEKIQ_QUEUE} ]]; then + echo "*** Starting sidekiq handling ${SIDEKIQ_QUEUE} queue with ${SIDEKIQ_THREADS} threads ***" + exec \ + s6-setuidgid abc /usr/local/bin/bundle exec "sidekiq -q ${SIDEKIQ_QUEUE} -c ${SIDEKIQ_THREADS}" +elif [[ ${SIDEKIQ_ONLY,,} == "true" ]] && [[ -z ${SIDEKIQ_QUEUE} ]]; then + echo "*** No sidekiq queue specified, aborting ***" + sleep infinity +elif [[ ${SIDEKIQ_DEFAULT,,} == "true" ]]; then + echo "*** Starting sidekiq handling default queue with ${SIDEKIQ_THREADS} threads ***" + exec \ + s6-setuidgid abc /usr/local/bin/bundle exec "sidekiq -q default -c ${SIDEKIQ_THREADS}" +else + echo "*** Starting sidekiq handling all queues with ${SIDEKIQ_THREADS} threads ***" + exec \ + s6-setuidgid abc /usr/local/bin/bundle exec "sidekiq -c ${SIDEKIQ_THREADS}" +fi diff --git a/root/etc/s6-overlay/s6-rc.d/svc-sidekiq/type b/root/etc/s6-overlay/s6-rc.d/svc-sidekiq/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-sidekiq/type @@ -0,0 +1 @@ +longrun diff --git a/root/etc/s6-overlay/s6-rc.d/svc-streaming/dependencies.d/init-services b/root/etc/s6-overlay/s6-rc.d/svc-streaming/dependencies.d/init-services new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/services.d/streaming/notification-fd b/root/etc/s6-overlay/s6-rc.d/svc-streaming/notification-fd similarity index 100% rename from root/etc/services.d/streaming/notification-fd rename to root/etc/s6-overlay/s6-rc.d/svc-streaming/notification-fd diff --git a/root/etc/s6-overlay/s6-rc.d/svc-streaming/run b/root/etc/s6-overlay/s6-rc.d/svc-streaming/run new file mode 100755 index 0000000..5216f64 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-streaming/run @@ -0,0 +1,9 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +export NODE_ENV=production +export PATH="${PATH}:/app/www/bin" + +exec \ + s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost 4000" \ + cd /app/www s6-setuidgid abc node ./streaming diff --git a/root/etc/s6-overlay/s6-rc.d/svc-streaming/type b/root/etc/s6-overlay/s6-rc.d/svc-streaming/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-streaming/type @@ -0,0 +1 @@ +longrun diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mastodon-config b/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mastodon-config new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-mastodon b/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-mastodon new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-prom b/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-prom new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-sidekiq b/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-sidekiq new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-streaming b/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-streaming new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/services.d/mastodon/run b/root/etc/services.d/mastodon/run deleted file mode 100755 index 222cf4d..0000000 --- a/root/etc/services.d/mastodon/run +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/with-contenv bash -# shellcheck shell=bash - -RAILS_ENV=production -PATH="${PATH}:/opt/ruby/bin:/opt/node/bin:/app/www/bin" -RAILS_SERVE_STATIC_FILES=false - -exec \ - s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost 3000" \ - cd /app/www s6-setuidgid abc /usr/bin/bundle exec rails s -p 3000 diff --git a/root/etc/services.d/sidekiq/run b/root/etc/services.d/sidekiq/run deleted file mode 100755 index e0fc2b8..0000000 --- a/root/etc/services.d/sidekiq/run +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/with-contenv bash -# shellcheck shell=bash - -RAILS_ENV=production -PATH="${PATH}:/opt/ruby/bin:/opt/node/bin:/app/www/bin" - -cd /app/www || exit 1 - -exec \ - s6-setuidgid abc /usr/bin/bundle exec sidekiq diff --git a/root/etc/services.d/streaming/run b/root/etc/services.d/streaming/run deleted file mode 100755 index 08cb19d..0000000 --- a/root/etc/services.d/streaming/run +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/with-contenv bash -# shellcheck shell=bash - -NODE_ENV=production -PATH="${PATH}:/opt/ruby/bin:/opt/node/bin:/app/www/bin" - -exec \ - s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost 4000" \ - cd /app/www s6-setuidgid abc node ./streaming diff --git a/root/generate-active-record b/root/generate-active-record new file mode 100755 index 0000000..8e47941 --- /dev/null +++ b/root/generate-active-record @@ -0,0 +1,6 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +cd /app/www || exit 1 + +rake db:encryption:init diff --git a/root/generate-secret b/root/generate-secret new file mode 100755 index 0000000..4f68185 --- /dev/null +++ b/root/generate-secret @@ -0,0 +1,6 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +cd /app/www || exit 1 + +bundle exec rails secret diff --git a/root/generate-vapid b/root/generate-vapid new file mode 100755 index 0000000..927788c --- /dev/null +++ b/root/generate-vapid @@ -0,0 +1,6 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +cd /app/www || exit 1 + +bundle exec rails mastodon:webpush:generate_vapid_key diff --git a/root/init-hook b/root/init-hook new file mode 100755 index 0000000..8ec44bd --- /dev/null +++ b/root/init-hook @@ -0,0 +1,16 @@ +#!/command/with-contenv bash + +# Disable the php-fpm service as the container doesn't use it +rm /etc/s6-overlay/s6-rc.d/user/contents.d/svc-php-fpm + +if [[ ${MASTODON_PROMETHEUS_EXPORTER_ENABLED,,} != "true" ]]; then + rm /etc/s6-overlay/s6-rc.d/user/contents.d/svc-prom +fi + +if [[ ${SIDEKIQ_ONLY,,} == "true" ]]; then + rm /etc/s6-overlay/s6-rc.d/user/contents.d/svc-mastodon + rm /etc/s6-overlay/s6-rc.d/user/contents.d/svc-nginx + rm /etc/s6-overlay/s6-rc.d/user/contents.d/svc-streaming +fi + +exec /docker-mods diff --git a/root/migrate b/root/migrate new file mode 100755 index 0000000..385b35d --- /dev/null +++ b/root/migrate @@ -0,0 +1,6 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +cd /app/www || exit 1 + +bundle exec rails db:migrate diff --git a/root/tootctl b/root/tootctl new file mode 100755 index 0000000..1204d04 --- /dev/null +++ b/root/tootctl @@ -0,0 +1,6 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +cd /app/www || exit 1 + +bin/tootctl "$@"