From 0921c53b72a92099b5f1b69645db05288321b600 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 27 Feb 2021 15:13:57 +0300 Subject: [PATCH] initial for mariadb --- README.md | 68 ++-------------------------------------------- app/Dockerfile | 8 +++--- app/startup.sh | 12 +++----- app/updater.sh | 2 +- docker-compose.yml | 52 ++++++++++------------------------- 5 files changed, 25 insertions(+), 117 deletions(-) diff --git a/README.md b/README.md index b68a614..22d38e5 100644 --- a/README.md +++ b/README.md @@ -1,68 +1,4 @@ -# Dockerized tt-rss using docker-compose +This branch uses MySQL (actually, MariaDB). -The idea is to provide tt-rss working (and updating) out of the box with minimal fuss. +It's not supported and is only there for development. Don't use it in production. Just don't. -- [TODO](https://git.tt-rss.org/fox/ttrss-docker-compose/wiki/TODO) -- [FAQ](https://git.tt-rss.org/fox/ttrss-docker-compose/wiki#faq) - -General outline of the configuration is as follows: - - - separate containers (frontend: nginx, database: pgsql, app and updater: php/fpm) - - tt-rss updates from git master repository on container restart - - tt-rss source code is stored on a persistent volume so plugins, etc. could be easily added - - database schema is installed automatically if it is missing - - nginx has its http port exposed to the outside - - optional SSL support via Caddy w/ automatic letsencrypt certificates (deprecated) - - feed updates are handled via update daemon started in a separate container (updater) - - optional backups container which performs tt-rss database backup once a week - -### Installation - -#### Check out scripts from Git: - -```sh -git clone https://git.tt-rss.org/fox/ttrss-docker-compose.git ttrss-docker && cd ttrss-docker -``` - -#### Edit configuration files: - -Copy ``.env-dist`` to ``.env`` and edit any relevant variables you need changed. - -You will likely have to change ``SELF_URL_PATH`` which should equal fully qualified tt-rss -URL as seen when opening it in your web browser. If this field is set incorrectly, you will -likely see the correct value in the tt-rss fatal error message. - -By default, `web` container binds to **localhost** port **8280**. If you want the container to be -accessible on the net, without using a reverse proxy sharing same host, you will need to -remove ``127.0.0.1:`` from ``HTTP_PORT`` variable in ``.env``. - -Please don't rename the services inside `docker-compose.yml` unless you know what you're doing. Web container expects application container to be named `app`, if you rename it and it's not accessible via Docker DNS as `http://app` you will run into 502 errors on startup. - -Main configuration file (`config.php`) is rewritten on startup, don't edit it manually. Use [environment variables](https://git.tt-rss.org/fox/ttrss-docker-compose/wiki#how-do-i-set-global-configuration-options) or `config.d` snippets to customize it. - -#### Build and start the container - -```sh -docker-compose up --build -d -``` - -See docker-compose documentation for more information and available options. - -#### Default login credentials - -Username: `admin`, password: `password` - -### Updating - -Restarting the container will update tt-rss from the origin repository. If database needs to be updated, -tt-rss will prompt you to do so on next page refresh. - -#### Updating container scripts - -1. Stop the containers: ``docker-compose down && docker-compose rm`` -2. Update scripts from git: ``git pull origin master`` and apply any necessary modifications to ``.env``, etc. -3. Rebuild and start the containers: ``docker-compose up --build`` - -### Suggestions / bug reports - -- [Forum thread](https://community.tt-rss.org/t/docker-compose-tt-rss/2894) diff --git a/app/Dockerfile b/app/Dockerfile index 2e46a25..849b39b 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -2,11 +2,11 @@ FROM alpine:3.13 EXPOSE 9000/tcp RUN apk add --no-cache dcron php8 php8-fpm \ - php8-pdo php8-gd php8-pgsql php8-pdo_pgsql php8-mbstring \ + php8-pdo php8-gd php8-mysqlnd php8-pdo_mysql php8-mbstring \ php8-intl php8-xml php8-curl php8-session \ php8-dom php8-fileinfo php8-json php8-iconv \ php8-pcntl php8-posix php8-zip php8-openssl \ - git postgresql-client sudo php8-pecl-xdebug + git mysql-client sudo php8-pecl-xdebug ENV SCRIPT_ROOT=/opt/tt-rss @@ -31,9 +31,9 @@ ENV TTRSS_XDEBUG_ENABLED="" ENV TTRSS_XDEBUG_HOST="" ENV TTRSS_XDEBUG_PORT="9000" -ENV TTRSS_DB_TYPE="pgsql" +ENV TTRSS_DB_TYPE="mysql" ENV TTRSS_DB_HOST="db" -ENV TTRSS_DB_PORT="5432" +ENV TTRSS_DB_PORT="3306" ENV TTRSS_MYSQL_CHARSET="UTF8" ENV TTRSS_PHP_EXECUTABLE="/usr/bin/php8" diff --git a/app/startup.sh b/app/startup.sh index c869e32..24f6213 100755 --- a/app/startup.sh +++ b/app/startup.sh @@ -1,6 +1,6 @@ #!/bin/sh -e -while ! pg_isready -h $TTRSS_DB_HOST -U $TTRSS_DB_USER; do +while ! mysql -h $TTRSS_DB_HOST -u $TTRSS_DB_USER -p$TTRSS_DB_PASS -e "select 1"; do echo waiting until $TTRSS_DB_HOST is ready... sleep 3 done @@ -19,11 +19,9 @@ SRC_REPO=https://git.tt-rss.org/fox/tt-rss.git [ -e $DST_DIR ] && rm -f $DST_DIR/.app_is_ready -export PGPASSWORD=$TTRSS_DB_PASS - [ ! -e /var/www/html/index.php ] && cp ${SCRIPT_ROOT}/index.php /var/www/html -PSQL="psql -q -h $TTRSS_DB_HOST -U $TTRSS_DB_USER $TTRSS_DB_NAME" +PSQL="mysql -q -h $TTRSS_DB_HOST -u $TTRSS_DB_USER -p$TTRSS_DB_PASS $TTRSS_DB_NAME" if [ ! -d $DST_DIR/.git ]; then mkdir -p $DST_DIR @@ -65,14 +63,12 @@ for d in cache lock feed-icons; do find $DST_DIR/$d -type f -exec chmod 666 {} \; done -$PSQL -c "create extension if not exists pg_trgm" - RESTORE_SCHEMA=${SCRIPT_ROOT}/restore-schema.sql.gz if [ -r $RESTORE_SCHEMA ]; then zcat $RESTORE_SCHEMA | $PSQL -elif ! $PSQL -c 'select * from ttrss_version'; then - $PSQL < /var/www/html/tt-rss/schema/ttrss_schema_pgsql.sql +elif ! $PSQL -e 'select * from ttrss_version'; then + $PSQL < /var/www/html/tt-rss/schema/ttrss_schema_mysql.sql fi # this was previously generated diff --git a/app/updater.sh b/app/updater.sh index e3a5bb5..6b8247e 100755 --- a/app/updater.sh +++ b/app/updater.sh @@ -12,7 +12,7 @@ if ! id app >/dev/null 2>&1; then adduser -D -h /var/www/html -G app -u $OWNER_UID app fi -while ! pg_isready -h $TTRSS_DB_HOST -U $TTRSS_DB_USER; do +while ! mysql -h $TTRSS_DB_HOST -u $TTRSS_DB_USER -p$TTRSS_DB_PASS -e "select 1"; do echo waiting until $TTRSS_DB_HOST is ready... sleep 3 done diff --git a/docker-compose.yml b/docker-compose.yml index 266807e..3065012 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,12 +2,13 @@ version: '3' services: db: - image: postgres:12-alpine + image: mariadb:10 restart: unless-stopped environment: - - POSTGRES_USER=${TTRSS_DB_USER} - - POSTGRES_PASSWORD=${TTRSS_DB_PASS} - - POSTGRES_DB=${TTRSS_DB_NAME} + - MYSQL_USER=${TTRSS_DB_USER} + - MYSQL_PASSWORD=${TTRSS_DB_PASS} + - MYSQL_ROOT_PASSWORD=${TTRSS_DB_PASS} + - MYSQL_DATABASE=${TTRSS_DB_NAME} volumes: - db:/var/lib/postgresql/data @@ -38,44 +39,19 @@ services: - db command: /opt/tt-rss/dcron.sh -f - updater: - build: - context: - ./app - restart: unless-stopped - env_file: - - .env - volumes: - - app:/var/www/html - - ./config.d:/opt/tt-rss/config.d:ro - depends_on: - - app - command: /opt/tt-rss/updater.sh - -# web: -# build: ./web -# restart: unless-stopped -# ports: -# - ${HTTP_PORT}:2015 -# volumes: -# - app:/var/www/html:ro -# depends_on: -# - app - -# web-ssl: -# build: ./web-ssl +# updater: +# build: +# context: +# ./app # restart: unless-stopped -# environment: -# - CADDYPATH=/certs -# - HTTP_HOST=${HTTP_HOST} -# ports: -# - 80:80 -# - 443:443 +# env_file: +# - .env # volumes: -# - app:/var/www/html:ro -# - certs:/certs +# - app:/var/www/html +# - ./config.d:/opt/tt-rss/config.d:ro # depends_on: # - app +# command: /opt/tt-rss/updater.sh web-nginx: build: ./web-nginx