Build whole custom RabbitMQ image instead of just APK

This commit is contained in:
Disassembler 2020-10-15 09:20:05 +02:00
parent 1cd9fb1485
commit 3f9accced2
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
8 changed files with 73 additions and 268 deletions

View File

@ -1,85 +0,0 @@
# Contributor: Nathan Johnson <nathan@nathanjohnson.info>
# Maintainer: Nathan Johnson <nathan@nathanjohnson.info>
pkgname=rabbitmq-server
pkgver=3.7.18
pkgrel=1
pkgdesc="RabbitMQ is an open source multi-protocol messaging broker."
url="https://www.rabbitmq.com/"
arch="noarch !s390x"
license="MPL-1.1"
depends="erlang erlang-tools erlang-runtime-tools erlang-stdlib
logrotate erlang-ssl erlang-crypto erlang-parsetools
erlang-mnesia erlang-sasl erlang-inets erlang-syntax-tools
erlang-eldap erlang-xmerl erlang-os-mon erlang-asn1 erlang-public-key"
makedepends="$depends_dev erlang-dev python3 py3-simplejson xmlto libxslt
rsync zip gawk grep erlang-compiler erlang-erl-docgen
erlang-edoc socat erlang-eunit elixir"
install="$pkgname.pre-install $pkgname.post-deinstall"
pkgusers="rabbitmq"
pkggroups="rabbitmq"
subpackages="$pkgname-doc"
source="
rabbitmq-server.initd
rabbitmq-server.logrotate
https://github.com/rabbitmq/rabbitmq-server/releases/download/v$pkgver/rabbitmq-server-$pkgver.tar.xz
py3.patch
"
options="!check" # test suite broken
# secfixes:
# 3.7.17:
# - CVE-2015-9251
# - CVE-2017-16012
# - CVE-2019-11358
build() {
make dist manpages PYTHON=python3
}
package() {
make install install-bin install-man DESTDIR="$pkgdir" PREFIX=/usr \
RMQ_ROOTDIR="/usr/lib/rabbitmq" MANDIR=/usr/share/man PYTHON=python3
mkdir -p "$pkgdir"/var/lib/rabbitmq/mnesia
mkdir -p "$pkgdir"/var/log/rabbitmq
#Copy all necessary lib files etc.
install -p -m755 -D "$builddir"/scripts/rabbitmq-server.ocf \
"$pkgdir"/usr/lib/ocf/resource.d/rabbitmq/rabbitmq-server
install -p -m755 -D "$builddir"/scripts/rabbitmq-server-ha.ocf \
"$pkgdir"/usr/lib/ocf/resource.d/rabbitmq/rabbitmq-server-ha
install -p -m644 -D "$srcdir/"$pkgname.logrotate \
"$pkgdir"/etc/logrotate.d/rabbitmq-server
install -m755 -D "$srcdir"/$pkgname.initd \
"$pkgdir"/etc/init.d/$pkgname
mkdir -p "$pkgdir"/usr/sbin
# This is lifted / adapted from the official upstream spec file.
# I'd prefer a patch file, but this is probably a little easier
# to manage since this is how they do it upstream. inb4eww
sed -e 's|@SU_RABBITMQ_SH_C@|su rabbitmq -s /bin/sh -c|' \
-e 's|@STDOUT_STDERR_REDIRECTION@||' \
< "$builddir"/scripts/rabbitmq-script-wrapper \
> "$pkgdir"/usr/sbin/rabbitmqctl
chmod 0755 "$pkgdir"/usr/sbin/rabbitmqctl
for script in rabbitmq-server rabbitmq-plugins; do
cp -a "$pkgdir"/usr/sbin/rabbitmqctl \
"$pkgdir"/usr/sbin/$script;
done
mkdir -p "$pkgdir"/usr/share/doc/"$pkgname"
cp -a "$builddir"/LICENSE* "$pkgdir"/usr/share/doc/"$pkgname"/
cp -a "$builddir"/deps/rabbit/docs/* "$pkgdir"/usr/share/doc/"$pkgname"/
cp -a "$builddir"/deps/rabbitmq_sharding/docs/* "$pkgdir"/usr/share/doc/"$pkgname"/
chmod 755 "$pkgdir"/var/lib/rabbitmq
chmod 750 "$pkgdir"/var/lib/rabbitmq/mnesia
chmod 755 "$pkgdir"/var/log/rabbitmq
chown -R $pkgusers:$pkggroups "$pkgdir"/var/lib/rabbitmq
chown -R $pkgusers:$pkggroups "$pkgdir"/var/log/rabbitmq
}
sha512sums="a8bb02a7cae1f8720e5c7aaabfe6a2c0e731cffbe0d8f99bdcb6597daa654dc49e6d41943974601435700cf469eaa8286dc91a3255a6b9023754c3861fbb5cd9 rabbitmq-server.initd
b8655cb048ab3b32001d4e6920bb5366696f3a5da75c053605e9b270e771c548e36858dca8338813d34376534515bba00af5e6dd7b4b1754a0e64a8fb756e3f3 rabbitmq-server.logrotate
7ac10172b2a1d282a0fbcfc13e4612b0aaee31c7248616cc16451c9390aabd96d866619336a29c9bb3b4142d2141b5d442a07a49c6bb0a4ea0cdb287dc813c0f rabbitmq-server-3.7.18.tar.xz
7862c8566631aeb8c7756e5c8ea11705546ffcdca6ec9058516f91c2650a21b1bb373879e8eb8a78dc5af808eb1fdf6c8167997ea7feace2de61dfa1fb1e5c8b py3.patch"

View File

@ -1,112 +0,0 @@
diff --git a/deps/amqp10_common/codegen.py b/deps/amqp10_common/codegen.py
index dc4480a..d573bcf 100755
--- a/deps/amqp10_common/codegen.py
+++ b/deps/amqp10_common/codegen.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
from __future__ import print_function
diff --git a/deps/rabbit_common/codegen.py b/deps/rabbit_common/codegen.py
index 8b81362..70bd7fa 100755
--- a/deps/rabbit_common/codegen.py
+++ b/deps/rabbit_common/codegen.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
## The contents of this file are subject to the Mozilla Public License
## Version 1.1 (the "License"); you may not use this file except in
diff --git a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/manage.py b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/manage.py
index 1ae2e80..3e61442 100755
--- a/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/manage.py
+++ b/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_django/manage.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import os
import sys
diff --git a/deps/rabbitmq_consistent_hash_exchange/README.md b/deps/rabbitmq_consistent_hash_exchange/README.md
index ce1623f..6ff906b 100644
--- a/deps/rabbitmq_consistent_hash_exchange/README.md
+++ b/deps/rabbitmq_consistent_hash_exchange/README.md
@@ -150,7 +150,7 @@ Executable versions of some of the code examples can be found under [./examples]
This version of the example uses [Pika](https://pika.readthedocs.io/en/stable/), the most widely used Python client for RabbitMQ:
``` python
-#!/usr/bin/env python
+#!/usr/bin/env python3
import pika
import time
@@ -342,7 +342,7 @@ routed to the same **arbitrarily chosen** queue.
#### Code Example in Python
``` python
-#!/usr/bin/env python
+#!/usr/bin/env python3
import pika
import time
@@ -544,7 +544,7 @@ routed to the same **arbitrarily chosen** queue.
#### Code Example in Python
``` python
-#!/usr/bin/env python
+#!/usr/bin/env python3
import pika
import time
diff --git a/deps/rabbitmq_consistent_hash_exchange/examples/python/example1.py b/deps/rabbitmq_consistent_hash_exchange/examples/python/example1.py
index 6cf67d6..30e43ea 100644
--- a/deps/rabbitmq_consistent_hash_exchange/examples/python/example1.py
+++ b/deps/rabbitmq_consistent_hash_exchange/examples/python/example1.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import pika
import time
diff --git a/deps/rabbitmq_consistent_hash_exchange/examples/python/example2.py b/deps/rabbitmq_consistent_hash_exchange/examples/python/example2.py
index 8c1ac15..0099b28 100644
--- a/deps/rabbitmq_consistent_hash_exchange/examples/python/example2.py
+++ b/deps/rabbitmq_consistent_hash_exchange/examples/python/example2.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import pika
import time
diff --git a/deps/rabbitmq_consistent_hash_exchange/examples/python/example3.py b/deps/rabbitmq_consistent_hash_exchange/examples/python/example3.py
index 0b74501..c11a4ce 100644
--- a/deps/rabbitmq_consistent_hash_exchange/examples/python/example3.py
+++ b/deps/rabbitmq_consistent_hash_exchange/examples/python/example3.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import pika
import time
diff --git a/deps/rabbitmq_management/bin/rabbitmqadmin b/deps/rabbitmq_management/bin/rabbitmqadmin
index 55173cb..04c0c12 100755
--- a/deps/rabbitmq_management/bin/rabbitmqadmin
+++ b/deps/rabbitmq_management/bin/rabbitmqadmin
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
diff --git a/deps/rabbitmq_trust_store/examples/rabbitmq_trust_store_django/manage.py b/deps/rabbitmq_trust_store/examples/rabbitmq_trust_store_django/manage.py
index 469f277..ea21f63 100755
--- a/deps/rabbitmq_trust_store/examples/rabbitmq_trust_store_django/manage.py
+++ b/deps/rabbitmq_trust_store/examples/rabbitmq_trust_store_django/manage.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import os
import sys

View File

@ -1,42 +0,0 @@
#!/sbin/openrc-run
pidfile=/run/rabbitmq/rabbitmq.pid
name=rabbitmq
daemon=/usr/sbin/rabbitmq-server
startup_log=/var/log/rabbitmq/startup_log
startup_err=/var/log/rabbitmq/startup_err
shutdown_log=/var/log/rabbitmq/shutdown_log
shutdown_err=/var/log/rabbitmq/shutdown_err
depend() {
need net localmount
after firewall
}
start() {
ebegin "Starting ${name}"
# We need to test if /var/run/rabbitmq exists, since scirpt will fail if it does not
checkpath -m 700 -o rabbitmq:rabbitmq -d "$(dirname "$pidfile")"
checkpath -m 644 -o rabbitmq:rabbitmq --file-truncate -f $startup_log
checkpath -m 644 -o rabbitmq:rabbitmq --file-truncate -f $startup_err
start-stop-daemon --start \
--env RABBITMQ_PID_FILE=$pidfile \
--pidfile $pidfile \
--stdout $startup_log \
--stderr $startup_err \
--background $daemon
eend $?
}
stop() {
ebegin "Stopping ${name}"
checkpath -m 644 -o rabbitmq:rabbitmq --file-truncate -f $shutdown_log
checkpath -m 644 -o rabbitmq:rabbitmq --file-truncate -f $shutdown_err
start-stop-daemon --stop --quiet --pidfile $pidfile \
--exec /bin/sh -- -c "/usr/sbin/rabbitmqctl \
--stop $pidfile > $shutdown_log \
2> $shutdown_err"
eend $?
}

View File

@ -1,12 +0,0 @@
/var/log/rabbitmq/*.log {
weekly
missingok
rotate 20
compress
delaycompress
notifempty
sharedscripts
postrotate
/usr/sbin/rabbitmqctl rotate_logs > /dev/null
endscript
}

View File

@ -1,5 +0,0 @@
#!/bin/sh
echo "Please manually remove the 'rabbitmq' user and group if no longer needed" >&2
exit 0

View File

@ -1,6 +0,0 @@
#!/bin/sh
addgroup -S rabbitmq 2>/dev/null
adduser -S -D -H -s /sbin/nologin -h /var/lib/rabbitmq -G rabbitmq \
-g 'RabbitMQ Server' rabbitmq 2>/dev/null
exit 0

View File

@ -25,7 +25,7 @@
}
},
"pandora-rabbitmq": {
"image": "rabbitmq_3.7.18-200621",
"image": "rabbitmq_3.8.9-201013",
"mounts": {
"pandora/rabbitmq_data": "var/lib/rabbitmq/mnesia"
}

View File

@ -1,16 +1,83 @@
IMAGE rabbitmq_3.7.18-200621
FROM alpine3.11_3.11.6-200621
IMAGE rabbitmq_3.8.9-201013
FROM alpine3.12_3.12.0-201013
RUN EOF
# Create OS user (which will be picked up later by apk add)
# Install RabbitMQ runtime dependencies
apk --no-cache add procps openssl
# Install RabbitMQ build dependencies
apk --no-cache add --virtual .deps autoconf gcc libc-dev linux-headers make ncurses-dev openssl-dev
# Download and unpack Erlang/OTP
cd /tmp
wget https://github.com/erlang/otp/archive/OTP-23.1.1.tar.gz
tar xf OTP-*
# Compile and install Erlang/OTP
cd /tmp/otp-*
export ERL_TOP=$(pwd)
export CFLAGS='-g -O2'
./otp_build autoconf
./configure \
--host=x86_64-linux-musl \
--build=x86_64-linux-musl \
--disable-dynamic-ssl-lib \
--disable-hipe \
--disable-sctp \
--disable-silent-rules \
--enable-clock-gettime \
--enable-hybrid-heap \
--enable-kernel-poll \
--enable-shared-zlib \
--enable-smp-support \
--enable-threads \
--with-microstate-accounting=extra \
--without-common_test \
--without-debugger \
--without-dialyzer \
--without-diameter \
--without-edoc \
--without-erl_docgen \
--without-erl_interface \
--without-et \
--without-eunit \
--without-ftp \
--without-hipe \
--without-jinterface \
--without-megaco \
--without-observer \
--without-odbc \
--without-reltool \
--without-ssh \
--without-tftp \
--without-wx
make -j $(getconf _NPROCESSORS_ONLN) GEN_OPT_FLGS="-O2 -fno-strict-aliasing"
make install
# Download and install RabbitMQ
cd /tmp
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.9/rabbitmq-server-generic-unix-latest-toolchain-3.8.9.tar.xz
tar xf rabbitmq-server-* -C /opt
mv /opt/rabbitmq* /opt/rabbitmq
sed -i 's/^SYS_PREFIX=.*$/SYS_PREFIX=/' /opt/rabbitmq/sbin/rabbitmq-defaults
ln -s /opt/rabbitmq/sbin/* /usr/sbin/
# Create RabbitMQ OS user
addgroup -S -g 5672 rabbitmq
adduser -S -u 5672 -h /var/lib/rabbitmq -s /bin/false -g rabbitmq -G rabbitmq rabbitmq
# Install RabbitMQ
apk --no-cache add rabbitmq-server@vm
# Create RabbitMQ directory structure
mkdir -p /var/lib/rabbitmq /etc/rabbitmq/conf.d /var/log/rabbitmq
chown -R rabbitmq:rabbitmq /opt/rabbitmq /var/lib/rabbitmq /etc/rabbitmq /var/log/rabbitmq
chmod 755 /var/lib/rabbitmq /etc/rabbitmq /var/log/rabbitmq
# Cleanup
apk --no-cache del .deps
rm -rf /usr/local/lib/erlang/lib/*/examples /usr/local/lib/erlang/lib/*/src /tmp/*
EOF
USER rabbitmq
ENV HOME /var/lib/rabbitmq
ENV RABBITMQ_LOGS -
CMD /usr/sbin/rabbitmq-server
READY /usr/sbin/rabbitmqctl await_startup