refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s

This commit is contained in:
Kroonk
2026-05-22 16:19:55 +02:00
parent 38cc4c09ca
commit a213a1dba0
2215 changed files with 242567 additions and 6015 deletions

3
scripts/vagrant/build/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*.box
*.log
.vagrant/

View File

@@ -0,0 +1,22 @@
GIT_TAG := $(shell git describe --abbrev=0 --tags)
VERSION := $(subst v,,$(GIT_TAG))
build: base
rm -rf .vagrant
GIT_TAG=$(GIT_TAG) vagrant up monicahq-stable
base:
vagrant box list | grep -q "ubuntu/bionic64" || vagrant box add ubuntu/bionic64
vagrant box update --box ubuntu/bionic64
package: build
rm -f monicahq-stable.box
vagrant box remove monicahq/monicahq --box-version 0 || true
vagrant package monicahq-stable --output ./monicahq-stable.box --vagrantfile ../Vagrantfile
vagrant box add monicahq/monicahq ./monicahq-stable.box
upload:
mv monicahq-stable.box monicahq-$(GIT_TAG).box
./vagrant-upload.sh
.PHONY: build base package

26
scripts/vagrant/build/Vagrantfile vendored Normal file
View File

@@ -0,0 +1,26 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION ||= "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.synced_folder ".", "/vagrant"
# Create a box with the latest version available
config.vm.define "monicahq-latest", primary: true do |monicahq|
monicahq.vm.box = "ubuntu/bionic64"
monicahq.vm.hostname = "monica"
monicahq.vm.boot_timeout = 180
monicahq.vm.provision "shell", path: "install-monica.sh", keep_color: true
end
# Create a box with the specific version tag
config.vm.define "monicahq-stable" do |monicahq|
monicahq.vm.box = "ubuntu/bionic64"
monicahq.vm.hostname = "monica"
monicahq.vm.boot_timeout = 180
monicahq.vm.provision "shell", path: "install-monica.sh", keep_color: true, env: {"GIT_TAG" => "#{ENV['GIT_TAG']}"}
end
end

View File

@@ -0,0 +1,105 @@
#!/usr/bin/env bash
set -euo pipefail
MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-changeme}
MYSQL_DB_DATABASE=${MYSQL_DB_DATABASE:-monica}
MYSQL_DB_USERNAME=${MYSQL_DB_USERNAME:-monica}
MYSQL_DB_PASSWORD=${MYSQL_DB_PASSWORD:-changeme}
DESTDIR=/var/www/html/monica
function update_setting() {
file=$1
name=$2
value=$3
if $(grep -q "$name" $file); then
sed -i "s/\($name\).*/\1=$value/" $file;
else
echo -e "\n$name=$value" | tee -a $file;
fi
}
export DEBIAN_FRONTEND=noninteractive
apt-get update >/dev/null
echo -e "\033[1;32m########################\033[0;40m"
echo -e "\033[1;32mInstalling Monica ${GIT_TAG:-}\033[0;40m"
echo -e "\033[1;32m########################\033[0;40m"
echo -e "\n\033[4;32mInstalling apache\033[0;40m"
apt-get install -y apache2 >/dev/null
echo "ServerName vagrant" >> /etc/apache2/apache2.conf # suppress apache warning
echo -e "\n\033[4;32mInstalling MySQL with default root password\033[0;40m"
debconf-set-selections <<< "mysql-server mysql-server/root_password password $MYSQL_ROOT_PASSWORD"
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $MYSQL_ROOT_PASSWORD"
apt-get install -y mysql-server mysql-client >/dev/null
echo -e "\n\033[4;32mInstalling PHP 8.1\033[0;40m"
apt-get install -y curl gnupg2 apt-transport-https apt-transport-https lsb-release ca-certificates >/dev/null
add-apt-repository -y ppa:ondrej/php >/dev/null
apt-get update >/dev/null
apt-get install -y php8.1 >/dev/null
echo -e "\n\033[4;32mInstalling git\033[0;40m"
apt-get install -y git >/dev/null
echo -e "\n\033[4;32mInstalling composer\033[0;40m"
apt-get install -y curl php8.1-cli >/dev/null
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer >/dev/null
echo -e "\n\033[4;32mInstalling packages for Monica\033[0;40m"
apt-get install -y php8.1-bcmath php8.1-curl php8.1-common php8.1-fpm \
php8.1-gd php8.1-gmp php8.1-intl php8.1-json php8.1-mbstring php8.1-mysql \
php8.1-opcache php8.1-redis php8.1-xml php8.1-zip >/dev/null
echo -e "\n\033[4;32mInstalling node.js\033[0;40m"
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - >/dev/null
apt-get install -y nodejs >/dev/null
echo -e "\n\033[4;32mInstalling yarn\033[0;40m"
npm install --global yarn >/dev/null
echo -e "\n\033[4;32mGetting database ready\033[0;40m"
mysql -uroot -p$MYSQL_ROOT_PASSWORD -e "CREATE DATABASE $MYSQL_DB_DATABASE;
CREATE USER '$MYSQL_DB_USERNAME'@'localhost' IDENTIFIED BY '$MYSQL_DB_PASSWORD';
GRANT ALL ON $MYSQL_DB_DATABASE.* TO '$MYSQL_DB_USERNAME'@'localhost';
FLUSH PRIVILEGES;"
echo -e "\n\033[4;32mInstalling Monica\033[0;40m"
git clone https://github.com/monicahq/monica.git $DESTDIR
cd $DESTDIR
if [ -n "${GIT_TAG:-}" ]; then
git checkout tags/$GIT_TAG
fi
composer install --no-interaction --no-dev --no-progress >/dev/null
composer clear-cache
echo -e "\n\033[4;32mBuild assets\033[0;40m"
yarn install
yarn run production
echo -e "\n\033[4;32mConfiguring Monica\033[0;40m"
cp .env.example .env
update_setting .env DB_DATABASE "$MYSQL_DB_DATABASE"
update_setting .env DB_USERNAME "$MYSQL_DB_USERNAME"
update_setting .env DB_PASSWORD "$MYSQL_DB_PASSWORD"
update_setting .env APP_DISABLE_SIGNUP "false"
chown -R www-data:www-data .
echo -e "\n\033[4;32mConfiguring cron script\033[0;40m"
{ crontab -l -u www-data; echo "* * * * * /usr/bin/php $DESTDIR/artisan schedule:run"; } | crontab -u www-data - || true
echo -e "\n\033[4;32mConfiguring apache\033[0;40m"
a2enmod rewrite
sed -i "s/\(DocumentRoot\).*/\1 ${DESTDIR//\//\\\/}\/public/" /etc/apache2/sites-enabled/000-default.conf
sed -i "s/\/var\/www\//${DESTDIR//\//\\\/}\/public\//" /etc/apache2/apache2.conf
sed -i "/<Directory ${DESTDIR//\//\\\/}\/public\/>/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/" /etc/apache2/apache2.conf
systemctl restart apache2
echo -e "\n\033[4;32mSystem update\033[0;40m"
apt-get -y upgrade
apt-get -y autoremove
apt-get -y clean

View File

@@ -0,0 +1,75 @@
#!/bin/bash
set -euvo pipefail
GIT_TAG=$(git describe --abbrev=0 --tags)
VERSION=${GIT_TAG##v}
API=https://app.vagrantup.com/api/v1
# Create a new version
response=$(
curl -sSL --header "Content-Type: application/json" --header "Authorization: Bearer $VAGRANT_CLOUD_TOKEN" \
"$API/box/monicahq/monicahq/versions" \
--data "{ \
\"version\": { \
\"version\": \"$VERSION\", \
\"description\": \"https://github.com/monicahq/monica/releases/tag/$GIT_TAG\" \
} \
}"
)
if [ $(echo "$response" | jq .success) == "false" ]; then
if [ $(echo "$response" | jq .errors[0]) != "Version has already been taken" ]; then
echo "$response" | jq .errors[0]
exit 1
fi
fi
# Create provider
response=$(
curl -sSL --header "Content-Type: application/json" --header "Authorization: Bearer $VAGRANT_CLOUD_TOKEN" \
"$API/box/monicahq/monicahq/version/$VERSION/providers" \
--data "{ \
\"provider\": { \
\"name\": \"virtualbox\" \
} \
}"
)
if [ $(echo "$response" | jq .success) == "false" ]; then
if [ $(echo "$response" | jq .errors[0]) != "Metadata provider must be unique for version" ]; then
echo "$response" | jq .errors[0]
exit 1
fi
fi
# Upload the box
response=$(
curl -sSL --header "Authorization: Bearer $VAGRANT_CLOUD_TOKEN" \
"$API/box/monicahq/monicahq/version/$VERSION/provider/virtualbox/upload"
)
if [ $(echo "$response" | jq .success) == "false" ]; then
echo "$response" | jq .errors[0]
exit 1
fi
upload_path=$(echo "$response" | jq .upload_path)
upload_path="${upload_path%\"}"
upload_path="${upload_path#\"}"
curl -fL --progress-bar \
--request PUT \
"$upload_path" \
--upload-file "monicahq-$GIT_TAG.box"
retval=$?
if [ $? -ne 0 ]; then
exit 1
fi
# Publish the version
response=$(
curl -sSL --header "Authorization: Bearer $VAGRANT_CLOUD_TOKEN" \
--request PUT \
"$API/box/monicahq/monicahq/version/$VERSION/release"
)
if [ $(echo "$response" | jq .success) == "false" ]; then
echo "$response" | jq .errors[0]
exit 1
fi