├── .env ├── .github └── pull_request_template.md ├── .gitignore ├── Dockerfile ├── Dockerfile.base ├── README.md ├── build-files ├── init.sh ├── laravel-cron ├── laravel-echo-server.json ├── nginx.conf └── services.conf └── docker-compose.yml /.env: -------------------------------------------------------------------------------- 1 | PM_VERSION=4.1.21 2 | PM_APP_URL=http://localhost 3 | PM_APP_PORT=8080 4 | PM_BROADCASTER_PORT=6004 5 | PM_DOCKER_SOCK=/var/run/docker.sock 6 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Issue & Reproduction Steps 2 | 3 | Expected behavior: 4 | 5 | Actual behavior: 6 | 7 | ## Solution 8 | - 9 | 10 | ## How to Test 11 | Test the steps above 12 | 13 | ## Related Tickets & Packages 14 | - 15 | 16 | ## Code Review Checklist 17 | - [ ] I have pulled this code locally and tested it on my instance, along with any associated packages. 18 | - [ ] This code adheres to [ProcessMaker Coding Guidelines](https://github.com/ProcessMaker/processmaker/wiki/Coding-Guidelines). 19 | - [ ] This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test. 20 | - [ ] This solution fixes the bug reported in the original ticket. 21 | - [ ] This solution does not alter the expected output of a component in a way that would break existing Processes. 22 | - [ ] This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail. 23 | - [ ] This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages. 24 | - [ ] This code does not duplicate functionality that already exists in the framework or in ProcessMaker. 25 | - [ ] This ticket conforms to the PRD associated with this part of ProcessMaker. 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bind-mount/composer/cache 2 | bind-mount/npm -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM processmaker/pm4-base:1.0.0 2 | 3 | ARG PM_VERSION 4 | 5 | WORKDIR /tmp 6 | RUN wget https://github.com/ProcessMaker/processmaker/archive/refs/tags/v${PM_VERSION}.zip 7 | RUN unzip v${PM_VERSION}.zip && rm -rf /code/pm4 && mv processmaker-${PM_VERSION} /code/pm4 8 | 9 | WORKDIR /code/pm4 10 | RUN composer install 11 | COPY build-files/laravel-echo-server.json . 12 | RUN npm install --unsafe-perm=true && npm run dev 13 | 14 | COPY build-files/laravel-echo-server.json . 15 | COPY build-files/init.sh . 16 | CMD bash init.sh && supervisord --nodaemon 17 | -------------------------------------------------------------------------------- /Dockerfile.base: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | ENV DEBIAN_FRONTEND=noninteractive 3 | ENV TZ="America/Los_Angeles" 4 | 5 | RUN apt update 6 | 7 | # In ubuntu 20.04, installing php without specifying a version installs 7.4 :) 8 | RUN apt install -y php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-imagick php-dom php-sqlite3 \ 9 | nginx vim curl unzip wget supervisor cron mysql-client build-essential 10 | 11 | # 12 | # node 13 | # 14 | RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - 15 | RUN apt -y install nodejs 16 | 17 | # 18 | # install composer 19 | # 20 | RUN wget -O composer-setup.php https://getcomposer.org/installer 21 | RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer 22 | RUN composer self-update 23 | 24 | # 25 | # cron 26 | # 27 | COPY build-files/laravel-cron /etc/cron.d/laravel-cron 28 | RUN chmod 0644 /etc/cron.d/laravel-cron && crontab /etc/cron.d/laravel-cron 29 | 30 | # 31 | # docker client 32 | # 33 | ENV DOCKERVERSION=20.10.5 34 | RUN curl -fsSLO https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKERVERSION}.tgz \ 35 | && tar xzvf docker-${DOCKERVERSION}.tgz --strip 1 \ 36 | -C /usr/local/bin docker/docker \ 37 | && rm docker-${DOCKERVERSION}.tgz 38 | 39 | # 40 | # configure php-fpm to run as root 41 | # 42 | RUN sed -i 's/www-data/root/g' /etc/php/7.4/fpm/pool.d/www.conf 43 | 44 | # 45 | # nginx 46 | # 47 | COPY build-files/nginx.conf /etc/nginx/nginx.conf 48 | 49 | # 50 | # supervisord 51 | # 52 | COPY build-files/services.conf /etc/supervisor/conf.d/services.conf 53 | 54 | 55 | RUN mkdir -p /code/pm4 56 | WORKDIR /code/pm4 57 | EXPOSE 80 443 6001 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ProcessMaker 4 Core Docker Instance 2 | 3 | This docker-compose setup allows you to quickly start up an instance of ProcessMaker4 Core to test with. 4 | 5 | This build has no enterprise packages. 6 | 7 | ## Requirements 8 | - Docker Engine >= 3.2 9 | - For Mac and Windows Users, we recommend [Docker Desktop](https://www.docker.com/products/docker-desktop) 10 | - For other installation options: [Install Instructions](https://docs.docker.com/engine/install/) 11 | 12 | - Docker Compose >= 1.2 13 | - If using Docker Desktop, Compose is already included 14 | - For all others: [Install Instructions](https://docs.docker.com/compose/install/) 15 | 16 | ## Running an instance 17 | 18 | 1. Clone or download this repo 19 | 20 | 1. Modify the .env file *(optional)* 21 | 22 | | Variable | Description | 23 | | --- | --- | 24 | | PM_VERSION | The version to install from dockerhub. Must match one of the tags at https://hub.docker.com/r/processmaker/pm4-core/tags or [build it locally](#building-the-application-image-locally)| 25 | | PM_APP_URL | The base URL that's accessible from outside the container. This will usually be `http://localhost` but you can change it if you customize your hosts file and add `extra_hosts` to the docker-compose.yml | 26 | | PM_APP_PORT | Choose a different port if 8080 is in use on your host | 27 | | PM_BROADCASTER_PORT | Choose a different port for the Socket.io server if 6001 is in use on your host | 28 | | PM_DOCKER_SOCK | Location of your docker socket file. See [note](#bind-mounting-the-docker-socket) | 29 | 30 | 1. Run `docker-compose up` 31 | 32 | This will pull the image if it doesn't exist. It's >2 gigabytes so it could take some time. 33 | 34 | If this is the first time running, it will run the install script and seed the database. 35 | This part usually takes a few minutes but if script executor images need to be downloaded and built it will take a few extra minutes. 36 | 37 | The instance should now be available at http://localhost:8080 (or where ever you configured it in the .env file) 38 | 39 | Username: **admin** Password: **admin123** 40 | 41 | `ctrl+c` will gracefully stop all containers but will not remove them so changes will persist. 42 | 43 | If you need a clean environment or made changes to config files, you can reinstall with 44 | ``` 45 | docker-compose down -v 46 | docker-compose up 47 | ``` 48 | 49 | ## Building the application image locally 50 | If you want to build your own version locally, run docker build with PM_VERSION set to a tag at https://github.com/ProcessMaker/processmaker/tags (without the leading 'v') 51 | ``` 52 | docker build --build-arg PM_VERSION=4.1.21-RC7 -t processmaker/pm4-core:local . 53 | ``` 54 | Then change PM_VERSION in .env to `local` 55 | 56 | ## Building the base image locally 57 | The pm4-base image includes all the prerequisites for PM4. It's available at https://hub.docker.com/r/processmaker/pm4-base 58 | 59 | If you need to modify it you can edit Dockerfile.base and build it yourself with 60 | ``` 61 | docker build -t pm4-base:local -f Dockerfile.base . 62 | ``` 63 | After building the base image, change `FROM` at the top of the Dockerfile and rebuild the application image the [above instructions](#building-the-application-image-locally) 64 | 65 | ## Bind-mounting the docker socket 66 | The instance uses the host's docker server by bind-mounting your docker sock file. 67 | This allows for smaller images and better performance than using dind (docker in docker). 68 | See [this post](http://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/) for more info. 69 | The host socket file is usually at /var/run/docker.sock but can be changed in the .env file 70 | 71 | ## Todo 72 | 73 | ### Automated builds pushed to dockerhub 74 | 75 | Currently, the image must be built and pushed to dockerhub manually using the 76 | [instructions above](#building-the-application-image-locally) when a new tag of PM4 77 | is released. 78 | 79 | The goal is to have CircleCI do this automatically 80 | 81 | 82 | ### Use production build 83 | 84 | Currently the image is built using development as the target (e.g. `npm run dev`). Building for production for Node and Composer packages 85 | should greatly reduce the image size and might increase performance. -------------------------------------------------------------------------------- /build-files/init.sh: -------------------------------------------------------------------------------- 1 | set -ex 2 | 3 | # # Wait for mysql to bec available 4 | # while ! mysqladmin ping -u pm -ppass -h mysql --silent; do 5 | # echo "Waiting for mysql" 6 | # sleep 1 7 | # done 8 | 9 | # # Check if database has been initialized 10 | # NUM_TABLES=$(mysql -u pm -p'pass' -h mysql -N -B -e 'show tables;' processmaker | wc -l) 11 | 12 | # if [ $NUM_TABLES -eq 0 ]; then 13 | # mysql -u pm -p'pass' -h mysql processmaker < mysqldump.sql 14 | # fi 15 | 16 | if [ ! -f ".env" ]; then 17 | 18 | while ! mysqladmin ping -u pm -ppass -h mysql --silent; do 19 | echo "Waiting for mysql" 20 | sleep 1 21 | done 22 | 23 | if [ "${PM_APP_PORT}" = "80" ]; then 24 | PORT_WITH_PREFIX="" 25 | else 26 | PORT_WITH_PREFIX=":${PM_APP_PORT}" 27 | fi 28 | 29 | php artisan processmaker:install --no-interaction \ 30 | --url=${PM_APP_URL}${PORT_WITH_PREFIX} \ 31 | --broadcast-host=${PM_APP_URL}:${PM_BROADCASTER_PORT} \ 32 | --username=admin \ 33 | --password=admin123 \ 34 | --email=admin@processmaker.com \ 35 | --first-name=Admin \ 36 | --last-name=User \ 37 | --db-host=mysql \ 38 | --db-port=3306 \ 39 | --db-name=processmaker \ 40 | --db-username=pm \ 41 | --db-password=pass \ 42 | --data-driver=mysql \ 43 | --data-host=mysql \ 44 | --data-port=3306 \ 45 | --data-name=processmaker \ 46 | --data-username=pm \ 47 | --data-password=pass \ 48 | --redis-host=redis 49 | 50 | 51 | echo "PROCESSMAKER_SCRIPTS_DOCKER=/usr/local/bin/docker" >> .env 52 | echo "PROCESSMAKER_SCRIPTS_DOCKER_MODE=copying" >> .env 53 | echo "LARAVEL_ECHO_SERVER_AUTH_HOST=http://localhost" >> .env 54 | echo "SESSION_SECURE_COOKIE=false" >> .env 55 | fi 56 | -------------------------------------------------------------------------------- /build-files/laravel-cron: -------------------------------------------------------------------------------- 1 | * * * * * cd /code/pm4 && php artisan schedule:run >> /dev/null 2>&1 2 | -------------------------------------------------------------------------------- /build-files/laravel-echo-server.json: -------------------------------------------------------------------------------- 1 | { 2 | "devMode": true, 3 | "authEndpoint": "/broadcasting/auth", 4 | "clients": [ 5 | { 6 | "appId": "0fd1f7a0ce0d527c", 7 | "key": "21a795019957dde6bcd96142e05d4b10" 8 | } 9 | ], 10 | "database": "redis", 11 | "databaseConfig": { 12 | "redis": { 13 | "host": "redis" 14 | }, 15 | "sqlite": { 16 | "databasePath": "/database/laravel-echo-server.sqlite" 17 | } 18 | }, 19 | "protocol": "http", 20 | "socketio": {}, 21 | "subscribers": { 22 | "http": true, 23 | "redis": true 24 | }, 25 | "apiOriginAllow": { 26 | "allowCors": false, 27 | "allowOrigin": "", 28 | "allowMethods": "", 29 | "allowHeaders": "" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /build-files/nginx.conf: -------------------------------------------------------------------------------- 1 | daemon off; 2 | user root root; 3 | 4 | worker_processes 1; 5 | # error_log /var/log/nginx/error.log info; 6 | error_log /dev/stderr info; 7 | events { 8 | worker_connections 1024; 9 | } 10 | 11 | http { 12 | # access_log /var/log/nginx/access.log; 13 | access_log /dev/stdout; 14 | include mime.types; 15 | default_type application/octet-stream; 16 | 17 | sendfile on; 18 | keepalive_timeout 65; 19 | 20 | server { 21 | listen 0.0.0.0; 22 | server_name localhost; 23 | root /code/pm4/public; 24 | 25 | index index.php index.html index.htm; 26 | location / { 27 | try_files $uri $uri/ /index.php$is_args$args; 28 | } 29 | error_page 500 502 503 504 /50x.html; 30 | location = /50x.html { 31 | root html; 32 | } 33 | location ~ \.php$ { 34 | try_files $uri $uri/ /index.php =404; 35 | fastcgi_pass unix://var/run/php/php7.4-fpm.sock; 36 | fastcgi_index index.php; 37 | fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name; 38 | include fastcgi_params; 39 | } 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /build-files/services.conf: -------------------------------------------------------------------------------- 1 | [program:nginx] 2 | command=nginx 3 | stdout_logfile=/dev/stdout 4 | stdout_logfile_maxbytes=0 5 | stderr_logfile=/dev/stderr 6 | stderr_logfile_maxbytes=0 7 | 8 | [program:php-fpm] 9 | command=php-fpm7.4 --fpm-config /etc/php/7.4/fpm/php-fpm.conf --nodaemonize --allow-to-run-as-root 10 | 11 | [program:horizon] 12 | directory=/code/pm4 13 | command=php artisan horizon 14 | stdout_logfile=/dev/stdout 15 | stdout_logfile_maxbytes=0 16 | stderr_logfile=/dev/stderr 17 | stderr_logfile_maxbytes=0 18 | 19 | [program:laravel-echo-server] 20 | directory=/code/pm4 21 | command=npx laravel-echo-server start 22 | stdout_logfile=/dev/stdout 23 | stdout_logfile_maxbytes=0 24 | stderr_logfile=/dev/stderr 25 | stderr_logfile_maxbytes=0 26 | 27 | [program:cron] 28 | command=cron -f -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.8" 2 | services: 3 | web: 4 | image: processmaker/pm4-core:${PM_VERSION} 5 | ports: 6 | - ${PM_APP_PORT}:80 7 | - ${PM_BROADCASTER_PORT}:6001 8 | environment: 9 | - PM_APP_URL 10 | - PM_APP_PORT 11 | - PM_BROADCASTER_PORT 12 | volumes: 13 | - ${PM_DOCKER_SOCK}:/var/run/docker.sock 14 | - storage:/code/pm4/storage 15 | links: 16 | - redis 17 | - mysql 18 | depends_on: 19 | - mysql 20 | - redis 21 | redis: 22 | image: redis 23 | mysql: 24 | image: mysql:5.7 25 | restart: always 26 | environment: 27 | MYSQL_ROOT_PASSWORD: password 28 | MYSQL_DATABASE: processmaker 29 | MYSQL_USER: pm 30 | MYSQL_PASSWORD: pass 31 | volumes: 32 | - database:/var/lib/mysql 33 | volumes: 34 | database: 35 | storage: --------------------------------------------------------------------------------