From 02d86266df3e18ac3bee245cd8702fe634f542e4 Mon Sep 17 00:00:00 2001 From: Artsiom Siamashka Date: Tue, 16 Sep 2025 17:04:41 +0200 Subject: [PATCH 01/13] Added Dockerfile and jenkins pipeline --- Dockerfile | 15 +++++++++++++++ Jenkinsfile | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 Dockerfile create mode 100644 Jenkinsfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a736e39 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +# Base image +FROM composer:2.6.4 AS base + +COPY . /src +WORKDIR /src +RUN composer install --no-dev --optimize-autoloader + +FROM wordpress:6.1.1-php8.2 AS livecarta_wp +ARG ENV_NAME +COPY --from=base /src/htdocs /var/www/html +COPY --from=base /src/environments/docker_container/ /var/www/html/ +COPY --from=base /src/environments/all/ /var/www/html/ +COPY --from=base /src/environments/${ENV_NAME}/robots.txt /var/www/html/robots.txt + +RUN chown -R www-data:www-data /var/www/html/ diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..336c909 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,50 @@ +pipeline { + agent any + + parameters { + choice( + name: 'ENVIRONMENT', + choices: ['dev', 'qa', 'new_prod', 'demo'], + description: 'Environment Name for the application (e.g., dev, production etc.)' + ) + } + + stages { + stage('Build Base QA Docker Image') { + when { + branch 'qa' + } + steps { + sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t 10.50.10.93:5000/livecarta_wp:qa ." + sh 'docker push 10.50.10.93:5000/livecarta_base:qa_test' + } + } + stage('Build Base DEV Docker Image') { + when { + branch 'develop' + } + steps { + sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t 10.50.10.93:5000/livecarta_base:dev ." + sh 'docker push 10.50.10.93:5000/livecarta_base:dev' + } + } + stage('Build Base PROD Docker Image') { + when { + branch 'master' + } + steps { + sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t 10.50.10.93:5000/livecarta_base:prod ." + sh 'docker push 10.50.10.93:5000/livecarta_base:prod' + } + } + stage('Build Base WL Docker Image') { + when { + branch 'wl' + } + steps { + sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t 10.50.10.93:5000/livecarta_base:wl ." + sh 'docker push 10.50.10.93:5000/livecarta_base:wl' + } + } + } +} \ No newline at end of file From ed71e9c86d0af01555929f1e5ce09424bbd38ebd Mon Sep 17 00:00:00 2001 From: Artsiom Siamashka Date: Wed, 17 Sep 2025 11:15:21 +0200 Subject: [PATCH 02/13] Fixed image naming --- Jenkinsfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 336c909..e2a1173 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { } steps { sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t 10.50.10.93:5000/livecarta_wp:qa ." - sh 'docker push 10.50.10.93:5000/livecarta_base:qa_test' + sh 'docker push 10.50.10.93:5000/livecarta_wp:qa' } } stage('Build Base DEV Docker Image') { @@ -24,8 +24,8 @@ pipeline { branch 'develop' } steps { - sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t 10.50.10.93:5000/livecarta_base:dev ." - sh 'docker push 10.50.10.93:5000/livecarta_base:dev' + sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t 10.50.10.93:5000/livecarta_wp:dev ." + sh 'docker push 10.50.10.93:5000/livecarta_wp:dev' } } stage('Build Base PROD Docker Image') { @@ -33,8 +33,8 @@ pipeline { branch 'master' } steps { - sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t 10.50.10.93:5000/livecarta_base:prod ." - sh 'docker push 10.50.10.93:5000/livecarta_base:prod' + sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t 10.50.10.93:5000/livecarta_wp:prod ." + sh 'docker push 10.50.10.93:5000/livecarta_wp:prod' } } stage('Build Base WL Docker Image') { @@ -42,8 +42,8 @@ pipeline { branch 'wl' } steps { - sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t 10.50.10.93:5000/livecarta_base:wl ." - sh 'docker push 10.50.10.93:5000/livecarta_base:wl' + sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t 10.50.10.93:5000/livecarta_wp:wl ." + sh 'docker push 10.50.10.93:5000/livecarta_wp:wl' } } } From 30e77947f60687f5883e98a360fd6351a80609d2 Mon Sep 17 00:00:00 2001 From: Artsiom Siamashka Date: Thu, 25 Sep 2025 19:13:57 +0200 Subject: [PATCH 03/13] Removed redundant steps, parametrized image name, set tmp image tag --- Jenkinsfile | 41 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e2a1173..5f591ce 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,41 +9,16 @@ pipeline { ) } + environment { + // LC_IMG_TAG = "${mapBranchToEnv(env.BRANCH_NAME)}" + LC_IMG_TAG = 'qa_test' + } + stages { - stage('Build Base QA Docker Image') { - when { - branch 'qa' - } + stage('Build') { steps { - sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t 10.50.10.93:5000/livecarta_wp:qa ." - sh 'docker push 10.50.10.93:5000/livecarta_wp:qa' - } - } - stage('Build Base DEV Docker Image') { - when { - branch 'develop' - } - steps { - sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t 10.50.10.93:5000/livecarta_wp:dev ." - sh 'docker push 10.50.10.93:5000/livecarta_wp:dev' - } - } - stage('Build Base PROD Docker Image') { - when { - branch 'master' - } - steps { - sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t 10.50.10.93:5000/livecarta_wp:prod ." - sh 'docker push 10.50.10.93:5000/livecarta_wp:prod' - } - } - stage('Build Base WL Docker Image') { - when { - branch 'wl' - } - steps { - sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t 10.50.10.93:5000/livecarta_wp:wl ." - sh 'docker push 10.50.10.93:5000/livecarta_wp:wl' + sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t ${env.PUSH_REGISTRY}/${LC_WP_IMG}:${LC_IMG_TAG} ." + sh 'docker push ${env.PUSH_REGISTRY}/${LC_WP_IMG}:${LC_IMG_TAG}' } } } From 7bfb9bdf893fb4ab8a6569c2ac7a8c02b6a78c37 Mon Sep 17 00:00:00 2001 From: Artsiom Siamashka Date: Thu, 25 Sep 2025 19:21:09 +0200 Subject: [PATCH 04/13] Fixed img name variable usage --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5f591ce..461be16 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,8 +17,8 @@ pipeline { stages { stage('Build') { steps { - sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t ${env.PUSH_REGISTRY}/${LC_WP_IMG}:${LC_IMG_TAG} ." - sh 'docker push ${env.PUSH_REGISTRY}/${LC_WP_IMG}:${LC_IMG_TAG}' + sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t ${env.PUSH_REGISTRY}/${env.LC_WP_IMG}:${LC_IMG_TAG} ." + sh 'docker push ${env.PUSH_REGISTRY}/${env.LC_WP_IMG}:${LC_IMG_TAG}' } } } From 6245e522ba19c62aefbc793c8a75f0b05690a08d Mon Sep 17 00:00:00 2001 From: Artsiom Siamashka Date: Thu, 25 Sep 2025 19:25:49 +0200 Subject: [PATCH 05/13] Included folder properties to inject base env variables --- Jenkinsfile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 461be16..8669966 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,12 @@ +@Library('utils') _ + pipeline { agent any + options { + withFolderProperties() + } + parameters { choice( name: 'ENVIRONMENT', @@ -10,7 +16,7 @@ pipeline { } environment { - // LC_IMG_TAG = "${mapBranchToEnv(env.BRANCH_NAME)}" + // LC_IMG_TAG = "${utils.mapBranchToEnv(env.BRANCH_NAME)}" LC_IMG_TAG = 'qa_test' } From 84917a95d3dae939cb62e58c46dc27351d89c9fb Mon Sep 17 00:00:00 2001 From: Artsiom Siamashka Date: Thu, 25 Sep 2025 19:29:47 +0200 Subject: [PATCH 06/13] Fixed push step --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8669966..960b65e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,7 +24,7 @@ pipeline { stage('Build') { steps { sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t ${env.PUSH_REGISTRY}/${env.LC_WP_IMG}:${LC_IMG_TAG} ." - sh 'docker push ${env.PUSH_REGISTRY}/${env.LC_WP_IMG}:${LC_IMG_TAG}' + sh "docker push ${env.PUSH_REGISTRY}/${env.LC_WP_IMG}:${LC_IMG_TAG}" } } } From 5f19f89b2f3a7c25b3aa2c8d713443767fef8090 Mon Sep 17 00:00:00 2001 From: Artsiom Siamashka Date: Sat, 27 Sep 2025 10:51:37 +0200 Subject: [PATCH 07/13] Removed env param and replaced with mapping function --- Jenkinsfile | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 960b65e..2e25405 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,16 @@ @Library('utils') _ +def mapBranchNameToWPEnv(branchName) { + def envMap = [ + master: 'new_prod', + main: 'new_prod', + develop: 'dev', + qa: 'qa', + demo: 'demo' + ] + return envMap.get(branchName, 'development') +} + pipeline { agent any @@ -7,23 +18,16 @@ pipeline { withFolderProperties() } - parameters { - choice( - name: 'ENVIRONMENT', - choices: ['dev', 'qa', 'new_prod', 'demo'], - description: 'Environment Name for the application (e.g., dev, production etc.)' - ) - } - environment { // LC_IMG_TAG = "${utils.mapBranchToEnv(env.BRANCH_NAME)}" LC_IMG_TAG = 'qa_test' + WP_ENV = "${mapBranchNameToWPEnv(env.BRANCH_NAME)}" } stages { stage('Build') { steps { - sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t ${env.PUSH_REGISTRY}/${env.LC_WP_IMG}:${LC_IMG_TAG} ." + sh "docker build --build-arg ENV_NAME=${WP_ENV} -t ${env.PUSH_REGISTRY}/${env.LC_WP_IMG}:${LC_IMG_TAG} ." sh "docker push ${env.PUSH_REGISTRY}/${env.LC_WP_IMG}:${LC_IMG_TAG}" } } From 6877774d1e66f86c362487baa487d23975437878 Mon Sep 17 00:00:00 2001 From: Artsiom Siamashka Date: Thu, 2 Oct 2025 13:23:38 +0200 Subject: [PATCH 08/13] Change domains for qa env to migrate --- environments/qa/wp-config-local.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/environments/qa/wp-config-local.php b/environments/qa/wp-config-local.php index f740488..abc93a5 100644 --- a/environments/qa/wp-config-local.php +++ b/environments/qa/wp-config-local.php @@ -5,9 +5,9 @@ define( 'DB_USER', '@lcWpMySqlUsernameQA@' ); define( 'DB_PASSWORD', '@lcWpMySqlPasswordQA@' ); define( 'DB_HOST', '@lcWpMySqlHostQA@' ); -define('DOMAIN_CURRENT_SITE', 'qa.livecarta.com'); +define('DOMAIN_CURRENT_SITE', 'qa116.livecarta.com'); -define('LAWCARTA_SUBDOMAIN', 'app-qa'); +define('LAWCARTA_SUBDOMAIN', 'app-qa116'); define('LAWCARTA_PORT', ''); define('LAWCARTA_ENVIRONMENT_NAME', 'qa'); From c948ba1de396e875a374818cbf7c9df0a6ecd53a Mon Sep 17 00:00:00 2001 From: Artsiom Siamashka Date: Mon, 9 Feb 2026 12:40:32 +0100 Subject: [PATCH 09/13] Moved Dockerfile from devops repo here, removed redundant ant build config, removed unused config, added dockerignore --- .dockerignore | 25 ++++++++++++ Dockerfile | 14 +++++++ build/build.xml | 59 ---------------------------- environments/dev/wp-config-local.php | 21 ---------- 4 files changed, 39 insertions(+), 80 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile delete mode 100644 build/build.xml delete mode 100644 environments/dev/wp-config-local.php diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8b387c1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +.git +.gitignore +.gitattributes +.github/ +.vscode/ +.idea/ +.DS_Store +Thumbs.db +*.log +logs.conf +logs/ + +docker-compose.yml +compose.yml + +.env +.env.* +wp-config-local.php + +node_modules/ +vendor/ + +**/.cache/ +**/tmp/ +**/temp/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c8f74ea --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM wordpress:6.1.1-php8.2 + +ARG ENV_NAME + +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer +COPY composer.json composer.json +COPY composer.lock composer.lock +RUN composer install + +COPY --chown=www-data:www-data ./htdocs/ /var/www/html/ +COPY --chown=www-data:www-data ./environments/docker_container/ /var/www/html/ +COPY --chown=www-data:www-data ./environments/all/ /var/www/html/ +COPY --chown=www-data:www-data ./environments/${ENV_NAME}/robots.txt /var/www/html/robots.txt + diff --git a/build/build.xml b/build/build.xml deleted file mode 100644 index fff1f17..0000000 --- a/build/build.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/environments/dev/wp-config-local.php b/environments/dev/wp-config-local.php deleted file mode 100644 index c55faac..0000000 --- a/environments/dev/wp-config-local.php +++ /dev/null @@ -1,21 +0,0 @@ - Date: Tue, 10 Feb 2026 18:42:19 +0100 Subject: [PATCH 10/13] Rewrote Dockerfile to multy-stage build --- Dockerfile | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index c8f74ea..8e32d4d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,17 @@ -FROM wordpress:6.1.1-php8.2 +FROM composer:latest AS setup +WORKDIR /src +COPY . . +RUN composer install --no-dev --optimize-autoloader +FROM wordpress:6.1.1-php8.2 AS app ARG ENV_NAME -COPY --from=composer:latest /usr/bin/composer /usr/bin/composer -COPY composer.json composer.json -COPY composer.lock composer.lock -RUN composer install +USER www-data:www-data +WORKDIR /var/www/html + +COPY --from=setup --chown=www-data:www-data ./htdocs . +COPY --from=setup --chown=www-data:www-data ./environments/docker_container/ . +COPY --from=setup --chown=www-data:www-data ./environments/all/ . +COPY --from=setup --chown=www-data:www-data ./environments/${ENV_NAME}/robots.txt . -COPY --chown=www-data:www-data ./htdocs/ /var/www/html/ -COPY --chown=www-data:www-data ./environments/docker_container/ /var/www/html/ -COPY --chown=www-data:www-data ./environments/all/ /var/www/html/ -COPY --chown=www-data:www-data ./environments/${ENV_NAME}/robots.txt /var/www/html/robots.txt From 997922ca9a1e402de02f8ce012f48ef2b21f844a Mon Sep 17 00:00:00 2001 From: Artsiom Siamashka Date: Tue, 10 Feb 2026 18:44:21 +0100 Subject: [PATCH 11/13] Changed source path of required files for the final build stage --- Dockerfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8e32d4d..89a129f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,9 +9,8 @@ ARG ENV_NAME USER www-data:www-data WORKDIR /var/www/html -COPY --from=setup --chown=www-data:www-data ./htdocs . -COPY --from=setup --chown=www-data:www-data ./environments/docker_container/ . -COPY --from=setup --chown=www-data:www-data ./environments/all/ . -COPY --from=setup --chown=www-data:www-data ./environments/${ENV_NAME}/robots.txt . - +COPY --from=setup --chown=www-data:www-data /src/htdocs . +COPY --from=setup --chown=www-data:www-data /src/environments/docker_container/ . +COPY --from=setup --chown=www-data:www-data /src/environments/all/ . +COPY --from=setup --chown=www-data:www-data /src/environments/${ENV_NAME}/robots.txt . From dcbba0cbf9b01e4c96f178fa5ac05b03a56f4c45 Mon Sep 17 00:00:00 2001 From: Artsiom Siamashka Date: Thu, 12 Mar 2026 15:44:55 +0100 Subject: [PATCH 12/13] Added WP_HOME and WP_SITEURL params to the config file --- environments/docker_container/wp-config-local.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/environments/docker_container/wp-config-local.php b/environments/docker_container/wp-config-local.php index 95a1801..5062d33 100644 --- a/environments/docker_container/wp-config-local.php +++ b/environments/docker_container/wp-config-local.php @@ -6,6 +6,8 @@ define( 'DB_PASSWORD', getenv('DB_PASSWORD') ); define( 'DB_HOST', getenv('DB_HOST') ); define('DOMAIN_CURRENT_SITE', getenv('DOMAIN_CURRENT_SITE')); +define('WP_HOME', getenv('WP_HOME')); +define('WP_SITEURL', getenv('WP_SITEURL')); define('LAWCARTA_SUBDOMAIN', getenv('SUBDOMAIN')); define('LAWCARTA_PORT', ''); From 66488001f0a27540fef0ce4c36cafd93ee7ca904 Mon Sep 17 00:00:00 2001 From: Artsiom Siamashka Date: Thu, 12 Mar 2026 16:11:28 +0100 Subject: [PATCH 13/13] Updated files copy during build --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 45fd3cc..3fe94a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ ARG ENV_NAME USER www-data:www-data WORKDIR /var/www/html -COPY --from=setup --chown=www-data:www-data /src/htdocs . -COPY --from=setup --chown=www-data:www-data /src/environments/docker_container/ . -COPY --from=setup --chown=www-data:www-data /src/environments/all/ . -COPY --from=setup --chown=www-data:www-data /src/environments/${ENV_NAME}/robots.txt . +COPY --from=setup --chown=www-data:www-data /src/htdocs ./ +COPY --from=setup --chown=www-data:www-data /src/environments/docker_container/ ./ +COPY --from=setup --chown=www-data:www-data /src/environments/all/ ./ +COPY --from=setup --chown=www-data:www-data /src/environments/${ENV_NAME}/robots.txt ./robots.txt