user/loomio: new aport #348
10 changed files with 415 additions and 0 deletions
196
user/loomio/APKBUILD
Normal file
196
user/loomio/APKBUILD
Normal file
|
@ -0,0 +1,196 @@
|
|||
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
|
||||
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
|
||||
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
|
||||
pkgname=loomio
|
||||
pkgver=2.21.4
|
||||
_gittag=v$pkgver
|
||||
pkgrel=0
|
||||
pkgdesc="A collaborative decision making tool"
|
||||
url="https://github.com/loomio/loomio"
|
||||
arch="x86_64"
|
||||
license="MIT"
|
||||
depends="
|
||||
postgresql
|
||||
postgresql-contrib
|
||||
python3
|
||||
redis
|
||||
ruby3.2
|
||||
ruby3.2-bundler
|
||||
ruby3.2-grpc
|
||||
vips
|
||||
npm
|
||||
procps-ng
|
||||
"
|
||||
makedepends="
|
||||
cmd:chrpath
|
||||
ruby3.2-dev
|
||||
nodejs
|
||||
openssl-dev
|
||||
readline-dev
|
||||
zlib-dev
|
||||
libpq-dev
|
||||
libffi-dev
|
||||
imagemagick-dev
|
||||
"
|
||||
pkgusers="loomio"
|
||||
pkggroups="loomio www-data"
|
||||
install="$pkgname.pre-install $pkgname.post-install $pkgname.post-upgrade"
|
||||
subpackages="$pkgname-openrc"
|
||||
source="
|
||||
$pkgname-$pkgver.tar.gz::https://github.com/loomio/loomio/archive/refs/tags/v$pkgver.tar.gz
|
||||
bin-wrapper.in
|
||||
loomio.confd
|
||||
loomio.logrotate
|
||||
loomio.sidekiq.initd
|
||||
loomio.vue.initd
|
||||
loomio.initd
|
||||
"
|
||||
_prefix="usr/lib/webapps/loomio"
|
||||
|
||||
export BUNDLE_DEPLOYMENT=true
|
||||
export BUNDLE_FORCE_RUBY_PLATFORM=true
|
||||
export BUNDLE_FROZEN=true
|
||||
export BUNDLE_JOBS=${JOBS:-2}
|
||||
|
||||
prepare() {
|
||||
local sysgemdir=$(ruby -e 'puts Gem.default_dir')
|
||||
|
||||
default_prepare
|
||||
|
||||
# Allow use of any bundler
|
||||
sed -i -e '/BUNDLED/,+1d' Gemfile.lock
|
||||
|
||||
# Allow use of any platform
|
||||
sed -i -e 's/PLATFORMS/PLATFORMS\n ruby/' Gemfile.lock
|
||||
|
||||
# Some gems are broken, so we copy our fixed version
|
||||
# instead of installing it from RubyGems using Bundler.
|
||||
mkdir -p vendor/gems/grpc/src/ruby/lib/grpc
|
||||
cp -r "$sysgemdir"/gems/grpc-*/* vendor/gems/grpc/
|
||||
cp "$sysgemdir"/specifications/grpc-*.gemspec \
|
||||
vendor/gems/grpc/grpc.gemspec
|
||||
cp "$sysgemdir"/extensions/*/*/grpc-*/grpc/*.so \
|
||||
vendor/gems/grpc/src/ruby/lib/grpc/
|
||||
}
|
||||
|
||||
build() {
|
||||
local bundle_without='exclude development test'
|
||||
|
||||
bundle config --local build.ffi --enable-system-libffi
|
||||
bundle config --local build.vips --enable-system-libraries
|
||||
bundle config --local build.nokogiri --use-system-libraries \
|
||||
--with-xml2-include=/usr/include/libxml2 \
|
||||
--with-xslt-include=/usr/include/libxslt
|
||||
bundle config --local build.google-protobuf '-- --with-cflags=-D__va_copy=va_copy'
|
||||
|
||||
msg "Installing Ruby gems..."
|
||||
bundle config --local without "$bundle_without"
|
||||
bundle config --local path "vendor/bundle"
|
||||
|
||||
bundle install --no-cache
|
||||
|
||||
msg "Precompiling static assets..."
|
||||
bundle exec bootsnap precompile --gemfile app/ lib/
|
||||
|
||||
# Create executables in bin/*.
|
||||
# See also https://github.com/bundler/bundler/issues/6149.
|
||||
bundle binstubs --force bundler puma sidekiq
|
||||
|
||||
# Remove faulty RPATH.
|
||||
chrpath -d vendor/bundle/ruby/*/gems/*/lib/nokogiri/*/nokogiri.so
|
||||
|
||||
# cp grpc so
|
||||
cp vendor/gems/grpc/src/ruby/lib/grpc/grpc_c.so vendor/bundle/ruby/*/gems/grpc*/src/ruby/lib/grpc/.
|
||||
rm -R vendor/bundle/ruby/*/gems/grpc*/src/ruby/lib/grpc/3* vendor/bundle/ruby/*/gems/grpc*/src/ruby/lib/grpc/2*
|
||||
|
||||
msg "Installing npm modules..."
|
||||
cd vue
|
||||
# force as vite-plugin-yaml hasn't updated their peerDependencies list yet
|
||||
npm ci --force
|
||||
npm run build
|
||||
}
|
||||
|
||||
package() {
|
||||
local destdir="$pkgdir/$_prefix"
|
||||
local datadir="$pkgdir/var/lib/loomio"
|
||||
local file dest
|
||||
|
||||
# Make directories
|
||||
install -dm 755 \
|
||||
"$(dirname $destdir)" \
|
||||
"$datadir"
|
||||
|
||||
mkdir -p "$(dirname $destdir)"
|
||||
cp -R "$builddir" "$destdir"
|
||||
|
||||
cd "$destdir"/vendor/bundle/ruby/*/
|
||||
|
||||
# Remove tests, documentations and other useless files.
|
||||
find gems/ \( -name 'doc' \
|
||||
-o -name 'spec' \
|
||||
-o -name 'test' \) \
|
||||
-type d -maxdepth 2 -exec rm -fr "{}" +
|
||||
find gems/ \( -name 'README*' \
|
||||
-o -name 'CHANGELOG*' \
|
||||
-o -name 'CONTRIBUT*' \
|
||||
-o -name '*LICENSE*' \
|
||||
-o -name 'Rakefile' \
|
||||
-o -name '.*' \) \
|
||||
-type f -delete
|
||||
|
||||
# Remove build logs and cache.
|
||||
rm -rf build_info/ cache/
|
||||
find extensions/ \( -name gem_make.out -o -name mkmf.log \) -delete
|
||||
|
||||
cd "$destdir"
|
||||
|
||||
# Install and symlink config files.
|
||||
for file in database.yml.postgresql puma.rb sidekiq.yml; do
|
||||
dest="$(basename "${file/.postgresql/}")"
|
||||
install -m640 -g loomio -D config/$file "$pkgdir"/etc/loomio/$dest
|
||||
ln -sf /etc/loomio/$dest "$pkgdir"/$_prefix/config/${file/.postgrewsql/}
|
||||
done
|
||||
|
||||
# This file will be generated by the post-install script, just prepare symlink.
|
||||
ln -sf /etc/loomio/secrets.yml config/secrets.yml
|
||||
# These shouldn't be necessary, they are all configurable, but OmniBus
|
||||
|
||||
cat > "$datadir"/.profile <<-EOF
|
||||
export RAILS_ENV=production
|
||||
export NODE_ENV=production
|
||||
export EXECJS_RUNTIME=Disabled
|
||||
EOF
|
||||
|
||||
# Install wrapper scripts to /usr/bin.
|
||||
local name; for name in rake rails; do
|
||||
sed "s/__COMMAND__/$name/g" "$srcdir"/bin-wrapper.in \
|
||||
> "$builddir"/loomio-$name
|
||||
install -m755 -D "$builddir"/loomio-$name "$pkgdir"/usr/bin/loomio-$name
|
||||
done
|
||||
|
||||
for file in $pkgname $pkgname.sidekiq $pkgname.vue; do
|
||||
install -m755 -D "$srcdir"/$file.initd "$pkgdir"/etc/init.d/$file
|
||||
done
|
||||
|
||||
install -m644 -D "$srcdir"/loomio.confd \
|
||||
"$pkgdir"/etc/conf.d/loomio
|
||||
|
||||
install -m644 -D "$srcdir"/loomio.logrotate \
|
||||
"$pkgdir"/etc/logrotate.d/loomio
|
||||
}
|
||||
|
||||
assets() {
|
||||
depends=""
|
||||
|
||||
amove $_prefix/public/assets
|
||||
}
|
||||
|
||||
sha512sums="
|
||||
72a1238c1eaa3b963bd20a09d4fc2e52798264779bdf06d3f32891f2880d246059c77381329d1274bfa5979a35740017f0ced324f88b205369e77335b403ffba loomio-2.21.4.tar.gz
|
||||
6cd4bb030660a9f4697eeb7c6de3f7509558aab3651e68218583dfeea56634f3b9f58acb50c7c9a4188a38c19434a815dd6c347e30207c4c0ae028c8dcb6ccaf bin-wrapper.in
|
||||
0f1c91fbd4b8099f0a115705d5af799e4492fa2a0fd54175f3bfbfb5be1122bd7fd73a7709695c7caf2dcc667f3b8715051c24f424472e1115753e43a38fdf50 loomio.confd
|
||||
1ecb0717cd5f04b894467b21d226b98d8f83b8f62afbf8da7edd57973aeabb13d121e9061cc48aec7572b1c710e82c8b44a1cedc0a924efd4bc4a124b3afe9a8 loomio.logrotate
|
||||
c5dae2b6f9a23853c3c7ac068d97a7b0269b1775f6e0169c3d8999ec67c2baf3545515ea21037e882d900b15a7abf9061dd5a584bdc82c347b54d8c134f6d7a4 loomio.sidekiq.initd
|
||||
f774954d8b06aacab27af9593b1b12fbe18ec2d0593dd4f82e4d3dfbc7e325fb1a423347fd974a2ec6665776a6cfe85f255f4fd7493c97eb840f34eb7fbdb329 loomio.vue.initd
|
||||
645637c4112ec91ec2ea6022713e77a8ee76c0f0a81f9adf1f9210b52a578e94b5b02f0b6244b173905f580f72dc362b5434c714aae11e3619f73af223891bb8 loomio.initd
|
||||
"
|
15
user/loomio/bin-wrapper.in
Normal file
15
user/loomio/bin-wrapper.in
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
BUNDLE_DIR='/usr/lib/webapps/loomio'
|
||||
export RAILS_ENV='production'
|
||||
export NODE_ENV='production'
|
||||
export EXECJS_RUNTIME='Disabled'
|
||||
|
||||
cd $BUNDLE_DIR
|
||||
install -m 700 -o loomio -g loomio -d "$(readlink ./tmp)"
|
||||
|
||||
if [ "$(id -un)" != 'loomio' ]; then
|
||||
exec su loomio -c '"$0" "$@"' -- bin/__COMMAND__ "$@"
|
||||
else
|
||||
exec bin/__COMMAND__ "$@"
|
||||
fi
|
32
user/loomio/loomio.confd
Normal file
32
user/loomio/loomio.confd
Normal file
|
@ -0,0 +1,32 @@
|
|||
# Configuration file for /etc/init.d/loomio and
|
||||
# /etc/init.d/loomio.{vue,sidekiq}
|
||||
|
||||
# Specify how many processes to create using sidekiq-cluster and which queue
|
||||
# they should handle. Each whitespace-separated item equates to one additional
|
||||
# Sidekiq process, and comma-separated values in each item determine the queues
|
||||
# it works on. The special queue name "*" means all queues.
|
||||
# Example: "* gitlab_shell process_commit,post_receive"
|
||||
# See https://docs.gitlab.com/ee/administration/sidekiq/extra_sidekiq_processes.html.
|
||||
#sidekiq_queue_groups="*"
|
||||
|
||||
# Maximum threads to use with Sidekiq (default: 50, 0 to disable).
|
||||
#sidekiq_max_concurrency=
|
||||
|
||||
# Minimum threads to use with Sidekiq (default: 0).
|
||||
#sidekiq_min_concurrency=
|
||||
|
||||
# The number of seconds to wait between worker checks.
|
||||
#sidekiq_interval=
|
||||
|
||||
# Graceful timeout for all running processes.
|
||||
#sidekiq_shutdown_timeout=
|
||||
|
||||
# Run workers for all queues in sidekiq_queues.yml except the given ones.
|
||||
#sidekiq_negate=no
|
||||
|
||||
# Run workers based on the provided selector.
|
||||
#sidekiq_queue_selector=no
|
||||
|
||||
# Memory limit (in MiB) for the Sidekiq process. If the RSS (Resident Set Size)
|
||||
# of the Sidekiq process exceeds this limit, a delayed shutdown is triggered.
|
||||
#sidekiq_memkiller_max_rss=2000
|
39
user/loomio/loomio.initd
Normal file
39
user/loomio/loomio.initd
Normal file
|
@ -0,0 +1,39 @@
|
|||
#!/sbin/openrc-run
|
||||
|
||||
name="Loomio"
|
||||
description="Meta script for starting/stopping all the Loomio components"
|
||||
subservices="loomio.sidekiq loomio.vue"
|
||||
|
||||
depend() {
|
||||
use net
|
||||
}
|
||||
|
||||
start() {
|
||||
local ret=0
|
||||
|
||||
ebegin "Starting all Loomio components"
|
||||
local svc; for svc in $subservices; do
|
||||
service $svc start || ret=1
|
||||
done
|
||||
eend $ret
|
||||
}
|
||||
|
||||
stop() {
|
||||
local ret=0
|
||||
|
||||
ebegin "Stopping all Loomio components"
|
||||
local svc; for svc in $subservices; do
|
||||
service $svc stop || ret=1
|
||||
done
|
||||
eend $ret
|
||||
}
|
||||
|
||||
status() {
|
||||
local ret=0
|
||||
|
||||
local svc; for svc in $subservices; do
|
||||
echo "$svc:"
|
||||
service $svc status || ret=1
|
||||
done
|
||||
eend $ret
|
||||
}
|
11
user/loomio/loomio.logrotate
Normal file
11
user/loomio/loomio.logrotate
Normal file
|
@ -0,0 +1,11 @@
|
|||
/var/log/loomio/*.log {
|
||||
compress
|
||||
copytruncate
|
||||
delaycompress
|
||||
maxsize 10M
|
||||
minsize 1M
|
||||
missingok
|
||||
sharedscripts
|
||||
rotate 10
|
||||
weekly
|
||||
}
|
32
user/loomio/loomio.post-install
Executable file
32
user/loomio/loomio.post-install
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
group=loomio
|
||||
config_file='/etc/loomio/config.yml'
|
||||
|
||||
#if [ $(grep '@@SECRET_KEY@@' "$config_file") ]; then
|
||||
# echo "* Generating random secret in $config_file" >&2
|
||||
|
||||
# secret_key="$(pwgen -s 50 1)"
|
||||
# sed -i "s|@@SECRET_KEY@@|$secret_key|" "$config_file"
|
||||
#fi
|
||||
|
||||
if [ "${0##*.}" = 'post-upgrade' ]; then
|
||||
cat >&2 <<-EOF
|
||||
*
|
||||
* To finish Loomio upgrade run:
|
||||
*
|
||||
*
|
||||
EOF
|
||||
else
|
||||
cat >&2 <<-EOF
|
||||
*
|
||||
* 1. Adjust settings in /etc/loomio/config.yml.
|
||||
*
|
||||
* 2. Create database for loomio:
|
||||
*
|
||||
* psql -c "CREATE ROLE loomio PASSWORD 'top-secret' INHERIT LOGIN;"
|
||||
* psql -c "CREATE DATABASE loomio OWNER loomio ENCODING 'UTF-8';"
|
||||
*
|
||||
EOF
|
||||
fi
|
1
user/loomio/loomio.post-upgrade
Symbolic link
1
user/loomio/loomio.post-upgrade
Symbolic link
|
@ -0,0 +1 @@
|
|||
loomio.post-install
|
26
user/loomio/loomio.pre-install
Normal file
26
user/loomio/loomio.pre-install
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
# It's very important to set user/group correctly.
|
||||
|
||||
loomio_dir='/var/lib/loomio'
|
||||
|
||||
if ! getent group loomio 1>/dev/null; then
|
||||
echo '* Creating group loomio' 1>&2
|
||||
|
||||
addgroup -S loomio
|
||||
fi
|
||||
|
||||
if ! id loomio 2>/dev/null 1>&2; then
|
||||
echo '* Creating user loomio' 1>&2
|
||||
|
||||
adduser -DHS -G loomio -h "$loomio_dir" -s /bin/sh \
|
||||
-g "added by apk for loomio" loomio
|
||||
passwd -u loomio 1>/dev/null # unlock
|
||||
fi
|
||||
|
||||
if ! id -Gn loomio | grep -Fq redis; then
|
||||
echo '* Adding user loomio to group www-data' 1>&2
|
||||
|
||||
addgroup loomio www-data
|
||||
fi
|
||||
|
||||
exit 0
|
32
user/loomio/loomio.sidekiq.initd
Normal file
32
user/loomio/loomio.sidekiq.initd
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!/sbin/openrc-run
|
||||
|
||||
name="Loomio background workers Service"
|
||||
root="/usr/share/webapps/loomio"
|
||||
pidfile="/run/loomio-sidekiq.pid"
|
||||
logfile="/var/log/loomio/sidekiq.log"
|
||||
|
||||
depend() {
|
||||
use net
|
||||
need redis
|
||||
}
|
||||
|
||||
start() {
|
||||
ebegin "Starting Loomio background workers"
|
||||
|
||||
cd $root
|
||||
|
||||
start-stop-daemon --start --background \
|
||||
--chdir "${root}" \
|
||||
--user="loomio" \
|
||||
--make-pidfile --pidfile="${pidfile}" \
|
||||
-1 "${logfile}" -2 "${logfile}" \
|
||||
--exec /usr/bin/env -- RAILS_ENV=production bundle exec rails s
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
ebegin "Stopping Loomio background workers"
|
||||
start-stop-daemon --stop \
|
||||
--pidfile=${pidfile} \
|
||||
eend $?
|
||||
}
|
31
user/loomio/loomio.vue.initd
Normal file
31
user/loomio/loomio.vue.initd
Normal file
|
@ -0,0 +1,31 @@
|
|||
#!/sbin/openrc-run
|
||||
|
||||
name="$RC_SVCNAME"
|
||||
cfgfile="/etc/conf.d/$RC_SVCNAME.conf"
|
||||
pidfile="/run/$RC_SVCNAME.pid"
|
||||
working_directory="/usr/share/bundles/loomio"
|
||||
command="npm"
|
||||
command_args="run serve"
|
||||
command_user="loomio"
|
||||
command_group="loomio"
|
||||
start_stop_daemon_args=""
|
||||
command_background="yes"
|
||||
output_log="/var/log/loomio/$RC_SVCNAME.log"
|
||||
error_log="/var/log/loomio/$RC_SVCNAME.err"
|
||||
|
||||
depend() {
|
||||
need redis
|
||||
need postgresql
|
||||
}
|
||||
|
||||
start_pre() {
|
||||
cd "$working_directory"
|
||||
checkpath --directory --owner $command_user:$command_group --mode 0775 \
|
||||
/var/log/loomio \
|
||||
/var/lib/loomio
|
||||
}
|
||||
|
||||
stop_pre() {
|
||||
ebegin "Killing child processes"
|
||||
kill $(ps -o pid= --ppid $(cat $pidfile)) || true
|
||||
}
|
Loading…
Reference in a new issue