mirror of
https://git.tt-rss.org/fox/ttrss-docker-compose
synced 2025-06-14 07:19:52 +02:00
split build-related stuff into src/
This commit is contained in:
parent
15caf46b66
commit
98d65cd865
11 changed files with 120 additions and 14 deletions
23
src/app/Dockerfile
Normal file
23
src/app/Dockerfile
Normal file
|
@ -0,0 +1,23 @@
|
|||
FROM alpine:3.9
|
||||
EXPOSE 9000/tcp
|
||||
|
||||
RUN apk add --no-cache php7 php7-fpm \
|
||||
php7-pdo php7-gd php7-pgsql php7-pdo_pgsql php7-mbstring \
|
||||
php7-intl php7-xml php7-curl php7-session \
|
||||
php7-dom php7-fileinfo php7-json \
|
||||
php7-pcntl php7-posix \
|
||||
git postgresql-client sudo rsync
|
||||
|
||||
ADD startup.sh /
|
||||
ADD updater.sh /
|
||||
ADD index.php /
|
||||
ADD build-prepare.sh /
|
||||
|
||||
RUN sed -i.bak 's/^listen = 127.0.0.1:9000/listen = 9000/' /etc/php7/php-fpm.d/www.conf
|
||||
|
||||
ARG OWNER_UID
|
||||
ARG OWNER_GID
|
||||
|
||||
RUN sh -c /build-prepare.sh
|
||||
|
||||
CMD /startup.sh
|
26
src/app/build-prepare.sh
Executable file
26
src/app/build-prepare.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
|
||||
DST_DIR=/src/tt-rss
|
||||
SRC_REPO=https://git.tt-rss.org/fox/tt-rss.git
|
||||
|
||||
if [ ! -d $DST_DIR ]; then
|
||||
mkdir -p $DST_DIR
|
||||
git clone $SRC_REPO $DST_DIR
|
||||
else
|
||||
cd $DST_DIR && \
|
||||
git config core.filemode false && \
|
||||
git pull origin master
|
||||
fi
|
||||
|
||||
if [ ! -d $DST_DIR/plugins.local/nginx_xaccel ]; then
|
||||
git clone https://git.tt-rss.org/fox/ttrss-nginx-xaccel.git $DST_DIR/plugins.local/nginx_xaccel
|
||||
else
|
||||
cd $DST_DIR/plugins.local/nginx_xaccel && \
|
||||
git config core.filemode false && \
|
||||
git pull origin master
|
||||
fi
|
||||
|
||||
mkdir -p /var/www
|
||||
addgroup -g $OWNER_GID app
|
||||
adduser -D -h /var/www/html -G app -u $OWNER_UID app
|
||||
|
3
src/app/index.php
Normal file
3
src/app/index.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
header("Location: /tt-rss/");
|
||||
return;
|
79
src/app/startup.sh
Executable file
79
src/app/startup.sh
Executable file
|
@ -0,0 +1,79 @@
|
|||
#!/bin/sh -ex
|
||||
|
||||
while ! pg_isready -h $DB_HOST -U $DB_USER; do
|
||||
echo waiting until $DB_HOST is ready...
|
||||
sleep 3
|
||||
done
|
||||
|
||||
DST_DIR=/var/www/html/tt-rss
|
||||
SRC_DIR=/src/tt-rss/
|
||||
|
||||
[ -e $DST_DIR ] && rm -f $DST_DIR/.app_is_ready
|
||||
|
||||
export PGPASSWORD=$DB_PASS
|
||||
|
||||
[ ! -e /var/www/html/index.php ] && cp /index.php /var/www/html
|
||||
|
||||
if [ ! -d $DST_DIR ]; then
|
||||
rsync -aP \
|
||||
$SRC_DIR/ $DST_DIR/
|
||||
else
|
||||
rsync -aP --delete \
|
||||
--exclude cache \
|
||||
--exclude lock \
|
||||
--exclude feed-icons \
|
||||
--exclude plugins.local \
|
||||
--exclude themes.local \
|
||||
$SRC_DIR/ $DST_DIR/
|
||||
|
||||
rsync -aP --delete \
|
||||
$SRC_DIR/plugins.local/nginx_xaccel $DST_DIR/plugins.local/nginx_xaccel
|
||||
fi
|
||||
|
||||
for d in cache lock feed-icons plugins.local themes.local; do
|
||||
mkdir -p $DST_DIR/$d
|
||||
done
|
||||
|
||||
for d in cache lock feed-icons; do
|
||||
chmod -R 777 $DST_DIR/$d
|
||||
done
|
||||
|
||||
chown -R $OWNER_UID:$OWNER_GID $DST_DIR
|
||||
|
||||
PSQL="psql -q -h $DB_HOST -U $DB_USER $DB_NAME"
|
||||
|
||||
$PSQL -c "create extension if not exists pg_trgm"
|
||||
|
||||
RESTORE_SCHEMA=/var/www/html/tt-rss/backups/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
|
||||
fi
|
||||
|
||||
SELF_URL_PATH=$(echo $SELF_URL_PATH | sed -e 's/[\/&]/\\&/g')
|
||||
|
||||
if [ ! -s $DST_DIR/config.php ]; then
|
||||
sed \
|
||||
-e "s/define('DB_HOST'.*/define('DB_HOST', '$DB_HOST');/" \
|
||||
-e "s/define('DB_USER'.*/define('DB_USER', '$DB_USER');/" \
|
||||
-e "s/define('DB_NAME'.*/define('DB_NAME', '$DB_NAME');/" \
|
||||
-e "s/define('DB_PASS'.*/define('DB_PASS', '$DB_PASS');/" \
|
||||
-e "s/define('PLUGINS'.*/define('PLUGINS', 'auth_internal, note, nginx_xaccel');/" \
|
||||
-e "s/define('SELF_URL_PATH'.*/define('SELF_URL_PATH','$SELF_URL_PATH');/" \
|
||||
< $DST_DIR/config.php-dist > $DST_DIR/config.php
|
||||
|
||||
cat >> $DST_DIR/config.php << EOF
|
||||
define('NGINX_XACCEL_PREFIX', '/tt-rss');
|
||||
EOF
|
||||
else
|
||||
sed \
|
||||
-e "s/define('SELF_URL_PATH'.*/define('SELF_URL_PATH','$SELF_URL_PATH');/" \
|
||||
-i.bak $DST_DIR/config.php
|
||||
fi
|
||||
|
||||
touch $DST_DIR/.app_is_ready
|
||||
|
||||
exec /usr/sbin/php-fpm7 -F
|
||||
|
18
src/app/updater.sh
Executable file
18
src/app/updater.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh -ex
|
||||
|
||||
# wait for the app container to delete .app_is_ready and perform rsync, etc.
|
||||
sleep 30
|
||||
|
||||
while ! pg_isready -h $DB_HOST -U $DB_USER; do
|
||||
echo waiting until $DB_HOST is ready...
|
||||
sleep 3
|
||||
done
|
||||
|
||||
DST_DIR=/var/www/html/tt-rss
|
||||
|
||||
while [ ! -s $DST_DIR/config.php -a -e $DST_DIR/.app_is_ready ]; do
|
||||
echo waiting for app container...
|
||||
sleep 3
|
||||
done
|
||||
|
||||
exec /usr/bin/php /var/www/html/tt-rss/update_daemon2.php
|
94
src/docker-compose.yml
Normal file
94
src/docker-compose.yml
Normal file
|
@ -0,0 +1,94 @@
|
|||
version: '3'
|
||||
|
||||
# set database password in .env
|
||||
# please don't use quote (') or (") symbols in variables
|
||||
|
||||
services:
|
||||
db:
|
||||
image: postgres:12-alpine
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- db:/var/lib/postgresql/data
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
|
||||
app:
|
||||
image: cthulhoo/ttrss-fpm-pgsql-static
|
||||
build:
|
||||
context:
|
||||
./app
|
||||
args:
|
||||
- OWNER_UID=${OWNER_UID}
|
||||
- OWNER_GID=${OWNER_GID}
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- DB_TYPE=pgsql
|
||||
- DB_HOST=db
|
||||
- DB_NAME=${POSTGRES_USER}
|
||||
- DB_USER=${POSTGRES_USER}
|
||||
- DB_PASS=${POSTGRES_PASSWORD}
|
||||
- OWNER_UID=${OWNER_UID}
|
||||
- OWNER_GID=${OWNER_GID}
|
||||
- SELF_URL_PATH=${SELF_URL_PATH}
|
||||
volumes:
|
||||
- app:/var/www/html
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
updater:
|
||||
image: cthulhoo/ttrss-fpm-pgsql-static
|
||||
build:
|
||||
context:
|
||||
./app
|
||||
args:
|
||||
- OWNER_UID=${OWNER_UID}
|
||||
- OWNER_GID=${OWNER_GID}
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- DB_TYPE=pgsql
|
||||
- DB_HOST=db
|
||||
- DB_NAME=${POSTGRES_USER}
|
||||
- DB_USER=${POSTGRES_USER}
|
||||
- DB_PASS=${POSTGRES_PASSWORD}
|
||||
- OWNER_UID=${OWNER_UID}
|
||||
- OWNER_GID=${OWNER_GID}
|
||||
- SELF_URL_PATH=${SELF_URL_PATH}
|
||||
volumes:
|
||||
- app:/var/www/html
|
||||
depends_on:
|
||||
- app
|
||||
user: app
|
||||
command: /updater.sh
|
||||
|
||||
web:
|
||||
image: cthulhoo/ttrss-web
|
||||
build: ./web
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- ${HTTP_PORT}:2015
|
||||
volumes:
|
||||
- app:/var/www/html:ro
|
||||
depends_on:
|
||||
- app
|
||||
|
||||
web-ssl:
|
||||
image: cthulhoo/ttrss-web-ssl
|
||||
build: ./web-ssl
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- CADDYPATH=/certs
|
||||
- HTTP_HOST=${HTTP_HOST}
|
||||
ports:
|
||||
- 80:80
|
||||
- 443:443
|
||||
volumes:
|
||||
- app:/var/www/html:ro
|
||||
- certs:/certs
|
||||
depends_on:
|
||||
- app
|
||||
|
||||
volumes:
|
||||
db:
|
||||
app:
|
||||
certs:
|
8
src/web-ssl/Caddyfile
Normal file
8
src/web-ssl/Caddyfile
Normal file
|
@ -0,0 +1,8 @@
|
|||
{%HTTP_HOST%}
|
||||
tls ttrss@{%HTTP_HOST%}
|
||||
|
||||
root /var/www/html
|
||||
log stdout
|
||||
errors stderr
|
||||
internal /tt-rss/cache
|
||||
fastcgi / app:9000 php
|
4
src/web-ssl/Dockerfile
Normal file
4
src/web-ssl/Dockerfile
Normal file
|
@ -0,0 +1,4 @@
|
|||
FROM abiosoft/caddy:no-stats
|
||||
|
||||
COPY Caddyfile /etc/
|
||||
ENV ACME_AGREE=true
|
6
src/web/Caddyfile
Normal file
6
src/web/Caddyfile
Normal file
|
@ -0,0 +1,6 @@
|
|||
0.0.0.0
|
||||
root /var/www/html
|
||||
log stdout
|
||||
errors stderr
|
||||
internal /tt-rss/cache
|
||||
fastcgi / app:9000 php
|
3
src/web/Dockerfile
Normal file
3
src/web/Dockerfile
Normal file
|
@ -0,0 +1,3 @@
|
|||
FROM abiosoft/caddy:no-stats
|
||||
|
||||
COPY Caddyfile /etc/
|
Loading…
Add table
Add a link
Reference in a new issue