M Makefile => Makefile +3 -0
@@ 31,6 31,9 @@ cryptpad.tar.zst: base.tar.zst
envoy.tar.zst: base.tar.zst
packer build packer/envoy.pkr.hcl
+mastodon.tar.zst: base.tar.zst
+ packer build packer/mastodon.pkr.hcl
+
nginx.tar.zst: base.tar.zst
packer build packer/nginx.pkr.hcl
M packer/cryptpad.pkr.hcl => packer/cryptpad.pkr.hcl +1 -1
@@ 18,7 18,7 @@ build {
provisioner "shell" {
script = "packer/cryptpad.sh"
- execute_command = "su - cryptpad -c '/bin/sh {{ .Path }}'"
+ execute_command = "su - cryptpad -c '/bin/sh -eux {{ .Path }}'"
}
provisioner "file" {
M packer/cryptpad.sh => packer/cryptpad.sh +1 -1
@@ 1,4 1,4 @@
-#!/bin/sh
+#!/bin/sh -eux
git clone --depth 1 -b 4.3.1 https://github.com/xwiki-labs/cryptpad.git cryptpad
cd cryptpad
rm -rf .git
A packer/mastodon.pkr.hcl => packer/mastodon.pkr.hcl +57 -0
@@ 0,0 1,57 @@
+source "nspawn" "mastodon" {
+ clone = "base"
+}
+
+build {
+ sources = ["source.nspawn.mastodon"]
+
+ provisioner "apt" {
+ packages = [
+ "build-essential", "bundler", "ffmpeg", "file", "git", "imagemagick",
+ "libicu-dev", "libidn11-dev", "libpq-dev", "libjemalloc-dev",
+ "zlib1g-dev", "libgdbm-dev", "libgmp-dev", "libssl-dev", "libyaml-0-2",
+ "libreadline8", "python3", "shared-mime-info", "ruby3.0", "ruby3.0-dev",
+ "wget", "whois", "yarnpkg",
+ ]
+ }
+
+ provisioner "shell" {
+ inline = [
+ "ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime",
+ "ln -fs ruby3.0 /usr/bin/ruby",
+ "ln -fs yarnpkg /usr/bin/yarn",
+ "groupadd -g 991 mastodon",
+ "useradd -l -u 991 -g 991 -d /opt/mastodon mastodon",
+ "install -m 755 -o mastodon -g mastodon -d /opt/mastodon",
+ "ln -s /opt/mastodon /mastodon",
+ ]
+ }
+
+ provisioner "shell" {
+ script = "packer/mastodon.sh"
+ execute_command = "su - mastodon -c '/bin/sh -eux {{ .Path }}'"
+ }
+
+ provisioner "shell" {
+ inline = [
+ "apt-get -y autoremove git",
+ ]
+ }
+
+ provisioner "shell" {
+ script = "no-ipv6.sh"
+ }
+
+ post-processors {
+ post-processor "shell-local" {
+ inline = [
+ "tar --zstd -C /var/lib/machines/mastodon -cf mastodon.tar.zst .",
+ "machinectl remove mastodon",
+ ]
+ }
+
+ post-processor "artifice" {
+ files = ["mastodon.tar.zst"]
+ }
+ }
+}
A packer/mastodon.sh => packer/mastodon.sh +21 -0
@@ 0,0 1,21 @@
+#!/bin/sh -eux
+export PATH="${PATH}:/opt/ruby/bin:/opt/mastodon/bin"
+
+git clone --depth 1 -b v4.0.2 https://github.com/mastodon/mastodon.git .
+rm -rf .git
+
+bundle config set --local deployment 'true'
+bundle config set --local without 'development test'
+bundle config set silence_root_warning true
+bundle install -j"$(nproc)"
+
+yarnpkg install --pure-lockfile --network-timeout 600000
+
+export RAILS_ENV=production
+export NODE_ENV=production
+export NODE_OPTIONS=--openssl-legacy-provider
+export RAILS_SERVE_STATIC_FILES=true
+export BIND=0.0.0.0
+OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile
+
+yarnpkg cache clean