mirror of
				https://git.tt-rss.org/fox/ttrss-docker-compose
				synced 2025-10-31 01:54:12 +01:00 
			
		
		
		
	initial
This commit is contained in:
		
						commit
						a1f1862ba2
					
				
					 8 changed files with 185 additions and 0 deletions
				
			
		
							
								
								
									
										2
									
								
								.env
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.env
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | |||
| POSTGRES_USER=postgres | ||||
| POSTGRES_PASSWORD=password | ||||
							
								
								
									
										18
									
								
								README.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								README.md
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,18 @@ | |||
| # A primitive set of scripts to deploy tt-rss via docker-compose | ||||
| 
 | ||||
| The idea is to provide tt-rss working (and updating) out of the box | ||||
| with minimal fuss. | ||||
| 
 | ||||
| The general outline of the configuration is as follows: | ||||
| 
 | ||||
| - three linked containers (frontend: nginx, database: pgsql, application: php/fpm) | ||||
| - nginx has its http port exposed to the outside | ||||
| - feed updating is done via embedded cron job, every 15 minutes | ||||
| - tt-rss source updates from git master repository on container restart | ||||
| - schema is installed automatically on first startup | ||||
| - SSL termination not included, you use a sidecar container for that | ||||
| 
 | ||||
| Post your feedback here: | ||||
| 
 | ||||
| https://community.tt-rss.org/t/docker-compose-tt-rss/2894 | ||||
| 
 | ||||
							
								
								
									
										15
									
								
								app/Dockerfile
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								app/Dockerfile
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | |||
| 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 \ | ||||
| 	git postgresql-client dcron sudo | ||||
| 
 | ||||
| ADD startup.sh / | ||||
| ADD scripts/update /etc/periodic/15min/ | ||||
| 
 | ||||
| RUN sed -i.bak 's/^listen = 127.0.0.1:9000/listen = 9000/' /etc/php7/php-fpm.d/www.conf | ||||
| 
 | ||||
| CMD /startup.sh | ||||
							
								
								
									
										7
									
								
								app/scripts/update
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										7
									
								
								app/scripts/update
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,7 @@ | |||
| #!/bin/sh | ||||
| 
 | ||||
| DST_DIR=/var/www/html/tt-rss | ||||
| 
 | ||||
| if [ -s $DST_DIR/config.php ]; then | ||||
| 	sudo -u nobody $DST_DIR/update.php --feeds | ||||
| fi | ||||
							
								
								
									
										44
									
								
								app/startup.sh
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										44
									
								
								app/startup.sh
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,44 @@ | |||
| #!/bin/sh -ex | ||||
| 
 | ||||
| OWNER=nobody | ||||
| DST_DIR=/var/www/html/tt-rss | ||||
| SRC_REPO=https://git.tt-rss.org/fox/tt-rss.git | ||||
| 
 | ||||
| export PGPASSWORD=$DB_PASS  | ||||
| 
 | ||||
| PSQL="psql -q -h $DB_HOST -U $DB_USER $DB_NAME" | ||||
| 
 | ||||
| if [ ! -d $DST_DIR ]; then | ||||
| 	mkdir -p $DST_DIR | ||||
| 	git clone $SRC_REPO $DST_DIR | ||||
| else | ||||
| 	cd $DST_DIR && git pull origin master | ||||
| fi | ||||
| 
 | ||||
| chown -R $OWNER $DST_DIR | ||||
| chmod +x /etc/periodic/15min/* | ||||
| 
 | ||||
| for d in cache lock feed-icons; do | ||||
| 	chmod -R 777 $DST_DIR/$d | ||||
| done | ||||
| 
 | ||||
| if ! $PSQL -c 'select * from ttrss_version'; then | ||||
| 	$PSQL < /var/www/html/tt-rss/schema/ttrss_schema_pgsql.sql | ||||
| fi | ||||
| 
 | ||||
| if [ ! -s $DST_DIR/config.php ]; then | ||||
| 	SELF_URL_PATH=$(echo $SELF_URL_PATH | sed -e 's/[\/&]/\\&/g') | ||||
| 
 | ||||
| 	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('SELF_URL_PATH'.*/define('SELF_URL_PATH','$SELF_URL_PATH');/" \ | ||||
| 		< $DST_DIR/config.php-dist > $DST_DIR/config.php | ||||
| fi | ||||
| 
 | ||||
| crond & | ||||
| 
 | ||||
| exec /usr/sbin/php-fpm7 -F | ||||
| 
 | ||||
							
								
								
									
										43
									
								
								docker-compose.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								docker-compose.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,43 @@ | |||
| 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: | ||||
|     build: ./app | ||||
|     restart: unless-stopped | ||||
|     environment: | ||||
|       - DB_TYPE=pgsql | ||||
|       - DB_HOST=db | ||||
|       - DB_NAME=${POSTGRES_USER} | ||||
|       - DB_USER=${POSTGRES_USER} | ||||
|       - DB_PASS=${POSTGRES_PASSWORD} | ||||
|       - SELF_URL_PATH=http://localhost:8280/tt-rss | ||||
|     volumes: | ||||
|       - html:/var/www/html | ||||
|     depends_on: | ||||
|       - db | ||||
| 
 | ||||
|   web: | ||||
|     build: ./web | ||||
|     restart: unless-stopped | ||||
|     ports: | ||||
|       - 8280:80 | ||||
|     volumes: | ||||
|       - html:/var/www/html | ||||
|     depends_on: | ||||
|       - app | ||||
| 
 | ||||
| volumes: | ||||
|   db: | ||||
|   html:   | ||||
							
								
								
									
										3
									
								
								web/Dockerfile
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								web/Dockerfile
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,3 @@ | |||
| FROM nginx:alpine | ||||
| 
 | ||||
| COPY nginx.conf /etc/nginx/nginx.conf | ||||
							
								
								
									
										53
									
								
								web/nginx.conf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								web/nginx.conf
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,53 @@ | |||
| worker_processes auto; | ||||
| pid /var/run/nginx.pid; | ||||
| 
 | ||||
| events { | ||||
|     worker_connections  1024; | ||||
| } | ||||
| 
 | ||||
| http { | ||||
| 	include /etc/nginx/mime.types; | ||||
| 	default_type  application/octet-stream; | ||||
| 
 | ||||
| 	access_log /dev/stdout; | ||||
| 	error_log /dev/stderr warn; | ||||
| 
 | ||||
| 	sendfile on; | ||||
| 
 | ||||
| 	upstream app { | ||||
| 		server app:9000; | ||||
| 	} | ||||
| 
 | ||||
| 	server { | ||||
| 		listen 80; | ||||
| 		root /var/www/html; | ||||
| 
 | ||||
| 		location / { | ||||
| 			try_files $uri $uri/index.php; | ||||
| 		} | ||||
| 
 | ||||
| 		location /tt-rss/cache { | ||||
| 			aio threads; | ||||
| 			internal; | ||||
| 			access_log /var/log/nginx/fakecake_debug.log; | ||||
| 		} | ||||
| 
 | ||||
| 		location ~ \.php$ { | ||||
| 			# regex to split $uri to $fastcgi_script_name and $fastcgi_path | ||||
| 			fastcgi_split_path_info ^(.+?\.php)(/.*)$; | ||||
| 
 | ||||
| 			# Check that the PHP script exists before passing it | ||||
| 			try_files $fastcgi_script_name =404; | ||||
| 
 | ||||
| 			# Bypass the fact that try_files resets $fastcgi_path_info | ||||
| 			# see: http://trac.nginx.org/nginx/ticket/321 | ||||
| 			set $path_info $fastcgi_path_info; | ||||
| 			fastcgi_param PATH_INFO $path_info; | ||||
| 
 | ||||
| 			fastcgi_index index.php; | ||||
| 			include fastcgi.conf; | ||||
| 
 | ||||
| 			fastcgi_pass app; | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue