Icehrm docker worker and readme

This commit is contained in:
Thilina Pituwala
2020-05-25 04:12:35 +02:00
parent 0f7530024e
commit a2ca93db83
13 changed files with 125 additions and 41 deletions

View File

@@ -21,7 +21,7 @@ RUN apk --no-cache add bind-tools
# Install packages # Install packages
RUN apk --no-cache add php php-fpm php-opcache php-mysqli php-json php-openssl php-curl \ RUN apk --no-cache add php php-fpm php-opcache php-mysqli php-json php-openssl php-curl \
php-zlib php-xml php-phar php-intl php-dom php-xmlreader php-ctype php-session \ php-zlib php-xml php-phar php-intl php-dom php-xmlreader php-ctype php-session \
php-mbstring php-gd nginx supervisor curl php-mbstring php-gd php7-ldap nginx supervisor curl
# Install xdebug # Install xdebug
RUN apk add --no-cache $PHPIZE_DEPS \ RUN apk add --no-cache $PHPIZE_DEPS \

View File

@@ -5,7 +5,7 @@ LABEL Maintainer="Thilina, Pituwala <thilina@icehrm.com>" \
# Install packages # Install packages
RUN apk --no-cache add php7 php7-fpm php7-opcache php7-mysqli php7-json php7-openssl php7-curl \ RUN apk --no-cache add php7 php7-fpm php7-opcache php7-mysqli php7-json php7-openssl php7-curl \
php7-zlib php7-xml php7-phar php7-intl php7-dom php7-xmlreader php7-ctype php7-session \ php7-zlib php7-xml php7-phar php7-intl php7-dom php7-xmlreader php7-ctype php7-session \
php7-mbstring php7-gd nginx supervisor curl php7-mbstring php7-gd php7-ldap nginx supervisor curl
# Configure nginx # Configure nginx
COPY docker/prod/config/nginx.conf /etc/nginx/nginx.conf COPY docker/prod/config/nginx.conf /etc/nginx/nginx.conf

View File

@@ -5,7 +5,7 @@ LABEL Maintainer="Thilina, Pituwala <thilina@icehrm.com>" \
# Install packages # Install packages
RUN apk --no-cache add php7 php7-fpm php7-opcache php7-mysqli php7-json php7-openssl php7-curl \ RUN apk --no-cache add php7 php7-fpm php7-opcache php7-mysqli php7-json php7-openssl php7-curl \
php7-zlib php7-xml php7-phar php7-intl php7-dom php7-xmlreader php7-ctype php7-session \ php7-zlib php7-xml php7-phar php7-intl php7-dom php7-xmlreader php7-ctype php7-session \
php7-mbstring php7-gd nginx supervisor curl php7-mbstring php7-gd php7-ldap nginx supervisor curl
# Configure nginx # Configure nginx
COPY docker/testing/config/nginx.conf /etc/nginx/nginx.conf COPY docker/testing/config/nginx.conf /etc/nginx/nginx.conf

32
Dockerfile-worker Normal file
View File

@@ -0,0 +1,32 @@
FROM alpine:3.11
LABEL Maintainer="Thilina, Pituwala <thilina@icehrm.com>" \
Description="IceHrm Docker Container with Nginx 1.16 & PHP-FPM 7.3 based on Alpine Linux."
ARG EXE_ENV
RUN apk upgrade --available
RUN apk add --no-cache tini openrc busybox-initscripts
# Install packages
RUN apk --no-cache add php7 php7-opcache php7-mysqli php7-json php7-openssl php7-curl \
php7-zlib php7-xml php7-phar php7-intl php7-dom php7-xmlreader php7-ctype php7-session \
php7-mbstring php7-gd curl
# Setup document root
RUN mkdir -p /var/www/html
# Add application
WORKDIR /var/www/html
COPY ./app /var/www/html/app/
COPY ./core /var/www/html/core/
COPY ./web /var/www/html/web/
COPY ./index.php /var/www/html/index.php
COPY ./docker/$EXE_ENV/config/config.php /var/www/html/app/config.php
COPY ./docker/worker/config/ice-cron /etc/crontabs/root
RUN rm /var/www/html/app/data/icehrm.log
CMD /usr/sbin/crond -f -l 8

View File

@@ -22,10 +22,15 @@ class LogManager
if (empty(self::$me)) { if (empty(self::$me)) {
self::$me = new LogManager(); self::$me = new LogManager();
self::$me->log = new Logger(APP_NAME); self::$me->log = new Logger(APP_NAME);
if (is_writable(ini_get('error_log'))) {
if (defined('LOG_STDERR') && LOG_STDERR === '1') {
self::$me->log->pushHandler(new StreamHandler('php://stderr', LOG_LEVEL));
} else if (is_writable(ini_get('error_log'))) {
self::$me->log->pushHandler(new StreamHandler(ini_get('error_log'), LOG_LEVEL)); self::$me->log->pushHandler(new StreamHandler(ini_get('error_log'), LOG_LEVEL));
} elseif (is_writable(CLIENT_BASE_PATH.'data/app.log')) { } elseif (is_writable(CLIENT_BASE_PATH.'data/app.log')) {
self::$me->log->pushHandler(new StreamHandler(CLIENT_BASE_PATH.'data/app.log', LOG_LEVEL)); self::$me->log->pushHandler(new StreamHandler(CLIENT_BASE_PATH.'data/app.log', LOG_LEVEL));
} else {
self::$me->log->pushHandler(new StreamHandler('php://stderr', LOG_LEVEL));
} }
} }
return self::$me; return self::$me;

View File

@@ -21,6 +21,13 @@ services:
- 8070:8070 - 8070:8070
volumes: volumes:
- ./docker/prod/app_data:/var/www/html/app/data - ./docker/prod/app_data:/var/www/html/app/data
icehrm-worker:
build:
context: ./
dockerfile: Dockerfile-worker
args:
- EXE_ENV=prod
volumes: volumes:
db_data: db_data:
app_data: app_data:

View File

@@ -19,5 +19,12 @@ services:
- 8080:8080 - 8080:8080
volumes: volumes:
- .:/var/www/html - .:/var/www/html
icehrm-worker-dev:
build:
context: ./
dockerfile: Dockerfile-worker
args:
- EXE_ENV=development
volumes: volumes:
db_data: db_data:

View File

@@ -1,5 +1,5 @@
<?php <?php
ini_set('error_log', 'data/icehrm.log'); ini_set('error_log', '/var/www/html/app/data/icehrm.log');
define('CLIENT_NAME', 'icehrm'); define('CLIENT_NAME', 'icehrm');
define('APP_BASE_PATH', '/var/www/html/core/'); define('APP_BASE_PATH', '/var/www/html/core/');
@@ -16,3 +16,5 @@ define('APP_CON_STR', 'mysqli://'.APP_USERNAME.':'.APP_PASSWORD.'@'.APP_HOST.'/'
//file upload //file upload
define('FILE_TYPES', 'jpg,png,jpeg'); define('FILE_TYPES', 'jpg,png,jpeg');
define('MAX_FILE_SIZE_KB', 10 * 1024); define('MAX_FILE_SIZE_KB', 10 * 1024);
define('LOG_STDERR', '1');

View File

@@ -1,5 +1,5 @@
<?php <?php
ini_set('error_log', 'data/icehrm.log'); ini_set('error_log', '/var/www/html/app/data/icehrm.log');
define('CLIENT_NAME', 'icehrm'); define('CLIENT_NAME', 'icehrm');
define('APP_BASE_PATH', '/var/www/html/core/'); define('APP_BASE_PATH', '/var/www/html/core/');
@@ -16,3 +16,5 @@ define('APP_CON_STR', 'mysqli://'.APP_USERNAME.':'.APP_PASSWORD.'@'.APP_HOST.'/'
//file upload //file upload
define('FILE_TYPES', 'jpg,png,jpeg'); define('FILE_TYPES', 'jpg,png,jpeg');
define('MAX_FILE_SIZE_KB', 10 * 1024); define('MAX_FILE_SIZE_KB', 10 * 1024);
define('LOG_STDERR', '1');

View File

@@ -1,5 +1,5 @@
<?php <?php
ini_set('error_log', 'data/icehrm.log'); ini_set('error_log', '/var/www/html/app/data/icehrm.log');
define('CLIENT_NAME', 'icehrm'); define('CLIENT_NAME', 'icehrm');
define('APP_BASE_PATH', '/var/www/html/core/'); define('APP_BASE_PATH', '/var/www/html/core/');
@@ -16,3 +16,5 @@ define('APP_CON_STR', 'mysqli://'.APP_USERNAME.':'.APP_PASSWORD.'@'.APP_HOST.'/'
//file upload //file upload
define('FILE_TYPES', 'jpg,png,jpeg'); define('FILE_TYPES', 'jpg,png,jpeg');
define('MAX_FILE_SIZE_KB', 10 * 1024); define('MAX_FILE_SIZE_KB', 10 * 1024);
define('LOG_STDERR', '1');

View File

@@ -0,0 +1 @@
* * * * * php /var/www/html/app/cron.php

View File

@@ -0,0 +1,2 @@
[Date]
date.timezone="UTC"

View File

@@ -10,6 +10,31 @@ properly.
- [IceHrm Demo](https://icehrm.com/icehrm-demo) - [IceHrm Demo](https://icehrm.com/icehrm-demo)
- Feature rich version of IceHrm (IceHrmPro) is available at [https://icehrm.com/purchase-icehrmpro](https://icehrm.com/purchase-icehrmpro) - Feature rich version of IceHrm (IceHrmPro) is available at [https://icehrm.com/purchase-icehrmpro](https://icehrm.com/purchase-icehrmpro)
Getting started
---------------
The easiest way to run IceHrm is using docker
- Install docker on Mac, Windows or Linux [https://docs.docker.com/get-docker/](https://docs.docker.com/get-docker/)
For Linux you need to install docker compose separately here [https://docs.docker.com/compose/install/](https://docs.docker.com/compose/install/)
```
$ git clone https://github.com/gamonoid/icehrm.git
$ cd icehrm
$ docker-compose -f docker-compose-prod.yaml up -d
```
- Visit [http://localhost:8070/](http://localhost:8070/) to load icehrm, that's it
You can find database and app data under `icehrm/docker/production`
When you want to kill the docker containers
```
docker-compose -f docker-compose-prod.yaml down
```
IceHrm Mobile App (Beta) IceHrm Mobile App (Beta)
------------------------ ------------------------
@@ -37,8 +62,8 @@ Useful Links
* Community Support: [http://stackoverflow.com/search?q=icehrm](http://stackoverflow.com/search?q=icehrm) * Community Support: [http://stackoverflow.com/search?q=icehrm](http://stackoverflow.com/search?q=icehrm)
* IceHrm Opensource Blog: [http://icehrm.org](http://icehrm.org) * IceHrm Opensource Blog: [http://icehrm.org](http://icehrm.org)
Installation Installation without Docker
------------ ---------------------------
* Download the latest release https://github.com/gamonoid/icehrm/releases/latest * Download the latest release https://github.com/gamonoid/icehrm/releases/latest
* Copy the downloaded file to the path you want to install iCE Hrm in your server and extract. * Copy the downloaded file to the path you want to install iCE Hrm in your server and extract.
@@ -66,57 +91,56 @@ Refer: [http://blog.icehrm.com/docs/upgrade/](http://blog.icehrm.com/docs/upgrad
Setup IceHrm Development Environment Setup IceHrm Development Environment
------------------------------------ ------------------------------------
IceHrm development environment is packaged as a Vagrant box. I includes php7, nginx, phpunit and other IceHrm uses docker to setup development environment
software required for running icehrm
Preparing development VM with Vagrant
-------------------------------------
- Clone icehrm from https://github.com/gamonoid/icehrm.git or download the source - Clone icehrm from https://github.com/gamonoid/icehrm.git or download the source
- Install Vagrant [https://www.vagrantup.com/downloads.html](https://www.vagrantup.com/downloads.html)
- Run vagrant up in icehrm root directory (this will download icehrm vagrant image which is ~1 GB)
``` ```
~ $ vagrant up $ git clone https://github.com/gamonoid/icehrm.git
$ cd icehrm
$ docker-compose up
``` ```
- Run vagrant ssh to login to the Virtual machine - Load icehrm Development preview
``` ```
~ $ vagrant ssh http://localhost:8080
``` ```
- Add following entries to the end of the host file to map icehrm domains to VagrantBox (on MacOS and Linux this is /etc/hosts | on windows this is Windows\System32\Drivers\etc\hosts) - Make some changes and the changes will be reflected on the above url
- Run e2e (cypress) tests
``` ```
192.168.40.40 app.icehrm-open.test docker-compose -f docker-compose-testing.yaml up --exit-code-from cypress
192.168.40.40 clients.icehrm-open.test ```
- When you are ready to push your changes to production, make sure to build the production images
```
$ docker-compose -f docker-compose-prod.yaml up -d --build
``` ```
- Navigate to [http://clients.icehrm-open.test/dev](http://clients.icehrm-open.test/dev) to load icehrm from VM. (user:admin/pass:admin) - Navigate to [http://clients.icehrm-open.test/dev](http://clients.icehrm-open.test/dev) to load icehrm from VM. (user:admin/pass:admin)
### Notes to Developers ### Building frontend assets
- When ever you have done a change to JavaScript or CSS files in icehrm/web rebuild the frontend - When ever you have done a change to JavaScript or CSS files in icehrm/web you need to rebuild the frontend
- First make sure you have all the dependencies (just doing this once is enough)
``` ```
~ $ cd /vagrant $ cd icehrm/web
~ $ gulp $ npm install
$ cd ..
$ npm install
``` ```
- Then run gulp
```
$ gulp
```
### Docker Setup - If you have only changed an admin module and you know which module it is
```
docker run -it -v $PWD:/e2e -w /e2e cypress/included:3.2.0 $ gulp admin-js --memployees
```
vagrant ssh -c 'cd /vagrant/core/robo; php robo.phar reset:db test; php robo.phar create:tables test; php robo.phar migrate:all test; php robo.phar execute:fixtures test'
docker-compose up --build
docker-compose -f docker-compose-testing.yaml up
docker-compose -f docker-compose-testing.yaml up --exit-code-from cypress