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/.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/ 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..9e36e86 --- /dev/null +++ b/Dockerfile.new @@ -0,0 +1,41 @@ +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 && 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/processmaker-${PM_VERSION} . +RUN composer install --ignore-platform-reqs +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 serversideup/php:7.4-fpm-nginx +ENV DEBIAN_FRONTEND=noninteractive +ENV TZ="America/Los_Angeles" +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/* +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 +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 . +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/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 8127f6d..30f1a89 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 @@ -14,17 +16,20 @@ services: - storage:/code/pm4/storage links: - redis - - mysql + - mysql depends_on: - mysql - - redis + - redis redis: image: redis mysql: + platform: linux/x86_64 image: mysql:5.7 restart: always + ports: + - "3306:3306" environment: - MYSQL_ROOT_PASSWORD: password + MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: processmaker MYSQL_USER: pm MYSQL_PASSWORD: pass @@ -32,4 +37,4 @@ services: - database:/var/lib/mysql volumes: database: - storage: \ No newline at end of file + storage: