Framadate : premier jet branche stable 1.1.x

This commit is contained in:
Gitouche 2022-01-09 12:56:04 +01:00
parent 5ff1d51728
commit 03e4ff07d9
18 changed files with 444 additions and 28 deletions

18
podman-framadate/00_status.sh Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env bash
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
source ${ABSDIR}/../functions.sh
source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir
ensure_not_root
echo "Podman images status..."
for image in ${upstream_images} ; do
podman images ${image} | grep ${image} || echo Image ${image} not found.
done
echo "Checking pod status..."
podman pod ps | grep ${pod_name} || echo Pod ${pod_name} not found.
echo
echo "Checking systemd unit status..."
systemctl --user status ${service_name}

View file

@ -0,0 +1,19 @@
#!/usr/bin/env bash
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
source ${ABSDIR}/../functions.sh
source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir
ensure_not_root
ensure_variables_are_defined "$envvars"
if [[ -d ~/.local/share/containers/storage/volumes/${dbvolume} ]]; then
echo "Volume ${dbvolume} from previous installation already exists"
echo "Please remove them before fresh install, or try to continue with normal installation"
exit 1
fi
podman volume create ${dbvolume} && \
podman unshare chown -R 999:999 `podman volume inspect --format '{{ .Mountpoint }}' ${dbvolume}`

View file

@ -1,8 +1,30 @@
#!/usr/bin/env bash
podman volume create framadate-docker_framadate-db
podman volume create framadate-docker_framadate-data
podman unshare chown -R 999:999 `podman volume inspect --format '{{ .Mountpoint }}' framadate-docker_framadate-db`
git clone https://framagit.org/framasoft/framadate/framadate.git `podman volume inspect --format '{{ .Mountpoint }}' framadate-docker_framadate-data`
podman unshare chown -R 33:33 `podman volume inspect --format '{{ .Mountpoint }}' framadate-docker_framadate-data`
podman-compose build
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
source ${ABSDIR}/../functions.sh
source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir
ensure_not_root
ensure_variables_are_defined "$envvars"
if [[ ! -d ~/.local/share/containers/storage/volumes/${dbvolume} ]]; then
echo "Error : conf volume ${dbvolume} does not exists. Consider running 05_freshinstall.sh if this is the first install."
exit 1
fi
cat <<EOT >> .env
MYSQL_ROOT_PASSWORD=${GARBAYE_FRAMADATE_MYSQL_ROOT_PASSWORD}
MYSQL_PASSWORD=${GARBAYE_FRAMADATE_MYSQL_PASSWORD}
APP_NAME=${GARBAYE_FRAMADATE_APP_NAME}
DOMAIN=${GARBAYE_FRAMADATE_DOMAIN}
ADMIN_MAIL=${GARBAYE_FRAMADATE_ADMIN_MAIL}
ADMIN_PASSWORD=${GARBAYE_FRAMADATE_ADMIN_PASSWORD}
SMTP_SERVER=${GARBAYE_FRAMADATE_SMTP_SERVER}
EOT
export GARBAYE_FRAMADATE_FRAMADATE_VERSION="${framadate_release}"
podman-compose up -d
shred -u .env

View file

@ -1,5 +1,19 @@
#!/usr/bin/env bash
podman generate systemd --files --name framadate-docker
mkdir -p ~/.config/systemd/user/
cp *.service ~/.config/systemd/user/
systemctl --user enable pod-framadate-docker.service
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
source ${ABSDIR}/../functions.sh
source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir
ensure_not_root
ensure_pod_exists ${pod_name}
ensure_systemd_as_user_dir_exists
# pod must be running and not managed by systemd
podman generate systemd --files --name ${pod_name}
mv *.service ~/.config/systemd/user/
podman pod stop ${pod_name}
systemctl --user enable ${service_name}

24
podman-framadate/30_start.sh Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/env bash
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
source ${ABSDIR}/../functions.sh
source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir
ensure_not_root
# FAIL if pod does not exists.
ensure_pod_exists ${pod_name}
# FAIL if systemd unit does not exists.
ensure_systemd_unit_exists ${service_name}
# FAIL if systemd unit is running.
ensure_systemd_unit_not_running ${service_name}
# FAIL if pod is already running - without systemd control.
ensure_pod_not_running ${pod_name}
# OK
echo "Starting pod through systemd"
systemctl --user start ${service_name}

28
podman-framadate/40_stop.sh Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
source ${ABSDIR}/../functions.sh
source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir
ensure_not_root
ensure_pod_exists ${pod_name}
# Check of running through systemd (as it should be)
if check_systemd_unit_exists ${service_name}; then
if check_systemd_unit_running ${service_name}; then
systemctl --user stop ${service_name} &&
echo Systemd service ${service_name} stopped.
fi
fi
# Check if running through podman (no systemd), stop with podman stop , then exit
if check_pod_running ${pod_name}; then
echo Pod found running without systemd unit, stopping it now.
podman pod stop ${pod_name}
exit 0
else
echo Pod ${pod_name} is not running.
exit 1
fi

19
podman-framadate/70_disable.sh Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env bash
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
source ${ABSDIR}/../functions.sh
source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir
ensure_not_root
# FAIL if pod does not exists
ensure_pod_exists ${pod_name}
# FAIL if systemd unit does not exists
ensure_systemd_unit_exists ${service_name}
# FAIL if systemd unit is running (stop it first)
ensure_systemd_unit_not_running ${service_name}
systemctl --user disable ${service_name}

20
podman-framadate/80_destroy.sh Executable file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env bash
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
source ${ABSDIR}/../functions.sh
source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir
ensure_not_root
# FAIL if pod does not exists
ensure_pod_exists ${pod_name}
# FAIL if pod is running
ensure_pod_not_running ${pod_name}
${ABSDIR}/70_disable.sh
rm -f ${HOME}/.config/systemd/user/${service_name}
systemctl --user daemon-reload
podman pod rm ${pod_name}

22
podman-framadate/90_prune.sh Executable file
View file

@ -0,0 +1,22 @@
#!/usr/bin/env bash
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
source ${ABSDIR}/../functions.sh
source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir
ensure_not_root
# FAIL if pod is running
ensure_pod_not_running ${pod_name}
# FAIL if pod exists
ensure_pod_not_exists ${pod_name}
# FAIL if systemd unit exists
ensure_systemd_unit_not_exists ${service_name}
# remove images
for image in ${upstream_images} ; do
podman rmi $(podman images -a -q -- ${image}) || echo Image ${image} not found.
done

View file

@ -1,46 +1,41 @@
version: '3'
services:
db:
framadate-db:
container_name: framadate-db
image: mysql:5.7
image: docker.io/library/mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=${GARBAYE_FRAMADATE_MYSQL_ROOT_PASSWORD}
- MYSQL_USER=framadate
- MYSQL_PASSWORD=${GARBAYE_FRAMADATE_MYSQL_PASSWORD}
- MYSQL_DATABASE=framadate
env_file:
- .env
restart: always
ports:
- "3307:3306"
volumes:
- framadate-db:/var/lib/mysql:Z
framadate-app:
container_name: framadate-app
build:
dockerfile: ./docker/stretch/Dockerfile
context: /home/podman-user/.local/share/containers/storage/volumes/framadate-docker_framadate-data/_data/
dockerfile: ./docker/Dockerfile
context: .
args:
GARBAYE_FRAMADATE_FRAMADATE_VERSION: "$GARBAYE_FRAMADATE_FRAMADATE_VERSION"
image: "framadate-app:${GARBAYE_FRAMADATE_FRAMADATE_VERSION}"
depends_on:
- db
ports:
- 127.0.0.1:8083:80
environment:
- ENV=prod
- APP_NAME=date.garbaye.fr
- ADMIN_MAIL=contact-framadate@garbaye.fr
- MYSQL_USER=framadate
- MYSQL_PASSWORD=${GARBAYE_FRAMADATE_MYSQL_PASSWORD}
- MYSQL_DB=framadate
- MYSQL_HOST=db
- MYSQL_PORT=3307
- MYSQL_HOST=framadate-db
- MYSQL_PORT=3306
- ADMIN_USER=admin
- ADMIN_PASSWORD=${GARBAYE_FRAMADATE_ADMIN_PASSWORD}
- APACHE_RUN_USER=www-data
- FRAMADATE_DEVMODE=1
- SMTP_SERVER=backdrifts.garbaye.fr:25
env_file:
- .env
restart: always
volumes:
- framadate-data:/var/www/framadate:Z
volumes:
framadate-db:
framadate-data:

View file

@ -0,0 +1,33 @@
FROM docker.io/library/php:7-apache
ARG GARBAYE_FRAMADATE_FRAMADATE_VERSION
RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq zip unzip git zlib1g-dev libicu-dev g++ default-mysql-client git
RUN docker-php-ext-install intl && docker-php-ext-install pdo_mysql
RUN a2enmod rewrite
COPY --from=docker.io/library/composer:1.10 /usr/bin/composer /usr/bin/composer
COPY docker/php.ini /usr/local/etc/php/php.ini
COPY docker/apache-framadate.conf /etc/apache2/sites-enabled/framadate.conf
COPY docker/entrypoint.sh /usr/local/bin/entrypoint
ENV COMPOSER_ALLOW_SUPERUSER=1
RUN set -eux; \
composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --classmap-authoritative; \
composer clear-cache
ENV PATH="${PATH}:/root/.composer/vendor/bin"
ENV COMPOSER_ALLOW_SUPERUSER 0
WORKDIR /var/www/framadate
RUN git clone -b $GARBAYE_FRAMADATE_FRAMADATE_VERSION --depth=1 https://framagit.org/framasoft/framadate/framadate.git .
RUN chown -R 33:33 .
# Some Apache and PHP configuration
RUN if [ "$ENV" = "dev" ] ; then echo Using PHP production mode ; else echo Using PHP development mode && echo "error_reporting = E_ERROR | E_WARNING | E_PARSE\ndisplay_errors = On" > /usr/local/etc/php/conf.d/php.ini ; fi
RUN rm /etc/apache2/sites-enabled/000-default.conf
EXPOSE 80
ENTRYPOINT ["entrypoint"]

View file

@ -0,0 +1,28 @@
<VirtualHost *:80>
DocumentRoot /var/www/framadate
# URL rewrite
<Directory "/">
AllowOverride All
</Directory>
# Admin folder
<Directory "/var/www/framadate/admin/">
AuthType Basic
AuthName "Administration"
AuthUserFile "/var/www/framadate/admin/.htpasswd"
Require valid-user
</Directory>
# Protection fichiers htpasswd et htaccess
<FilesMatch "^\.ht.*">
Deny from all
Satisfy all
ErrorDocument 403 "Accès refusé."
</FilesMatch>
# Logs
ErrorLog /dev/stdout
CustomLog /dev/stdout combined
</VirtualHost>

View file

@ -0,0 +1,91 @@
#!/bin/bash
# Read environment variables or set default values
FRAMADATE_CONFIG=${FRAMADATE_CONFIG:-/var/www/framadate/app/inc/config.php}
DOMAIN=${DOMAIN-localhost}
FORCE_HTTPS=${FORCE_HTTPS-false}
APP_NAME=${APP_NAME-Framadate}
ADMIN_MAIL=${ADMIN_MAIL-}
NO_REPLY_MAIL=${NO_REPLY_MAIL-}
MYSQL_USER=${MYSQL_USER-user}
MYSQL_PASSWORD=${MYSQL_PASSWORD-password}
MYSQL_DB=${MYSQL_DB-framadate}
MYSQL_HOST=${MYSQL_HOST-mysql}
MYSQL_PORT=${MYSQL_PORT-3306}
DISABLE_SMTP=${DISABLE_SMTP-false}
# Add configuration file if not exist
if [ ! -f $FRAMADATE_CONFIG ]; then
echo "There is no configuration file. Create one with environment variables"
cp /var/www/framadate/tpl/admin/config.tpl $FRAMADATE_CONFIG
# Set values on configuration file
sed -i -E "s/^(\/\/ )?const APP_URL( )?=.*;/const APP_URL = '$DOMAIN';/g" $FRAMADATE_CONFIG
if [ "$FORCE_HTTPS" = true ]; then
sed -i -E "s/^(\/\/ )?const FORCE_HTTPS\\s*=.*;/const FORCE_HTTPS = true;/" $FRAMADATE_CONFIG
fi
sed -i -E "s/^(\/\/ )?const NOMAPPLICATION( )?=.*;/const NOMAPPLICATION = '$APP_NAME';/g" $FRAMADATE_CONFIG
# Configure mail
sed -i -E "s/^(\/\/ )?const ADRESSEMAILADMIN( )?=.*;/const ADRESSEMAILADMIN = '$ADMIN_MAIL';/g" $FRAMADATE_CONFIG
sed -i -E "s/^(\/\/ )?const ADRESSEMAILREPONSEAUTO( )?=.*;/const ADRESSEMAILREPONSEAUTO = '$NO_REPLY_MAIL';/g" $FRAMADATE_CONFIG
# Database configuration
sed -i -E "s/^(\/\/ )?const DB_USER( )?=.*;/const DB_USER = '$MYSQL_USER';/g" $FRAMADATE_CONFIG
sed -i -E "s/^(\/\/ )?const DB_PASSWORD( )?=.*;/const DB_PASSWORD = '$MYSQL_PASSWORD';/g" $FRAMADATE_CONFIG
sed -i -E "s/^(\/\/ )?const DB_DRIVER( )?=.*;/const DB_DRIVER = 'pdo_mysql';/g" $FRAMADATE_CONFIG
sed -i -E "s/^(\/\/ )?const DB_NAME( )?=.*;/const DB_NAME = '$MYSQL_DB';/g" $FRAMADATE_CONFIG
sed -i -E "s/^(\/\/ )?const DB_HOST( )?=.*;/const DB_HOST = '$MYSQL_HOST';/g" $FRAMADATE_CONFIG
sed -i -E "s/^(\/\/ )?const DB_PORT( )?=.*;/const DB_PORT = '$MYSQL_PORT';/g" $FRAMADATE_CONFIG
sed -i -E "s/^(\/\/ )?const DB_CONNECTION_STRING( )?=.*;/const DB_CONNECTION_STRING = 'mysql:host=$MYSQL_HOST;dbname=$MYSQL_DB;port=$MYSQL_PORT';/g" $FRAMADATE_CONFIG
# SMTP config
if [ "$DISABLE_SMTP" = "true" ]; then
sed -i -E "s/'use_smtp' => true,/'use_smtp' => false,/g" $FRAMADATE_CONFIG
fi
sed -i -E "s/localhost/${SMTP_SERVER:-localhost}/g" $FRAMADATE_CONFIG
# Framadate internal config
sed -i -E "s/^(\/\/ )?const TABLENAME_PREFIX( )?=.*;/const TABLENAME_PREFIX = 'fd_';/g" $FRAMADATE_CONFIG
sed -i -E "s/^(\/\/ )?const MIGRATION_TABLE( )?=.*;/const MIGRATION_TABLE = 'framadate_migration';/g" $FRAMADATE_CONFIG
sed -i -E "s/^(\/\/ )?const DEFAULT_LANGUAGE( )?=.*;/const DEFAULT_LANGUAGE = 'fr';/g" $FRAMADATE_CONFIG
sed -i -E "s/^(\/\/ )?const URL_PROPRE( )?=.*;/const URL_PROPRE = true;/g" $FRAMADATE_CONFIG
else
echo "Using existing config file " $FRAMADATE_CONFIG
fi
# Configure /admin basic auth
if [ ! -f /var/www/framadate/admin/.htpasswd ]; then
if [ "$ADMIN_USER" ] && [ "$ADMIN_PASSWORD" ]; then
htpasswd -bc /var/www/framadate/admin/.htpasswd $ADMIN_USER $ADMIN_PASSWORD
else
echo "!!! You need to configure ADMIN_USER and ADMIN_PASSWORD environment variables !!!"
exit 1
fi
fi
if [ "$ENV" = "dev" ]; then
echo Installing PHP development dependencies
composer install --no-interaction --no-progress
else
echo Installing PHP production dependencies
composer install -o --no-interaction --no-progress --prefer-dist --no-dev
composer dump-autoload --optimize --no-dev --classmap-authoritative
fi
# Await MySQL Container being ready
until /usr/bin/mysql --host=$MYSQL_HOST --user=$MYSQL_USER --password=$MYSQL_PASSWORD --silent --execute "SELECT 1;" $MYSQL_DB; do
>&2 echo "MySQL is unavailable - sleeping"
sleep 1
done
>&2 echo "Resuming setup"
echo "Setting up .htaccess"
cp /var/www/framadate/htaccess.txt /var/www/framadate/.htaccess
# Run Database migrations
echo "Running database migrations"
#php /var/www/framadate/bin/doctrine migrations:status --no-interaction -vvv
#php /var/www/framadate/bin/doctrine migrations:migrate --no-interaction -vvv
php /var/www/framadate/admin/migration.php
# Run apache server
# chown -R www-data:www-data /var/www/framadate
source /etc/apache2/envvars
exec apache2 -D FOREGROUND

View file

@ -0,0 +1,11 @@
apc.enable_cli = 1
date.timezone = UTC
session.auto_start = Off
short_open_tag = Off
# http://symfony.com/doc/current/performance.html
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 20000
opcache.memory_consumption = 256
realpath_cache_size = 4096K
realpath_cache_ttl = 600

View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
podman volume create framadate-docker_framadate-db
podman volume create framadate-docker_framadate-data
podman unshare chown -R 999:999 `podman volume inspect --format '{{ .Mountpoint }}' framadate-docker_framadate-db`
git clone https://framagit.org/framasoft/framadate/framadate.git `podman volume inspect --format '{{ .Mountpoint }}' framadate-docker_framadate-data`
podman unshare chown -R 33:33 `podman volume inspect --format '{{ .Mountpoint }}' framadate-docker_framadate-data`
podman-compose build
podman-compose up -d

View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
podman generate systemd --files --name framadate-docker
mkdir -p ~/.config/systemd/user/
cp *.service ~/.config/systemd/user/
systemctl --user enable pod-framadate-docker.service

View file

@ -0,0 +1,46 @@
version: '3'
services:
db:
container_name: framadate-db
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=${GARBAYE_FRAMADATE_MYSQL_ROOT_PASSWORD}
- MYSQL_USER=framadate
- MYSQL_PASSWORD=${GARBAYE_FRAMADATE_MYSQL_PASSWORD}
- MYSQL_DATABASE=framadate
restart: always
ports:
- "3307:3306"
volumes:
- framadate-db:/var/lib/mysql:Z
framadate-app:
container_name: framadate-app
build:
dockerfile: ./docker/stretch/Dockerfile
context: /home/podman-user/.local/share/containers/storage/volumes/framadate-docker_framadate-data/_data/
depends_on:
- db
ports:
- 127.0.0.1:8083:80
environment:
- ENV=prod
- APP_NAME=date.garbaye.fr
- ADMIN_MAIL=contact-framadate@garbaye.fr
- MYSQL_USER=framadate
- MYSQL_PASSWORD=${GARBAYE_FRAMADATE_MYSQL_PASSWORD}
- MYSQL_DB=framadate
- MYSQL_HOST=db
- MYSQL_PORT=3307
- ADMIN_USER=admin
- ADMIN_PASSWORD=${GARBAYE_FRAMADATE_ADMIN_PASSWORD}
- APACHE_RUN_USER=www-data
- FRAMADATE_DEVMODE=1
- SMTP_SERVER=backdrifts.garbaye.fr:25
restart: always
volumes:
- framadate-data:/var/www/framadate:Z
volumes:
framadate-db:
framadate-data:

13
podman-framadate/vars.sh Normal file
View file

@ -0,0 +1,13 @@
#!/usr/bin/env bash
pod_name='podman-framadate'
service_name="pod-${pod_name}.service"
framadate_release='1.1.19'
dbvolume='podman-framadate_framadate-db'
GARBAYE_FRAMADATE_APP_NAME="${GARBAYE_FRAMADATE_ENV_APP_NAME:-Framadate Garbaye}"
GARBAYE_FRAMADATE_DOMAIN="${GARBAYE_FRAMADATE_ENV_DOMAIN:-date.garbaye.fr}"
GARBAYE_FRAMADATE_ADMIN_MAIL="${GARBAYE_FRAMADATE_ENV_ADMIN_MAIL:-contact-framadate@garbaye.fr}"
get_default_iface_ipv4 GARBAYE_FRAMADATE_SMTP_SERVER
GARBAYE_FRAMADATE_FRAMADATE_VERSION=${framadate_version}
envvars='GARBAYE_FRAMADATE_ADMIN_PASSWORD GARBAYE_FRAMADATE_MYSQL_ROOT_PASSWORD GARBAYE_FRAMADATE_MYSQL_PASSWORD'
upstream_images='localhost/framadate-app docker.io/library/composer docker.io/library/mysql docker.io/library/php docker.io/library/composer'