diff --git a/README.md b/README.md index 48a7abc..6956fc2 100755 --- a/README.md +++ b/README.md @@ -7,52 +7,74 @@ This web interface aims to be as simple as possible. The minimalistic approach i If you like to help (to translate or implement features), open an issue first. If possible, you should use existing code to implement new features. PRs will be merged after a code review. Features which are currently not supported: -- Permissions Management (except for viewing) -- File Management (except for viewing) + +* Permissions Management (except for viewing) +* File Management (except for viewing) + +## Configuration + +The main configuration file is the `env` file located in `config/`. There's an example file called `env.example` which you +need to copy to `config/env`. + +**Information for docker users**: it's possible to have the `env` file persistent and not within the container so +that rebuilding the image isn't required. Create a host volume `/path/from/host/env` and map it to +`/var/www/html/application/config/env`. Changes will show up after restarting the container. ## Install / Deployment -You can either use docker or manual deployment. +You can either use docker or manual deployment. Please read the following section carefully. -### Docker +### Automatic installation and deployment with docker or docker-compose -#### Install +##### 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. +###### docker * 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. +* Copy either `config/env.example` to `config/env` and adjust to your needs or make it persistent outside if the container. To do so take a look at the configuration section first). 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 teamspeak_web:latest -f docker/Dockerfile .` +* Create a container with the image, e.g. `docker run --name teamspeak_web -p 8181:80 slimblog_app:latest`. Make sure that if teamspeak and ts3web share the same docker instance they should be put into one network and the subnet **needs be added to teamspeak's query whitelist**. The web interface won't work otherwise. +* Point your browser to `8181` to see the web interface. -From the example: +###### docker-compose -* Copy `docker-compose/env` file to `config/env` -* Build the docker image from the project home with `docker build -t ts3web:latest -f docker/Dockerfile .` +There's an example `docker-compose.yml` in the `docker-compose/` directory. + +* Adjust `docker-compose/env` if you need to change something. +* Build the docker image from the project home with `docker build -t teamspeak_web:latest -f docker/Dockerfile .` * Change directory to `docker-compose/` folder * Execute `docker-compose up -d` -* Everything should be up and running. Point your browser to `8181` to see the web interface, look into the logs for a teamspeak serveradmin login. +* Point your browser to `8080` to see the web interface. -#### Upgrade +##### Upgrade + +###### docker * Change directory to project home * `git pull` +* Build the docker image from the project home with `docker build -t teamspeak_web:latest -f docker/Dockerfile .` +* Re-create app container with latest image + +###### docker-compose + +* Change directory to project home +* `git pull` +* Build the docker image from the project home with `docker build -t teamspeak_web:latest -f docker/Dockerfile .` * Change directory to `docker-compose/` folder * Execute `docker-compose down` * Execute `docker-compose up -d` -### Manual +### Manual installation and deployment #### Install * Clone repository * Install composer * Change directory to project home +* Execute `composer install` * `composer install` -#### Configuration - -* Copy `config/env.example` to `config/env` and adjust to your needs +#### Web server * Configure nginx or apache. * Point your document root to `public/`. * Example `nginx.conf`: @@ -78,18 +100,19 @@ From the example: include fastcgi_params; } ``` - +* Everything should be up and running. Point your browser to `8080` to see the web interface. + #### Upgrade * Change directory to project home * `git pull` * `composer update` -## 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 +### Contributions & Development +* Follow manual install guide but use the internal server with `php -S localhost:8080 -t public public/index.php` +* Point browser to [localhost:8080](http://localhost:8080) -### 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. @@ -105,10 +128,9 @@ 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 -Themes can be chosen in the `env` file by editing the `theme` variable. Templates are mapped to the corresponding view folder in `src/View/`. `.css`, `.js` and other style files like `.ttf` or `.woff2` for fonts should be placed in `public/theme/` and accessed accordingly. See an example in `src/View/material/layout/header.twig`. \ No newline at end of file +#### 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/`. `.css`, `.js` and other style files like `.ttf` or `.woff2` for fonts should be placed in `public/theme/` and accessed accordingly. See an example in `src/View/boostrap4/layout.twig`. \ No newline at end of file diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index 76ae531..7d59e6e 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -25,9 +25,13 @@ services: - network web: container_name: teamspeak_web - image: ts3web:latest + image: teamspeak_web:latest + volumes: + - ./env:/var/www/html/application/config/env ports: - 8181:80 + depends_on: + - app restart: always networks: - network \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 9d97ca7..8ce1622 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,25 +1,26 @@ FROM phpearth/php:7.3-nginx # install deps -RUN apk add --no-cache git -RUN apk add --no-cache composer +RUN apk add --no-cache git \ + && 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 +COPY config/ /var/www/html/application/config/ +COPY data/ /var/www/html/application/data/ +COPY public/ /var/www/html/application/public/ +COPY src/ /var/www/html/application/src/ +COPY composer.json /var/www/html/application/composer.json +RUN mkdir -p /var/www/html/application/bin/ \ + && mkdir -p /var/www/html/application/cache/ \ + && chmod -R 777 /var/www/html/application/data/ \ + && mkdir -p /var/www/html/application/log/ \ + && touch /var/www/html/application/log/application.log \ + && chmod 777 /var/www/html/application/log/application.log # initialize app -RUN cd /var/www/html/ts3web/ && composer install \ No newline at end of file +RUN cd /var/www/html/application/ \ + && composer install \ No newline at end of file diff --git a/docker/default.conf b/docker/default.conf index f0d581b..4a3c772 100644 --- a/docker/default.conf +++ b/docker/default.conf @@ -2,7 +2,7 @@ server { listen 80 default_server; - root /var/www/html/ts3web/public; + root /var/www/html/application/public; index index.html index.htm index.php;