Skip to content

Commit

Permalink
Added local & CI Deployment scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandeep Kadam committed Apr 24, 2019
1 parent fb7b2bf commit bb81177
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -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="[email protected]"

# 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ Desktop.ini
node_modules
.sass-cache
*.log
/dist/*
/_sqldata/*
66 changes: 66 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -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+$/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "bin"]
path = bin
url = [email protected]:ebiwd/wordpress-bin.git
1 change: 1 addition & 0 deletions bin
Submodule bin added at 77ad4b
78 changes: 78 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bb81177

Please sign in to comment.