From 9623892e7955c98ed98b3cf5e7f76e2c60843bfa Mon Sep 17 00:00:00 2001 From: Fernando Ontiveros Date: Sat, 5 Apr 2025 16:23:05 +0000 Subject: [PATCH] improving the dockerfile and the building --- .circleci/config.yml | 39 -------------- .gitignore | 1 - .gitlab-ci.yml | 12 +++++ .travis.yml | 13 ----- Jenkinsfile | 95 --------------------------------- docker/.dockerignore | 33 ++++++++++++ docker/Dockerfile | 10 ++++ docker/build.sh | 26 +++++++++ workflow/public_html/index.html | 8 +++ 9 files changed, 89 insertions(+), 148 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .gitlab-ci.yml delete mode 100644 .travis.yml delete mode 100644 Jenkinsfile create mode 100644 docker/.dockerignore create mode 100644 docker/Dockerfile create mode 100644 docker/build.sh create mode 100644 workflow/public_html/index.html diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 5bb423cc9..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,39 +0,0 @@ -version: 2 -jobs: - build: - working_directory: ~/processmaker - docker: - - image: devopsstacks/pm:n285-phpunit - - image: cimg/mysql:8.0 - command: | - mysqld --default-authentication-plugin='mysql_native_password' --optimizer-switch='derived_merge=off' --sql-mode='NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' --collation-server='utf8mb4_unicode_ci' --character-set-server='utf8mb4' --max_connections=500 - environment: - MYSQL_HOST: 127.0.0.1 - MYSQL_ROOT_PASSWORD: 'password' - MYSQL_ROOT_HOST: '%' - steps: - - checkout - - run: - name: Install dockerize - command: wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz - environment: - DOCKERIZE_VERSION: v0.6.1 - - run: - name: Wait for DB - command: dockerize -wait tcp://127.0.0.1:3306 -timeout 3m - - run: mysql -u root -ppassword -h 127.0.0.1 -e "create database test;" - - run: mysql -u root -ppassword -h 127.0.0.1 -e "create database testexternal;" - - run: composer install - - run: - name: Run Test Units - command: | - mkdir -p coverage - vendor/bin/phpunit --stop-on-error --testdox-html coverage/result.html --coverage-html coverage --verbose tests/unit/ - environment: - XDEBUG_MODE: coverage - - store_artifacts: - path: coverage - destination: coverage - - store_test_results: - path: coverage - \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1935ddc44..01ddee998 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ update.sh # Ignore build artifacts and logs workflow/public_html/build-log.html workflow/public_html/mix-manifest.json -workflow/public_html/index.html workflow/public_html/webapp/ workflow/public_html/translations/ workflow/public_html/files/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000..e1a98b9db --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,12 @@ +stages: + - build + +build_job: + stage: build + script: + - bash docker/build.sh $VERSION + +before_script: + - VERSION=$(git describe | awk -F- '{ if( $2) {print $1 "." $2} else {print $1 ".0"} }' ) + - echo $VERSION + diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a62cb7be4..000000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: php -script: phpunit - -php: - - 5.3 - - 5.4 - -before_install: - - composer install - -branches: - only: - - michelangelo diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 6bd348c4b..000000000 --- a/Jenkinsfile +++ /dev/null @@ -1,95 +0,0 @@ -#!groovy -node { - /** - * Branch should be in gitflow format. If not, then we'll abort. - */ - if(!env.BRANCH_NAME.matches(/(feature|hotfix|bugfix|release|master|develop)\/.+/) && !env.BRANCH_NAME.matches(/^PR-.*$/)) { - hipchatSend message: "${env.BRANCH_NAME} Build: Does not match gitflow naming. Aborted", room: 'engineering' - error "Job does not follow gitflow naming format." - } - // Parse out our short name and potential jira ticket. Null if not associated. If null, then for now we won't notify - // on jira ticket - def jiraTicket = env.BRANCH_NAME.find(/HOR-\d+/) - - def shortname = env.BRANCH_NAME.replace('/', '-').replace('.', '-').toLowerCase() - def dbSuffix = shortname.replace('-', '') - - echo "Building for ${env.BRANCH_NAME}" - - // Checkout source - checkout scm - - try { - stage('Start Notification') { - if(jiraTicket) { - jiraComment issueKey: jiraTicket, body: "Build ${env.BUILD_NUMBER} Starting.\nTicket will be updated once build is completed.\n\n${env.BUILD_URL}" - } - hipchatSend message: "${env.BRANCH_NAME} Build: ${env.BUILD_NUMBER} Starting.\n${env.BUILD_URL}", room: 'engineering' - } - - stage('Dependencies') { - echo "Running Composer" - sh 'composer install' - echo "Running rake" - sh 'rake' - } - - stage('Generate QA MySQL Databases') { - withCredentials([string(credentialsId: 'qa-rds-hostname', variable: 'rdsHostname'), usernamePassword(credentialsId: 'qa-rds-credentials', passwordVariable: 'rdsPassword', usernameVariable: 'rdsUsername')]) { - echo 'Dropping existing database and recreating.' - sh "mysql -h ${rdsHostname} -u ${rdsUsername} -p${rdsPassword} -e 'drop database if exists qa205${dbSuffix}; create database qa205${dbSuffix}'" - sh "mysql -h ${rdsHostname} -u ${rdsUsername} -p${rdsPassword} -e 'drop database if exists qa300${dbSuffix}; create database qa300${dbSuffix}'" - } - } - - stage('Publish to QA-205') { - sshagent(['processmaker-deploy']) { - echo 'Dropping existing files and recreating' - sh "ssh processmaker@build-qa205.processmaker.net 'rm -Rf /home/processmaker/${shortname}'" - sh "scp -r ./ processmaker@build-qa205.processmaker.net:~/${shortname}" - echo 'Creating necessary directories' - sh "ssh processmaker@build-qa205.processmaker.net 'mkdir -p /home/processmaker/${shortname}/workflow/engine/js/labels'" - sh "ssh processmaker@build-qa205.processmaker.net 'mkdir -p /home/processmaker/${shortname}/workflow/public_html/translations'" - } - } - - stage('Publish to QA-300') { - sshagent(['processmaker-deploy']) { - echo 'Dropping existing files and recreating' - sh "ssh processmaker@build-qa300.processmaker.net 'rm -Rf /home/processmaker/${shortname}'" - sh "scp -r ./ processmaker@build-qa300.processmaker.net:~/${shortname}" - echo 'Creating necessary directories' - sh "ssh processmaker@build-qa300.processmaker.net 'mkdir -p /home/processmaker/${shortname}/workflow/engine/js/labels'" - sh "ssh processmaker@build-qa300.processmaker.net 'mkdir -p /home/processmaker/${shortname}/workflow/public_html/translations'" - } - } - - stage('Success Notification') { - withCredentials([string(credentialsId: 'qa-rds-hostname', variable: 'rdsHostname'), usernamePassword(credentialsId: 'qa-rds-credentials', passwordVariable: 'rdsPassword', usernameVariable: 'rdsUsername')]) { - if(jiraTicket) { - jiraComment issueKey: jiraTicket, body: "" + - "Build ${env.BUILD_NUMBER} Completed.\n" + - "5.6 Build: https://${shortname}.qa205.processmaker.net\n" + - "Database Host: ${rdsHostname}\n" + - "Username: ${rdsUsername}\n" + - "Password: ${rdsPassword}\n" + - "Database: qa205${dbSuffix}\n\n" + - "7.0 Build: https://${shortname}.qa300.processmaker.net\n" + - "Database Host: ${rdsHostname}\n" + - "Username: ${rdsUsername}\n" + - "Password: ${rdsPassword}\n" + - "Database: qa300${dbSuffix}\n\n" + - "${env.BUILD_URL}" - } - hipchatSend room: 'engineering', message: "" + - "${env.BRANCH_NAME} Build: ${env.BUILD_NUMBER} Completed.\n" + - "${env.BUILD_URL}" - } - } - } catch(error) { - if(jiraTicket) { - jiraComment issueKey: jiraTicket, body: "Build ${env.BUILD_NUMBER} Failed: ${error}\n\n${env.BUILD_URL}" - } - hipchatSend message: "${env.BRANCH_NAME} Build: ${env.BUILD_NUMBER} Failed: ${error}\n${env.BUILD_URL}", room: 'engineering' - } -} \ No newline at end of file diff --git a/docker/.dockerignore b/docker/.dockerignore new file mode 100644 index 000000000..d34595ea6 --- /dev/null +++ b/docker/.dockerignore @@ -0,0 +1,33 @@ +# Ignore temporary files +tmp/ +temp/ + +# Ignore Docker-related files (if you don't want them in the context) +Dockerfile +docker/ + +# Ignore version control files +/.git + +# Ignore documentation and configuration files +INSTALL.txt +README.md +Rakefile +pmos.conf.example + +# Ignore testing and feature files +tests/ +features/ +phpunit.xml +behat.yml.dist +phpdox.xml +env_unittest.sh + +# Ignore patches and updates +patch/ +update/ + +# Other files to ignore (customize as needed) +apiary.apib +processmaker.bat + diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..40e6d204d --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,10 @@ +# Use our base image +FROM gitlab.luranasoft.com:5050/luos/docker/base-image:1.0.9-php8.3 + +# Set the working directory +WORKDIR /code + +# Copy the application code from the current directory to /code in the image +COPY . . + +RUN chown -R www-data:www-data /code diff --git a/docker/build.sh b/docker/build.sh new file mode 100644 index 000000000..969829657 --- /dev/null +++ b/docker/build.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Check if the first parameter is provided +if [ -z "$1" ]; then + echo "Error: Semantic version parameter is required." + echo "Usage: $0 " + exit 1 +fi + +echo "Building Lurana Open Source version $1" + +# Update and install Composer dependencies +composer update +composer install + +# Construct the Docker image tag name +tagname="gitlab.luranasoft.com:5050/pm/processmaker:$1" +echo "Docker tag name: $tagname" + +# Build the Docker image using the new tag name +docker build -t "$tagname" -f ./docker/Dockerfile . + +# Push the Docker image to the repository +docker push "$tagname" + +echo "Build and push completed successfully." \ No newline at end of file diff --git a/workflow/public_html/index.html b/workflow/public_html/index.html new file mode 100644 index 000000000..f8bac433b --- /dev/null +++ b/workflow/public_html/index.html @@ -0,0 +1,8 @@ + + + Redirector + + + + +