Skip to content

Commit

Permalink
Inital commit
Browse files Browse the repository at this point in the history
  • Loading branch information
foorschtbar committed Aug 19, 2020
0 parents commit 0affa5d
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
settings.env
docker-compose.yml

#database
/data/db/*
!/data/db/.gitkeep

#telegram
/data/telegram/*
!/data/telegram/Dockerfile
84 changes: 84 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# strichliste-docker - A Strichliste Docker Container

This is a docker container for the [strichliste](https://www.strichliste.org/) using the [strichliste frontend and backend bundle](https://github.com/strichliste/strichliste), a MariaDB database and a the Telegram Bot [strichliste-telegram](https://github.com/Westwoodlabs/strichliste-telegram).

## Usage

- Clone this repository.
- Create settings.env from template and change values.
- Create docker-compose.yml from template and change for your needs (remove treafik for example).
- Setup initial database.

### Setup initial database
After configuring the environment variables you can start the container and create the inital database schema with the following command:
```
./../bin/console doctrine:schema:create
```
(you might need to wait a bit for the database to start up, the command will tell you if it succeeded or not)

## Templates
Example settings.env configuration:

```env
DB_HOST=db
MYSQL_ROOT_PASSWORD=
MYSQL_DATABASE=strichliste
MYSQL_USER=strichliste
MYSQL_PASSWORD=
DATABASE_URL=mysql://strichliste:<changeme>@db/strichliste
```

Example docker-compose configuration:

```yml
version: "3.8"

services:

web:
build: ./data/web
env_file:
- settings.env
networks:
- reverse-proxy
- internal
volumes:
- ./data/web/services.yaml:/var/www/html/config/services.yaml
- ./data/web/strichliste.yaml:/var/www/html/config/strichliste.yaml
- ./data/web/doctrine.yaml:/var/www/html/config/packages/doctrine.yaml
labels:
- "traefik.enable=true"
- "traefik.http.routers.strichliste.rule=Host(`myhostname.fqdn.local`)"
- "traefik.http.routers.strichliste.entryPoints=https"
- "traefik.http.routers.strichliste.tls=true"
- "traefik.http.services.strichliste.loadbalancer.server.scheme=http"
- "traefik.http.services.strichliste.loadbalancer.server.port=80"
restart: unless-stopped
depends_on:
- db
db:
image: mariadb
restart: unless-stopped
env_file:
- settings.env
volumes:
- ./data/db:/var/lib/mysql
networks:
- internal

telegram:
build: ./data/telegram
restart: unless-stopped
volumes:
- ./data/telegram/authorizedUsers.json:/usr/src/app/authorizedUsers.json
- ./data/telegram/config.py:/usr/src/app/config.py
networks:
- internal

networks:
reverse-proxy:
external: true
internal:
external: false
```
Empty file added data/db/.gitkeep
Empty file.
23 changes: 23 additions & 0 deletions data/telegram/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#download StrichlisteTelegramBridge with git clone
FROM alpine:3.8 as release

RUN apk --no-cache add ca-certificates \
&& apk --no-cache add \
git

RUN mkdir /source

WORKDIR /source

RUN git clone --depth=1 https://github.com/Westwoodlabs/strichliste-telegram.git .

# build StrichlisteTelegramBridge container
FROM python:3

COPY --from=release /source /usr/src/app

WORKDIR /usr/src/app

RUN pip install --no-cache-dir -r /usr/src/app/requirements.txt

CMD [ "python", "./bot.py" ]
23 changes: 23 additions & 0 deletions data/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM alpine:3.8 as release

RUN apk --no-cache add ca-certificates \
&& apk --no-cache add \
curl \
tar

RUN mkdir /source
WORKDIR /source
RUN curl -Lo strichliste.tar.gz https://github.com/strichliste/strichliste/releases/download/v1.7.1/strichliste.tar.gz
RUN tar -xf strichliste.tar.gz
RUN rm -r strichliste.tar.gz

FROM php:7.3-apache

RUN docker-php-ext-install pdo_mysql

COPY --from=release /source /var/www/html

RUN chown -R www-data:www-data /var/www/html

# configure apache
COPY ./apache.conf /etc/apache2/sites-available/000-default.conf
32 changes: 32 additions & 0 deletions data/web/apache.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
User www-data
Group www-data

<VirtualHost *:80>
ServerName strichliste

DocumentRoot /var/www/html/public
<Directory /var/www/html/public>
AllowOverride All
Order Allow,Deny
Allow from All

FallbackResource /index.php
</Directory>

# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
<Directory /var/www/project>
Options FollowSymlinks
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# Change log to works better behind a reverse proxy
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
ErrorLog ${APACHE_LOG_DIR}/error.log
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
CustomLog ${APACHE_LOG_DIR}/access.log combined env=!forwarded
CustomLog ${APACHE_LOG_DIR}/access.log proxy env=forwarded
</VirtualHost>
33 changes: 33 additions & 0 deletions data/web/doctrine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
env(DATABASE_URL): ''

doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci

url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
dql:
datetime_functions:
date: App\Doctrine\Functions\Date
iif: App\Doctrine\Functions\Iif
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
34 changes: 34 additions & 0 deletions data/web/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.

imports:
- { resource: 'strichliste.yaml' }

# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
webroot: '%kernel.project_dir%/public'

services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
public: false # Allows optimizing the container by removing unused services; this also means
# fetching services directly from the container via $container->get() won't work.
# The best practice is to be explicit about your dependencies anyway.

# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: '../src/*'
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'

# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']

# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
71 changes: 71 additions & 0 deletions data/web/strichliste.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
parameters:
strichliste:

article:
enabled: true
autoOpen: true

common:
idleTimeout: 30000 # Time in ms

paypal:
enabled: false
recipient: "[email protected]"
fee: 0

user:
# See http://de.php.net/manual/en/datetime.formats.relative.php
stalePeriod: '14 day'

i18n:
dateFormat: 'YYYY-MM-DD HH:mm:ss'
timezone: 'auto'
language: 'en'
currency:
name: 'Euro'
symbol: ''
alpha3: 'EUR'

account:
boundary:
upper: 20000
lower: -2000

# Be aware: All amounts are in cents!
payment:
undo:
enabled: true
delete: false
timeout: '20 sec' # See http://de.php.net/manual/en/datetime.formats.relative.php

boundary:
upper: 15000
lower: -2000

transactions:
enabled: true

splitInvoice:
enabled: true

deposit:
enabled: true
custom: true
steps:
- 50
- 100
- 200
- 500
- 1000
- 2000

dispense:
enabled: true
custom: true
steps:
- 50
- 100
- 200
- 500
- 1000
- 2000

0 comments on commit 0affa5d

Please sign in to comment.