Merge branch 'develop' of https://github.com/Valian/easyappointments into Valian-develop

This commit is contained in:
alext 2017-05-23 15:10:49 +02:00
commit 8e3cbd67cb
6 changed files with 155 additions and 26 deletions

19
.env Normal file
View file

@ -0,0 +1,19 @@
DB_USERNAME=easyapp
DB_NAME=easyapp
# before deploying to production change to harder password, and don't commit it to git
DB_PASSWORD=veryhardpassword
# change to your installation address
APP_URL=localhost
APP_HOST=0.0.0.0
APP_PORT=80
# email settings - set to 'smtp' and provide SMTP settings if you want to send emails
EMAIL_PROTOCOL=mail
SMTP_HOST=smtp.gmail.com
SMTP_USER=user
SMTP_PASS=password
SMTP_CRYPTO=ssl
SMTP_PORT=25

View file

@ -1,5 +1,14 @@
FROM tutum/apache-php FROM php:7.0-apache
MAINTAINER Alex Tselegidis <alextselegidis@gmail.com> ENV PROJECT_DIR=/var/www/html \
APP_URL=localhost
EXPOSE 80 RUN docker-php-ext-install mysqli gettext
COPY ./src $PROJECT_DIR
COPY docker-entrypoint.sh /entrypoint.sh
VOLUME $PROJECT_DIR/storage
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
CMD ["run"]

View file

@ -43,6 +43,25 @@ If you have problems installing or configuring the application take a look on th
You can also report problems on the [issues page](https://github.com/alextselegidis/easyappointments/issues) You can also report problems on the [issues page](https://github.com/alextselegidis/easyappointments/issues)
and help the development progress. and help the development progress.
### Docker
To start Easy!Appointments using Docker in development configuration, with source files mounted into container, run:
```
docker-compose up
```
Production deployment can be made by changing required values in .env file (DB_PASSWORD, APP_URL, APP_PORT) and running:
```
docker-compose -f docker-compose.prod.yml up -d
```
Database data will be stored in named volume `easyappointments_easy-appointments-data`, and app storage (logs, cache, uploads) in `easyappointments_easy-appointments-storage`.
To find where exactly they are stored, you can run
```
docker volume inspect easyappointments_easy-appointments-storage
```
Production containers will automatically be restarted in case of crash / server reboot. For more info, take a look into `docker-compose.prod.yml` file.
### User Feedback ### User Feedback
Whether it is new ideas or defects, your feedback is highly appreciated and will be taken into Whether it is new ideas or defects, your feedback is highly appreciated and will be taken into
consideration for the following releases of the project. Share your experience and discuss your consideration for the following releases of the project. Share your experience and discuss your

31
docker-compose.prod.yml Normal file
View file

@ -0,0 +1,31 @@
version: '2'
services:
database:
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
- MYSQL_DATABASE=${DB_NAME}
- MYSQL_USER=${DB_USERNAME}
- MYSQL_PASSWORD=${DB_PASSWORD}
volumes:
- easy-appointments-data:/var/lib/mysql
restart: always
application:
image: easyappointments
build:
context: .
ports:
- 80:80
environment:
- DB_HOST=database:3306
env_file:
- .env
volumes:
- easy-appointments-storage:/var/www/html/src/storage
restart: always
volumes:
easy-appointments-data:
easy-appointments-storage:

View file

@ -1,23 +1,27 @@
storage: version: '2'
image: 'busybox:latest' services:
volumes: database:
- /var/lib/mysql image: mysql
- ./src:/app environment:
command: sleep 3153600000 - MYSQL_ROOT_PASSWORD=veryhardpassword
database: - MYSQL_DATABASE=easyapp
image: mysql:5.7 - MYSQL_USER=easyapp
environment: - MYSQL_PASSWORD=veryhardpassword
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: easyappointments application:
volumes_from: image: easyappointments
- storage build:
restart: always context: .
mem_limit: 200m volumes:
app: - ./src:/var/www/html
build: ./ command: dev
ports: ports:
- 80:80 - ${APP_HOST}:80:80
links: environment:
- database:database - DB_HOST=database:3306
volumes_from: - APP_URL=localhost
- storage depends_on:
- database
env_file:
- .env
restart: always

47
docker-entrypoint.sh Normal file
View file

@ -0,0 +1,47 @@
#!/usr/bin/env sh
createAppSettings() {
cp $PROJECT_DIR/config-sample.php $PROJECT_DIR/config.php
sed -i "s/DB_HOST = ''/DB_HOST = '$DB_HOST'/g" $PROJECT_DIR/config.php
sed -i "s/DB_USERNAME = ''/DB_USERNAME = '$DB_USERNAME'/g" $PROJECT_DIR/config.php
sed -i "s/DB_PASSWORD = ''/DB_PASSWORD = '$DB_PASSWORD'/g" $PROJECT_DIR/config.php
sed -i "s/DB_NAME = ''/DB_NAME = '$DB_NAME'/g" $PROJECT_DIR/config.php
if [ "$EMAIL_PROTOCOL" = "smtp" ]; then
echo "Setting up email..."
sed -i "s/\$config\['protocol'\] = 'mail'/\$config['protocol'] = 'smtp'/g" $PROJECT_DIR/application/config/email.php
sed -i "s#// \$config\['smtp_host'\] = ''#\$config['smtp_host'] = '$SMTP_HOST'#g" $PROJECT_DIR/application/config/email.php
sed -i "s#// \$config\['smtp_user'\] = ''#\$config['smtp_user'] = '$SMTP_USER'#g" $PROJECT_DIR/application/config/email.php
sed -i "s#// \$config\['smtp_pass'\] = ''#\$config['smtp_pass'] = '$SMTP_PASS'#g" $PROJECT_DIR/application/config/email.php
sed -i "s#// \$config\['smtp_crypto'\] = 'ssl'#\$config['smtp_crypto'] = '$SMTP_CRYPTO'#g" $PROJECT_DIR/application/config/email.php
sed -i "s#// \$config\['smtp_port'\] = 25#\$config['smtp_port'] = $SMTP_PORT#g" $PROJECT_DIR/application/config/email.php
fi
sed -i "s/url-to-easyappointments-directory/$APP_URL/g" $PROJECT_DIR/config.php
chown -R www-data $PROJECT_DIR
}
if [ "$1" = "run" ]; then
echo "Preparing Easy!Appointments production configuration.."
createAppSettings
echo "Starting Easy!Appointments production server.."
exec docker-php-entrypoint apache2-foreground
elif [ "$1" = "dev" ]; then
echo "Preparing Easy!Appointments development configuration.."
createAppSettings
sed -i "s/DEBUG_MODE = FALSE/DEBUG_MODE = TRUE/g" $PROJECT_DIR/config.php
echo "Starting Easy!Appointments production server.."
exec docker-php-entrypoint apache2-foreground
fi
exec $@