There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

drdaeman ,
@drdaeman@lemmy.zhukov.al avatar

Yes - same as with the original script, upgrades would require more manual steps than just updating the version in the Compose file. This is how it’s typically done.

There are ways to automate this. Docker Hub used to have a feature for automatic rebuilds when base images had changed, but AFAIK this feature was removed some years ago. Now it’s a matter of setting up a CI with periodically (nightly or weekly) scheduled pipelines, but it’s not a trivial matter.

Semi-automation can be achieved by using build-time arguments. I’m at my computer now, so here’s a revised process:

First, a bunch of manual commands that would allow us to write a patch. I’ll use those crude sed statements - just because they work today, but YMMV.

<pre style="background-color:#ffffff;">
<span style="color:#323232;">docker run -it --rm --user root tootsuite/mastodon bash
</span><span style="color:#323232;">cp -r /opt/mastodon /opt/mastodon.vanilla
</span><span style="color:#323232;">sed -i 's/500/1000/g' /opt/mastodon/app/javascript/mastodon/features/compose/components/compose_form.js
</span><span style="color:#323232;">sed -i 's/500/1000/g' /opt/mastodon/app/validators/status_length_validator.rb
</span><span style="color:#323232;">diff -urN /opt/mastodon.vanilla /opt/mastodon
</span>

This will produce a nice patch like this that you can copy. Create an empty directory and save as change-limits.patch in there:

<pre style="background-color:#ffffff;">
<span style="color:#323232;">diff -urN /opt/mastodon.vanilla/app/javascript/mastodon/features/compose/components/compose_form.js /opt/mastodon/app/javascript/mastodon/features/compose/components/compose_form.js
</span><span style="color:#323232;">--- /opt/mastodon.vanilla/app/javascript/mastodon/features/compose/components/compose_form.js   2023-07-07 17:50:26.046682458 +0000
</span><span style="color:#323232;">+++ /opt/mastodon/app/javascript/mastodon/features/compose/components/compose_form.js   2023-07-07 17:50:49.626674917 +0000
</span><span style="color:#323232;">@@ -90,7 +90,7 @@
</span><span style="color:#323232;">     const fulltext = this.getFulltextForCharacterCounting();
</span><span style="color:#323232;">     const isOnlyWhitespace = fulltext.length !== 0 && fulltext.trim().length === 0;
</span><span style="color:#323232;">
</span><span style="color:#323232;">-    return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > 500 || (isOnlyWhitespace && !anyMedia));
</span><span style="color:#323232;">+    return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > 1000 || (isOnlyWhitespace && !anyMedia));
</span><span style="color:#323232;">   };
</span><span style="color:#323232;">
</span><span style="color:#323232;">   handleSubmit = (e) => {
</span><span style="color:#323232;">@@ -280,7 +280,7 @@
</span><span style="color:#323232;">           </div>
</span><span style="color:#323232;">
</span><span style="color:#323232;">           <div className='character-counter__wrapper'>
</span><span style="color:#323232;">-            <CharacterCounter max={500} text={this.getFulltextForCharacterCounting()} />
</span><span style="color:#323232;">+            <CharacterCounter max={1000} text={this.getFulltextForCharacterCounting()} />
</span><span style="color:#323232;">           </div>
</span><span style="color:#323232;">         </div>
</span><span style="color:#323232;">
</span><span style="color:#323232;">diff -urN /opt/mastodon.vanilla/app/validators/status_length_validator.rb /opt/mastodon/app/validators/status_length_validator.rb
</span><span style="color:#323232;">--- /opt/mastodon.vanilla/app/validators/status_length_validator.rb     2023-07-07 17:50:26.106682438 +0000
</span><span style="color:#323232;">+++ /opt/mastodon/app/validators/status_length_validator.rb     2023-07-07 17:51:00.796671166 +0000
</span><span style="color:#323232;">@@ -1,7 +1,7 @@
</span><span style="color:#323232;"> # frozen_string_literal: true
</span><span style="color:#323232;">
</span><span style="color:#323232;"> class StatusLengthValidator < ActiveModel::Validator
</span><span style="color:#323232;">-  MAX_CHARS = 500
</span><span style="color:#323232;">+  MAX_CHARS = 1000
</span><span style="color:#323232;">   URL_PLACEHOLDER_CHARS = 23
</span><span style="color:#323232;">   URL_PLACEHOLDER = 'x' * 23
</span>

Now, put the Dockerfile next to the patch:

<pre style="background-color:#ffffff;">
<span style="color:#323232;">ARG MASTODON_VERSION=latest
</span><span style="color:#323232;">FROM tootsuite/mastodon:${MASTODON_VERSION}
</span><span style="color:#323232;">
</span><span style="color:#323232;">USER root
</span><span style="color:#323232;">RUN apt-get update && apt-get install -y --no-install-recommends patch
</span><span style="color:#323232;">COPY change-limits.patch ./
</span><span style="color:#323232;">RUN patch -up3 < change-limits.patch
</span><span style="color:#323232;">
</span><span style="color:#323232;">USER mastodon
</span><span style="color:#323232;">RUN OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile
</span>

And a shell script to semi-automate the upgrades. Note it requires curl and jq to be available to parse JSON.

<pre style="background-color:#ffffff;">
<span style="color:#323232;">#!/bin/sh
</span><span style="color:#323232;">
</span><span style="color:#323232;">set -e
</span><span style="color:#323232;">
</span><span style="color:#323232;">MASTODON_VERSION="$(curl -s "https://hub.docker.com/v2/namespaces/tootsuite/repositories/mastodon/tags?page_size=100" | jq -r '.results[]["name"]' | sort -rV | head -n 1)"
</span><span style="color:#323232;">echo "Latest version: ${MASTODON_VERSION}"
</span><span style="color:#323232;">docker pull "tootsuite/mastodon:${MASTODON_VERSION}"
</span><span style="color:#323232;">docker build --build-arg "MASTODON_VERSION=${MASTODON_VERSION}" -t "my-mastodon:${MASTODON_VERSION}" .
</span>

And finally, create a file called .dockerignore that contains only one line that would say build.sh. That’s just minor cosmetic touch saying that our build.sh is not meant to be a part of the build context. If everything is correct, there should be now 4 files in the directory: .dockerignore, build.sh, change-limits.patch and Dockerfile.

Now when you run build.sh it will automatically find the latest version and build you a custom image tagged as e.g. my-mastodon:v4.1.3, which you can use in your Compose file. For a distributed system like Docker Swarm, Nomad or Kubernetes you’ll want to tweak this script a little to use some registry (your-registry.example.org/your/mastodon:v4.1.3) and possibly even apply changes further (e.g. docker service update --image …).

Mutable tags like latest can become confusing or even problematic (e.g. if you’ll want to downgrade it’s best to have previous version image readily available for some time - even if the build process is reproducible), so I would really recommend to use explicit version number tags.

Hope this helps.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines