Archived
1
0
Fork 0

Add docker image example with docker-compose

This commit is contained in:
Varakh 2019-01-18 17:49:49 +01:00
parent 20fb428b1e
commit d42eaa9111
9 changed files with 270 additions and 36 deletions

View file

@ -1,4 +1,4 @@
# README #
# README
**ts3web** is a web interface for any TeamSpeak 3 Server used with serverQuery login.
@ -10,15 +10,48 @@ Features which are currently not supported:
- Permissions Management (except for viewing)
- File Management (except for viewing)
## Install ##
## Install / Deployment
You can either use docker or manual deployment.
### Docker
#### Install
There's an example `docker-compose.yml` in the `docker-compose/` directory. Please read the following section carefully as the setup will be explained.
* Clone repository
* Copy `config/env.example` to `config/env` and adjust to your needs. Ensure that if you share the same docker network, the environment variable `teamspeak_default_host` should be the name of your teamspeak docker container.
* Build the docker image from the project home with `docker build -t ts3web:latest -f docker/Dockerfile .`
* Create a container with the image. Make sure that if teamspeak and ts3web share the same docker instance they should be put into one network and the subnet should be added to teamspeak's query whitelist. The web interface won't work otherwise.
From the example:
* Copy `docker-compose/env` file to `config/env`
* Change directory to `docker-compose/` folder
* Execute `docker-compose up -d`
#### Upgrade
* Change directory to project home
* `git pull`
* Change directory to `docker-compose/` folder
* Execute `docker-compose down`
* Execute `docker-compose up -d`
### Manual
#### Install
* Clone repository
* Install composer
* Change directory to project home
* Copy `config/env.example` to `config/env` and adjust to your needs
* `composer install`
## Deployment ##
#### Configuration
* Copy `config/env.example` to `config/env` and adjust to your needs
* Configure nginx or apache.
* Point your document root to `public/`.
* Example `nginx.conf`:
@ -44,17 +77,17 @@ location ~ \.php$ {
}
```
## Upgrade ##
#### Upgrade
* Change directory to project home
* `git pull`
* `composer update`
## Developers ##
## Developers
* start server with `php -S localhost:8080 -t public public/index.php`
* point browser to [localhost:8080](http://localhost:8080) to have a preview
### Helpers ###
### Helpers
Attributes can be defined when including `table`, `keyvalues` and `form` templates of twig. This helps to generate tables and forms without the need to specify all attributes.
@ -70,10 +103,10 @@ fields // define fields for a form
See example usage in the folder `View/material`.
## Translations ##
## Translations
- This app uses Symfony Translator. It's bootstrapped in `Util\BootstrapHelper` and locales are placed under `data/locale/`. Adjust to your needs or help translating.
- Form fields (name/id should be the same) are also translated. For a field named `content` or `ConT enT` translate `form_field_content`.
## Theme ##
## Theme
Themes can be chosen in the `env` file by editing the `theme` variable. Templates are mapped to the corresponding view folder in `src/View/<themeName>`. `.css`, `.js` and other style files like `.ttf` or `.woff2` for fonts should be placed in `public/theme/<themeName>` and accessed accordingly. See an example in `src/View/material/layout/header.twig`.

View file

@ -1,6 +1,5 @@
# site
site_title="Teamspeak 3 Web"
site_url="http://localhost:8080"
site_language="en" # values: each yml you specified in data/locale/
site_date_format="d.m.Y H:i:s" # values: all possible for Date::class
@ -9,7 +8,7 @@ theme="material" # values: material (foldernames are used to determine theme in
theme_cache=false # values: true|false (cache view/twig. makes it faster, disable for debug)
# teamspeak
teamspeak_default_host="localhost"
teamspeak_default_host="localhost" # 'localhost' or 'name_of_docker_container' if running locally
teamspeak_default_query_port=10011
teamspeak_default_user="serveradmin"

View file

@ -0,0 +1,33 @@
version: '2'
networks:
network:
ipam:
driver: default
config:
- subnet: 172.254.0.0/16
services:
app:
container_name: teamspeak_app
image: teamspeak:latest
volumes:
- ./teamspeak:/var/ts3server
- ./whitelist.txt:/whitelist.txt
ports:
- 10011:10011
- 30033:30033
- 9987:9987/udp
environment:
- TS3SERVER_LICENSE=accept
- TS3SERVER_IP_WHITELIST=/whitelist.txt
restart: always
networks:
- network
web:
container_name: teamspeak_web
image: ts3web:latest
ports:
- 8181:80
restart: always
networks:
- network

17
docker-compose/env Normal file
View file

@ -0,0 +1,17 @@
# site
site_title="Teamspeak 3 Web"
site_language="en" # values: each yml you specified in data/locale/
site_date_format="d.m.Y H:i:s" # values: all possible for Date::class
# theme
theme="material" # values: material (foldernames are used to determine theme in src/View/)
theme_cache=false # values: true|false (cache view/twig. makes it faster, disable for debug)
# teamspeak
teamspeak_default_host="teamspeak_app" # 'localhost' or 'name_of_docker_container' if running locally
teamspeak_default_query_port=10011
teamspeak_default_user="serveradmin"
# log
log_name="ts3web" # values: all strings
log_level="INFO" # values: DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY

View file

@ -0,0 +1 @@
172.254.0.0/16

25
docker/Dockerfile Normal file
View file

@ -0,0 +1,25 @@
FROM phpearth/php:7.3-nginx
# install deps
RUN apk add --no-cache git
RUN apk add --no-cache composer
# adjust nginx
COPY docker/default.conf /etc/nginx/conf.d/default.conf
COPY docker/nginx.conf /etc/nginx/nginx.conf
# copy application and set permissions
RUN mkdir -p /var/www/html/ts3web/bin/
COPY config/ /var/www/html/ts3web/config/
RUN mkdir -p /var/www/html/ts3web/cache/
ADD data/ /var/www/html/ts3web/data/
RUN chmod -R 777 /var/www/html/ts3web/data/
RUN mkdir -p /var/www/html/ts3web/log/
RUN touch /var/www/html/ts3web/log/application.log
RUN chmod 777 /var/www/html/ts3web/log/application.log
ADD public/ /var/www/html/ts3web/public/
ADD src/ /var/www/html/ts3web/src/
ADD composer.json /var/www/html/ts3web/composer.json
# initialize app
RUN cd /var/www/html/ts3web/ && composer install

30
docker/default.conf Normal file
View file

@ -0,0 +1,30 @@
# copied to /etc/nginx/conf.d/default.conf
server {
listen 80 default_server;
root /var/www/html/ts3web/public;
index index.html index.htm index.php;
server_name _;
charset utf-8;
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; }
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php-fpm.sock;
include fastcgi.conf;
}
error_page 404 /index.php;
location ~ /\.ht {
deny all;
}
}

97
docker/nginx.conf Normal file
View file

@ -0,0 +1,97 @@
# /etc/nginx/nginx.conf
user nginx;
# Set number of worker processes automatically based on number of CPU cores.
worker_processes auto;
# Enables the use of JIT for regular expressions to speed-up their processing.
pcre_jit on;
# Configures default error logger.
error_log /var/log/nginx/error.log warn;
# Includes files with directives to load dynamic modules.
include /etc/nginx/modules/*.conf;
events {
# The maximum number of simultaneous connections that can be opened by
# a worker process.
worker_connections 1024;
}
http {
# Includes mapping of file name extensions to MIME types of responses
# and defines the default type.
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Name servers used to resolve names of upstream servers into addresses.
# It's also needed when using tcpsocket and udpsocket in Lua modules.
#resolver 208.67.222.222 208.67.220.220;
# Don't tell nginx version to clients.
server_tokens off;
# Specifies the maximum accepted body size of a client request, as
# indicated by the request header Content-Length. If the stated content
# length is greater than this size, then the client receives the HTTP
# error code 413. Set to 0 to disable.
client_max_body_size 1024m;
# Timeout for keep-alive connections. Server will close connections after
# this time.
keepalive_timeout 65;
# Sendfile copies data between one FD and other from within the kernel,
# which is more efficient than read() + write().
sendfile on;
# Don't buffer data-sends (disable Nagle algorithm).
# Good for sending frequent small bursts of data in real time.
tcp_nodelay on;
# Causes nginx to attempt to send its HTTP response head in one packet,
# instead of using partial frames.
#tcp_nopush on;
# Path of the file with Diffie-Hellman parameters for EDH ciphers.
#ssl_dhparam /etc/ssl/nginx/dh2048.pem;
# Specifies that our cipher suits should be preferred over client ciphers.
ssl_prefer_server_ciphers on;
# Enables a shared SSL cache with size that can hold around 8000 sessions.
ssl_session_cache shared:SSL:2m;
# Enable gzipping of responses.
gzip on;
# Set the Vary HTTP header as defined in the RFC 2616.
gzip_vary on;
# Enable checking the existence of precompressed files.
#gzip_static on;
# Specifies the main log format.
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# Sets the path, format, and configuration for a buffered log write.
access_log /var/log/nginx/access.log main;
proxy_buffering on;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
# Includes virtual hosts configs.
include /etc/nginx/conf.d/*.conf;
}

View file

@ -29,7 +29,6 @@ class BootstrapHelper
try {
$env->required([
'site_title',
'site_url',
'site_language',
'site_date_format',
'theme',