From c602df5cc75e10ab3efc5e1356118b2b6b182641 Mon Sep 17 00:00:00 2001 From: Jose Chirivella Date: Fri, 3 Dec 2021 14:10:20 -0500 Subject: [PATCH 1/8] Added the WIP images --- Dockerfile | 13 ++++++++++--- Dockerfile.base | 16 +++++----------- Dockerfile.new | 23 +++++++++++++++++++++++ 3 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 Dockerfile.new diff --git a/Dockerfile b/Dockerfile index 999dac4..ac0bdb2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,23 @@ -FROM processmaker/pm4-base:1.0.0 - +FROM alpine as copy ARG PM_VERSION WORKDIR /tmp RUN wget https://github.com/ProcessMaker/processmaker/archive/refs/tags/v${PM_VERSION}.zip RUN unzip v${PM_VERSION}.zip && rm -rf /code/pm4 && mv processmaker-${PM_VERSION} /code/pm4 +FROM composer:1.7 as vendor WORKDIR /code/pm4 +COPY --from=copy /code/pm4 . RUN composer install COPY build-files/laravel-echo-server.json . + +FROM node:lts-alpine as node +WORKDIR /code/pm4 +COPY --from=vendor /code/pm4 . RUN npm install --unsafe-perm=true && npm run dev -COPY build-files/laravel-echo-server.json . +FROM processmaker/pm4-base:v4.1.20 +WORKDIR /code/pm4 +COPY --from=node /code/pm4 . COPY build-files/init.sh . CMD bash init.sh && supervisord --nodaemon diff --git a/Dockerfile.base b/Dockerfile.base index cfe43b7..6c36c63 100644 --- a/Dockerfile.base +++ b/Dockerfile.base @@ -6,17 +6,11 @@ RUN apt update # In ubuntu 20.04, installing php without specifying a version installs 7.4 :) 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 \ -nginx vim curl unzip wget supervisor cron mysql-client build-essential - -# -# node -# -RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - -RUN apt -y install nodejs + nginx vim curl unzip wget supervisor cron mysql-client build-essential # # install composer -# +# RUN wget -O composer-setup.php https://getcomposer.org/installer RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer RUN composer self-update @@ -33,7 +27,7 @@ RUN chmod 0644 /etc/cron.d/laravel-cron && crontab /etc/cron.d/laravel-cron ENV DOCKERVERSION=20.10.5 RUN curl -fsSLO https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKERVERSION}.tgz \ && tar xzvf docker-${DOCKERVERSION}.tgz --strip 1 \ - -C /usr/local/bin docker/docker \ + -C /usr/local/bin docker/docker \ && rm docker-${DOCKERVERSION}.tgz # @@ -42,8 +36,8 @@ RUN curl -fsSLO https://download.docker.com/linux/static/stable/x86_64/docker-${ RUN sed -i 's/www-data/root/g' /etc/php/7.4/fpm/pool.d/www.conf # -# nginx -# +# nginx +# COPY build-files/nginx.conf /etc/nginx/nginx.conf # diff --git a/Dockerfile.new b/Dockerfile.new new file mode 100644 index 0000000..c2b1b22 --- /dev/null +++ b/Dockerfile.new @@ -0,0 +1,23 @@ +FROM php:7.4-cli-alpine as PHPBASE + +RUN apt update -y && apt install + +FROM alpine as copy +WORKDIR /tmp +RUN wget https://github.com/ProcessMaker/processmaker/archive/refs/tags/v${PM_VERSION}.zip +RUN unzip v${PM_VERSION}.zip && rm -rf /code/pm4 && mv processmaker-${PM_VERSION} /code/pm4 + +FROM composer:1.7 as vendor +WORKDIR /code/pm4 +COPY --from=copy /code/pm4 . +RUN composer install +COPY build-files/laravel-echo-server.json . + +FROM node:lts-alpine as NODE +WORKDIR /code/pm4 +COPY --from=vendor /code/pm4 . +RUN npm install +RUN npm run dev + +FROM nginx:alpine +COPY build-files/nginx.conf /etc/nginx/nginx.conf From 86feffad4be007fa99407950eef3f23e21a6f607 Mon Sep 17 00:00:00 2001 From: Jose Chirivella Date: Tue, 7 Dec 2021 15:23:46 -0500 Subject: [PATCH 2/8] Fixing the steps to build the final image --- Dockerfile.new | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Dockerfile.new b/Dockerfile.new index c2b1b22..2c04f76 100644 --- a/Dockerfile.new +++ b/Dockerfile.new @@ -1,23 +1,33 @@ FROM php:7.4-cli-alpine as PHPBASE RUN apt update -y && apt install +RUN sed -i 's/www-data/root/g' /etc/php/7.4/fpm/pool.d/www.conf FROM alpine as copy +ARG PM_VERSION WORKDIR /tmp RUN wget https://github.com/ProcessMaker/processmaker/archive/refs/tags/v${PM_VERSION}.zip -RUN unzip v${PM_VERSION}.zip && rm -rf /code/pm4 && mv processmaker-${PM_VERSION} /code/pm4 +RUN unzip v${PM_VERSION}.zip && mkdir -p /code/pm4 && mv processmaker-${PM_VERSION} /code/pm4 FROM composer:1.7 as vendor +ARG PM_VERSION WORKDIR /code/pm4 -COPY --from=copy /code/pm4 . -RUN composer install +COPY --from=copy /code/pm4/processmaker-${PM_VERSION} . +RUN composer install --ignore-platform-reqs COPY build-files/laravel-echo-server.json . -FROM node:lts-alpine as NODE +FROM node:lts-alpine as node WORKDIR /code/pm4 COPY --from=vendor /code/pm4 . RUN npm install RUN npm run dev FROM nginx:alpine +RUN apk add --no-cache supervisor +COPY build-files/services.conf /etc/supervisor/conf.d/services.conf COPY build-files/nginx.conf /etc/nginx/nginx.conf +COPY build-files/laravel-cron /etc/cron.d/laravel-cron +RUN chmod 0644 /etc/cron.d/laravel-cron && crontab /etc/cron.d/laravel-cron +WORKDIR /code/pm4 +COPY --from=node /code/pm4 . +EXPOSE 80 443 6001 \ No newline at end of file From 02827067a3d5c4baf65721843cdccfece345c19e Mon Sep 17 00:00:00 2001 From: Jose Chirivella Date: Thu, 9 Dec 2021 16:38:59 -0500 Subject: [PATCH 3/8] Added more instructions to the Dockerfile.new * Added a makefile for helping debug this quickly --- Dockerfile.new | 19 +++++++++++-------- Makefile | 9 +++++++++ docker-compose.yml | 16 +++++++++------- 3 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 Makefile diff --git a/Dockerfile.new b/Dockerfile.new index 2c04f76..1ca0bd0 100644 --- a/Dockerfile.new +++ b/Dockerfile.new @@ -1,8 +1,3 @@ -FROM php:7.4-cli-alpine as PHPBASE - -RUN apt update -y && apt install -RUN sed -i 's/www-data/root/g' /etc/php/7.4/fpm/pool.d/www.conf - FROM alpine as copy ARG PM_VERSION WORKDIR /tmp @@ -22,12 +17,20 @@ COPY --from=vendor /code/pm4 . RUN npm install RUN npm run dev -FROM nginx:alpine -RUN apk add --no-cache supervisor +FROM serversideup/php:7.4-fpm-nginx +ENV DEBIAN_FRONTEND=noninteractive +ENV TZ="America/Los_Angeles" +RUN apt update +RUN apt-get install -y supervisor cron php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-imagick php-sqlite3 mysql-client \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* +RUN sed -i 's/www-data/root/g' /etc/php/7.4/fpm/pool.d/www.conf COPY build-files/services.conf /etc/supervisor/conf.d/services.conf COPY build-files/nginx.conf /etc/nginx/nginx.conf COPY build-files/laravel-cron /etc/cron.d/laravel-cron RUN chmod 0644 /etc/cron.d/laravel-cron && crontab /etc/cron.d/laravel-cron WORKDIR /code/pm4 COPY --from=node /code/pm4 . -EXPOSE 80 443 6001 \ No newline at end of file +COPY build-files/init.sh . +EXPOSE 80 443 6001 +CMD bash init.sh && supervisord --nodaemon diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f5033e6 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +VERSION = 4.1.21 +PLATFORMS = "linux/amd64,linux/arm64" +DOCKER_REPO = "processmaker4/pm4-core" + +build: + docker buildx build --platform $(PLATFORMS) --build-arg PM_VERSION=$(VERSION) -t $(DOCKER_REPO):ci -f Dockerfile.new . + +build-compose: + docker compose build --build-arg PM_VERSION=$(VERSION) diff --git a/docker-compose.yml b/docker-compose.yml index 8127f6d..bd2c1a8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,9 @@ -version: "3.8" +version: '3.8' services: web: - image: processmaker/pm4-core:${PM_VERSION} + build: + context: . + dockerfile: Dockerfile.new ports: - ${PM_APP_PORT}:80 - ${PM_BROADCASTER_PORT}:6001 @@ -10,21 +12,21 @@ services: - PM_APP_PORT - PM_BROADCASTER_PORT volumes: - - ${PM_DOCKER_SOCK}:/var/run/docker.sock + - /var/run/docker.sock:/usr/bin/docker.sock - storage:/code/pm4/storage links: - redis - - mysql + - mysql depends_on: - mysql - - redis + - redis redis: image: redis mysql: image: mysql:5.7 restart: always environment: - MYSQL_ROOT_PASSWORD: password + MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: processmaker MYSQL_USER: pm MYSQL_PASSWORD: pass @@ -32,4 +34,4 @@ services: - database:/var/lib/mysql volumes: database: - storage: \ No newline at end of file + storage: From b7cf053959fbbd6613df1e0ade6f20e6ad80ca3a Mon Sep 17 00:00:00 2001 From: Jose Chirivella Date: Mon, 13 Dec 2021 11:25:14 -0500 Subject: [PATCH 4/8] Reverted back the env variable which points to the docker.sock --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index bd2c1a8..4ef7394 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,7 @@ services: - PM_APP_PORT - PM_BROADCASTER_PORT volumes: - - /var/run/docker.sock:/usr/bin/docker.sock + - ${PM_DOCKER_SOCK}:/usr/bin/docker.sock - storage:/code/pm4/storage links: - redis From e39ddd14492f9cfd0990091f08cbdc7042c3032c Mon Sep 17 00:00:00 2001 From: Jose Chirivella Date: Mon, 13 Dec 2021 13:00:59 -0500 Subject: [PATCH 5/8] Added docker step back --- Dockerfile.new | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Dockerfile.new b/Dockerfile.new index 1ca0bd0..9e36e86 100644 --- a/Dockerfile.new +++ b/Dockerfile.new @@ -20,10 +20,15 @@ RUN npm run dev FROM serversideup/php:7.4-fpm-nginx ENV DEBIAN_FRONTEND=noninteractive ENV TZ="America/Los_Angeles" -RUN apt update -RUN apt-get install -y supervisor cron php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-imagick php-sqlite3 mysql-client \ +ENV DOCKERVERSION=20.10.5 +RUN apt-get update +RUN apt-get install -y --no-install-recommends supervisor cron php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-imagick php-sqlite3 mysql-client \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* +RUN curl -fsSLO https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKERVERSION}.tgz \ + && tar xzvf docker-${DOCKERVERSION}.tgz --strip 1 \ + -C /usr/local/bin docker/docker \ + && rm docker-${DOCKERVERSION}.tgz RUN sed -i 's/www-data/root/g' /etc/php/7.4/fpm/pool.d/www.conf COPY build-files/services.conf /etc/supervisor/conf.d/services.conf COPY build-files/nginx.conf /etc/nginx/nginx.conf From 61e92f3e672b45a57860d408d3223044b7ba3b81 Mon Sep 17 00:00:00 2001 From: Jose Chirivella Date: Mon, 13 Dec 2021 13:01:17 -0500 Subject: [PATCH 6/8] /var/run/docker.sock seems to be the volume to be --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4ef7394..42c4a2d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,7 @@ services: - PM_APP_PORT - PM_BROADCASTER_PORT volumes: - - ${PM_DOCKER_SOCK}:/usr/bin/docker.sock + - ${PM_DOCKER_SOCK}:/var/run/docker.sock - storage:/code/pm4/storage links: - redis From 296d8824fa397a62edb17bca067788de815c250a Mon Sep 17 00:00:00 2001 From: Jose Chirivella Date: Mon, 27 Dec 2021 14:02:29 -0500 Subject: [PATCH 7/8] Added some folders to the gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6a01034..0f5ce9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ bind-mount/composer/cache -bind-mount/npm \ No newline at end of file +bind-mount/npm +.idea/ +.vscode/ From 4d1f88bc3c0abde2aed100e5bbe82847a04faa82 Mon Sep 17 00:00:00 2001 From: Jose Chirivella Date: Tue, 1 Feb 2022 12:02:11 -0500 Subject: [PATCH 8/8] updating pm version and testing docker compose config --- .env | 2 +- build-files/init.sh | 2 +- docker-compose.yml | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.env b/.env index c10a6da..7842d20 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -PM_VERSION=4.1.20 +PM_VERSION=4.1.21 PM_APP_URL=http://localhost PM_APP_PORT=8080 PM_BROADCASTER_PORT=6001 diff --git a/build-files/init.sh b/build-files/init.sh index 4c6b682..849f6a3 100644 --- a/build-files/init.sh +++ b/build-files/init.sh @@ -46,7 +46,7 @@ if [ ! -f ".env" ]; then --data-username=pm \ --data-password=pass \ --redis-host=redis - + echo "PROCESSMAKER_SCRIPTS_DOCKER=/usr/local/bin/docker" >> .env echo "PROCESSMAKER_SCRIPTS_DOCKER_MODE=copying" >> .env diff --git a/docker-compose.yml b/docker-compose.yml index 42c4a2d..30f1a89 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,8 +23,11 @@ services: redis: image: redis mysql: + platform: linux/x86_64 image: mysql:5.7 restart: always + ports: + - "3306:3306" environment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: processmaker