From bb811773820160f18c910bf77a453f1110c14e30 Mon Sep 17 00:00:00 2001 From: Sandeep Kadam Date: Wed, 24 Apr 2019 15:45:01 +0100 Subject: [PATCH] Added local & CI Deployment scripts --- .env | 57 +++++++++++++++++++++++++++++++++ .gitignore | 2 ++ .gitlab-ci.yml | 66 +++++++++++++++++++++++++++++++++++++++ .gitmodules | 3 ++ bin | 1 + docker-compose.yml | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 207 insertions(+) create mode 100644 .env create mode 100644 .gitlab-ci.yml create mode 100644 .gitmodules create mode 160000 bin create mode 100755 docker-compose.yml diff --git a/.env b/.env new file mode 100644 index 000000000..b3a97d807 --- /dev/null +++ b/.env @@ -0,0 +1,57 @@ +# Configuration file for Wordpress local development and deployment script +# Copy this file to the root of the repo, edit the configuration in steps 1-4 and rename to .env + +# +# 1. define the name of the Wordpress site +# +PROJECT_NAME=wordpresslocal + +# Wordpress specific details + +WP_SITE_TITLE="Wordpress demo site" +WP_SITE_DESCRIPTION="This is my WP Demo Site Description" +WP_SITE_ADMIN_USERNAME="admin" +WP_SITE_ADMIN_PASSWORD="admin" +WP_SITE_ADMIN_EMAIL="admin@mysite.com" + +# WP default plugins/posts/comments config changes +WP_NEED_BLANK_SITE=No + +# WP Group site setup settings (Given default values of Web Development Group) + +WP_GROUP_SITE_TITLE="Web Development" +WP_GROUP_WHO_TAXONOMY_SLUG=who-jonathan-hickford +WP_GROUP_WHAT_TAXONOMY_SLUG=what-embl-org-sitemap-taxonomy-locations-embl-ebi-hinxton-web-development +WP_GROUP_WHERE_TAXONOMY_SLUG=where-sites-embl-ebi-hinxton-web-development +WP_GROUP_TEAM_SHORT_DESCRIPTION="The Web Development team maintain the EMBL-EBI website, internal websites, and bespoke websites for projects in which EMBL-EBI is a collaborator. The team support teams and projects throughout the organisation with web development and User Experience design." + +############################################## +# you shouldn't need to edit below this line + +VM_CORE_PATH=/var/www/html +APACHE_DOCUMENT_ROOT=/var/www/html/dist + +# repo specific paths +LOCAL_CORE_PATH=. + +RELATIVE_DOCUMENT_ROOT=dist +RELATIVE_SQLDUMP_SRC=_sqldump +RELATIVE_SQLDATA_SRC=_sqldata +RELATIVE_TEMP_SRC=_temp +WP_SOURCE_THEMES_PATH=${LOCAL_CORE_PATH}/wp-content/themes +WP_SOURCE_PLUGIN_PATH=${LOCAL_CORE_PATH}/wp-content/plugins +WP_DEST_THEMES_PATH=${RELATIVE_DOCUMENT_ROOT}/wp-content/themes +WP_DEST_PLUGIN_PATH=${RELATIVE_DOCUMENT_ROOT}/wp-content/plugins + +# docker specific details, used in docker-compose.yml +DOCKER_DATABASE=docker +DOCKER_DATABASE_USER=docker +DOCKER_DATABASE_PASS=docker +DB_ROOT_PASSWORD=rootpassword + +GIT_EMBL_DE_TOKEN=tHJezuyyt53veqK-MSs6 + +### PROJECT SETTINGS +PHP_TAG=7.1-dev-4.4.5 +MARIADB_TAG=10.1-3.2.2 +APACHE_TAG=2.4-3.0.5 diff --git a/.gitignore b/.gitignore index e4ca28441..070e9f2ec 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ Desktop.ini node_modules .sass-cache *.log +/dist/* +/_sqldata/* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000..fbfc52f41 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,66 @@ +# This script runs on gitlab.ebi.ac.uk + +image: ebiwd/alpine-ssh + +variables: + # project specific variables can be defined here + GIT_SUBMODULE_STRATEGY: recursive + SSH_OWNER_ID: wd_drupl + SSH_APACHE_ID: w3_wd01 + S3_BUCKET_DEV: origin.dev.vfwp.emblstatic.net + S3_BUCKET_PROD: origin.vfwp.emblstatic.net + # set secrets in Settings -> Pipelines -> Secret Variables + SSH_OWNER_KEY: secret-key + SSH_APACHE_KEY: secret-key + AWS_KEY: key + AWS_SECRET: secret-key + +stages: + - build + - deploy + +build: + stage: build + tags: + - docker + script: + - apk update && apk add zip && apk add unzip + - mkdir -pv data_sync + - cd wp-content/plugins/ + - zip -r $CI_PROJECT_DIR/data_sync/plugins.zip . + - cd $CI_PROJECT_DIR/wp-content/themes/ + - zip -r $CI_PROJECT_DIR/data_sync/themes.zip . + artifacts: + paths: + - data_sync/ + +deploy-dev-aws: + stage: deploy + image: ebiwd/alpine-ssh + tags: + - docker + before_script: + - add-aws-key ${AWS_KEY} ${AWS_SECRET} + dependencies: + - build + script: + - bin/deploy-aws + only: + # only match on develop branch, or specific tag patterns + - develop + - /^v\d+\.\d+\.\d+$/ + - /^v\d+\.\d+\.\d+-(alpha|beta|rc)\.\d+$/ + +#deploy-aws-prod: +# stage: deploy +# image: ebiwd/alpine-ssh +# tags: +# - docker +# before_script: +# - add-aws-key ${AWS_KEY} ${AWS_SECRET} +# script: +# - bin/deploy-aws prod +# only: +# # only match on specific tag patterns +# - /^v\d+\.\d+\.\d+$/ +# - /^v\d+\.\d+\.\d+-(alpha|beta|rc)\.\d+$/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..51e23a6a8 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "bin"] + path = bin + url = git@gitlab.ebi.ac.uk:ebiwd/wordpress-bin.git diff --git a/bin b/bin new file mode 160000 index 000000000..77ad4b9b3 --- /dev/null +++ b/bin @@ -0,0 +1 @@ +Subproject commit 77ad4b9b36bfb0a6451e4652d0e11891eb988f20 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100755 index 000000000..fa4bd36a7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,78 @@ +version: "2" + +services: + mysql: + image: wodby/mariadb:${MARIADB_TAG} + container_name: "${PROJECT_NAME}_mariadb" + stop_grace_period: 30s + environment: + MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD} + MYSQL_DATABASE: ${DOCKER_DATABASE} + MYSQL_USER: ${DOCKER_DATABASE_USER} + MYSQL_PASSWORD: ${DOCKER_DATABASE_PASS} + volumes: + - ${LOCAL_CORE_PATH}/${RELATIVE_SQLDATA_SRC}:/var/lib/mysql # I want to manage volumes manually. + + php: + depends_on: + - mysql + image: ebiwd/php7-apache-wptools:latest + container_name: "${PROJECT_NAME}_php" + environment: + PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025 + DB_HOST: 'mysql' + DB_USER: ${DOCKER_DATABASE_USER} + DB_PASSWORD: ${DOCKER_DATABASE_PASS} + DB_NAME: ${DOCKER_DATABASE} + APACHE_LOG_LEVEL: debug + APACHE_BACKEND_HOST: php + APACHE_DOCUMENT_ROOT: ${VM_CORE_PATH}/${RELATIVE_DOCUMENT_ROOT} + volumes: + - ${LOCAL_CORE_PATH}/:${VM_CORE_PATH} + labels: + - 'traefik.backend=apache' + - 'traefik.port=80' + - 'traefik.frontend.rule=Host:${PROJECT_NAME}.docker.localhost' + + mailhog: + image: mailhog/mailhog + container_name: "${PROJECT_NAME}_mailhog" + labels: + - 'traefik.backend=mailhog' + - 'traefik.port=8025' + - 'traefik.frontend.rule=Host:mailhog.${PROJECT_NAME}.docker.localhost' + + pma: + image: phpmyadmin/phpmyadmin + container_name: "${PROJECT_NAME}_pma" + environment: + PMA_HOST: mysql + PMA_USER: root + PMA_PASSWORD: ${DB_ROOT_PASSWORD} + PHP_UPLOAD_MAX_FILESIZE: 1G + PHP_MAX_INPUT_VARS: 1G + labels: + - 'traefik.backend=pma' + - 'traefik.port=80' + - 'traefik.frontend.rule=Host:pma.${PROJECT_NAME}.docker.localhost' + + portainer: + image: portainer/portainer + container_name: "${PROJECT_NAME}_portainer" + command: --no-auth -H unix:///var/run/docker.sock + volumes: + - /var/run/docker.sock:/var/run/docker.sock + labels: + - 'traefik.backend=portainer' + - 'traefik.port=9000' + - 'traefik.frontend.rule=Host:portainer.${PROJECT_NAME}.docker.localhost' + + traefik: + image: traefik + container_name: "${PROJECT_NAME}_traefik" + command: -c /dev/null --web --docker --logLevel=INFO + ports: + - '80' + - '8080' # Dashboard + volumes: + - /var/run/docker.sock:/var/run/docker.sock