Moved Docker related files into the docker directory.

This commit is contained in:
alext 2018-11-03 15:15:20 +01:00
parent 515b6b4c46
commit b33474761e
11 changed files with 94 additions and 90 deletions

19
.env
View File

@ -1,19 +0,0 @@
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

2
.gitignore vendored
View File

@ -5,6 +5,8 @@
/doc/apigen/html
/doc/jsdoc/html
/doc/plato/html
/docker/.env*
!/docker/.env.example
/node_modules/
/npm-debug.log
/src/config.php

View File

@ -1,8 +1,10 @@
# Docker
Run the development containers of Easy!Appointments with Docker and Docker Compose utility. Docker allows you to compose your application from microservices, without worrying about inconsistencies between development and production environments and without locking into any platform or language.
Run the development containers of Easy!Appointments with Docker and Docker Compose utility. Docker allows you to compose your application from micro-services, without worrying about inconsistencies between development and production environments and without locking into any platform or language.
Make sure that you have Docker and Docker compose installed and configured in your system and execute the following command through your terminal while being in the Git clone directory:
Copy the `.env.example` file to `.env` inside the `docker` directory and set the desired environment variables.
Make sure that you have Docker and Docker Compose installed and configured in your system and execute the following command through your terminal while being in `docker` directory of your Git clone:
`docker-compose up`
@ -22,10 +24,10 @@ class Config {
// DATABASE SETTINGS
// ------------------------------------------------------------------------
const DB_HOST = 'database';
const DB_HOST = 'database:3306';
const DB_NAME = 'easyappointments';
const DB_USERNAME = 'root';
const DB_PASSWORD = 'root';
const DB_USERNAME = 'easyappointments';
const DB_PASSWORD = 'easyappointments';
// ------------------------------------------------------------------------
// GOOGLE CALENDAR SYNC

View File

@ -1,31 +0,0 @@
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,27 +0,0 @@
version: '2'
services:
database:
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=veryhardpassword
- MYSQL_DATABASE=easyapp
- MYSQL_USER=easyapp
- MYSQL_PASSWORD=veryhardpassword
application:
image: easyappointments
build:
context: .
volumes:
- ./src:/var/www/html
command: dev
ports:
- ${APP_HOST}:80:80
environment:
- DB_HOST=database:3306
- APP_URL=localhost
depends_on:
- database
env_file:
- .env
restart: always

17
docker/.env.example Normal file
View File

@ -0,0 +1,17 @@
# Before deploying to production change to harder password, and don't commit it to git.
DB_USERNAME=easyappointments
DB_NAME=easyappointments
DB_PASSWORD=easyappointments
# 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

@ -6,11 +6,11 @@ ENV PROJECT_DIR=/var/www/html \
RUN docker-php-ext-install mysqli gettext
COPY ./src $PROJECT_DIR
COPY docker-entrypoint.sh /entrypoint.sh
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN sed -i 's/\r//' /entrypoint.sh
RUN sed -i 's/\r//' /docker-entrypoint.sh
VOLUME $PROJECT_DIR/storage
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
ENTRYPOINT ["/bin/bash", "/docker-entrypoint.sh"]
CMD ["run"]

View File

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

27
docker/docker-compose.yml Normal file
View File

@ -0,0 +1,27 @@
version: '2'
services:
database:
image: mysql
environment:
- MYSQL_DATABASE=${DB_NAME}
- MYSQL_USER=${DB_USERNAME}
- MYSQL_PASSWORD=${DB_PASSWORD}
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
application:
image: easyappointments
build:
context: .
volumes:
- ../src:/var/www/html
command: dev
ports:
- ${APP_HOST}:80:80
environment:
- DB_HOST=database:3306
- APP_URL=localhost
depends_on:
- database
env_file:
- .env
restart: always

View File

@ -20,7 +20,6 @@ createAppSettings() {
chown -R www-data $PROJECT_DIR
}
if [ "$1" = "run" ]; then
echo "Preparing Easy!Appointments production configuration.."
@ -35,7 +34,6 @@ 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

View File

@ -47,20 +47,25 @@ You can also report problems on the [issues page](https://github.com/alextselegi
and help the development progress.
### Docker
To start Easy!Appointments using Docker in development configuration, with source files mounted into container, run:
To start Easy!Appointments using Docker in development configuration, with source files mounted into container, copy the `docker/.env.example` file to `docker/.env` and run:
```
docker-compose up
```
inside the `docker` directory.
**Important: once the containers are set up, the `src/config.php` file will be overwritten. In some host environments you might need to manually change the BASE_URL value, if Docker cannot map the container to `http://localhost`.
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`.
Database data will be stored in named volume `easyappointments_easyappointments-data`, and app storage (logs, cache, uploads) in `easyappointments_easyappointments-storage`.
To find where exactly they are stored, you can run
```
docker volume inspect easyappointments_easy-appointments-storage
docker volume inspect easyappointments_easyappointments-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.