Skip to content

Commit

Permalink
publish 'wordpress' harness
Browse files Browse the repository at this point in the history
  • Loading branch information
kierenevans committed Aug 19, 2020
1 parent 46858dd commit c591f12
Show file tree
Hide file tree
Showing 152 changed files with 4,910 additions and 0 deletions.
109 changes: 109 additions & 0 deletions _twig/docker-compose.yml/application.yml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{% set blocks = '_twig/docker-compose.yml/' %}
{% set syncvolume = false %}
{% if @('host.os') == 'darwin' and @('docker-sync') == 'yes' %}
{% set syncvolume = true %}
{% elseif @('host.os') == 'darwin' and @('mutagen') == 'yes' %}
{% set syncvolume = true %}
{% endif %}
{% set hostnames = [@('hostname')] %}
{% set hostnames = hostnames|merge(@('hostname_aliases')|map(alias => "#{alias}." ~ @('domain'))) %}

console:
build:
context: ./
dockerfile: .my127ws/docker/image/console/Dockerfile
{% if @('app.build') == 'dynamic' %}
entrypoint: [/entrypoint.dynamic.sh]
command: [sleep, infinity]
volumes:
- {{ (syncvolume) ? @('workspace.name') ~ '-sync:/app:nocopy' : ('./:/app' ~ @('docker.compose.host_volume_options')) }}
- ./.my127ws/application:/home/build/application
- ./.my127ws/docker/image/console/root/lib/task:/lib/task
- ./.my127ws:/.my127ws
{% else %}
image: {{ @('docker.repository') ~ ':' ~ @('app.version') ~ '-console' }}
{% endif %}
labels:
- traefik.enable=false
environment: {{ to_nice_yaml(deep_merge([
@('services.php-base.environment'),
@('services.console.environment'),
@('services.php-base.environment_secrets'),
@('services.console.environment_secrets')
]), 2, 6) | raw }}
{% include blocks ~ 'environment.yml.twig' %}
networks:
- private

nginx:
build: .my127ws/docker/image/nginx
{% if @('app.build') == 'dynamic' %}
volumes:
- {{ (syncvolume) ? @('workspace.name') ~ '-sync:/app:nocopy' : ('./:/app' ~ @('docker.compose.host_volume_options')) }}
{% else %}
image: {{ @('docker.repository') ~ ':' ~ @('app.version') ~ '-nginx' }}
{% endif %}
labels:
{% if 'varnish' not in @('app.services') %}
- traefik.backend={{ @('workspace.name') }}
- traefik.frontend.rule=Host:{{ hostnames|join(',') }}
- traefik.docker.network=my127ws
- traefik.port=80
{% else %}
- traefik.enable=false
{% endif %}
environment: {{ to_nice_yaml(deep_merge([
@('services.nginx.environment'),
@('services.nginx.environment_secrets')
]), 2, 6) | raw }}
links:
- php-fpm:php-fpm
networks:
{% if 'varnish' not in @('app.services') %}
private:
aliases:
{% for alias in hostnames %}
- {{ alias }}
{% endfor %}
{% else %}
private: {}
{% endif %}
shared: {}

php-fpm:
build: .my127ws/docker/image/php-fpm
{% if @('app.build') == 'dynamic' %}
{% if ("cron" in @('app.services')) %}
image: {{ @('workspace.name') ~ '-php-fpm:dev' }}
{% endif %}
volumes:
- {{ (syncvolume) ? @('workspace.name') ~ '-sync:/app:nocopy' : ('./:/app' ~ @('docker.compose.host_volume_options')) }}
- ./.my127ws:/.my127ws
{% else %}
image: {{ @('docker.repository') ~ ':' ~ @('app.version') ~ '-php-fpm' }}
{% endif %}
labels:
- traefik.enable=false
networks:
- private
environment: {{ to_nice_yaml(deep_merge([
@('services.php-base.environment'),
@('services.php-fpm.environment'),
@('services.php-base.environment_secrets'),
@('services.php-fpm.environment_secrets')
]), 2, 6) | raw }}
{% include blocks ~ 'environment.yml.twig' %}
expose:
{% for pool in @('php-fpm.pools') %}
- {{ pool.port }}
{% endfor %}

relay:
build: .my127ws/docker/image/relay
labels:
- traefik.enable=false
networks:
private:
aliases:
- mailhog-relay
shared: {}
Empty file.
7 changes: 7 additions & 0 deletions _twig/docker-compose.yml/service/chrome.yml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
chrome:
image: yukinying/chrome-headless-browser:latest
command: ["--no-sandbox", "--disable-gpu", "--headless", "--disable-dev-shm-usage", "--remote-debugging-address=0.0.0.0", "--remote-debugging-port=9222", "--user-data-dir=/data"]
labels:
- traefik.enable=false
networks:
- private
22 changes: 22 additions & 0 deletions _twig/docker-compose.yml/service/cron.yml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cron:
build:
context: ./
dockerfile: .my127ws/docker/image/cron/Dockerfile
{% if @('app.build') == 'dynamic' %}
volumes:
- {{ (syncvolume) ? @('workspace.name') ~ '-sync:/app:nocopy' : ('./:/app' ~ @('docker.compose.host_volume_options')) }}
- ./.my127ws/application:/home/build/application
{% else %}
image: {{ @('docker.repository') ~ ':' ~ @('app.version') ~ '-cron' }}
{% endif %}
environment: {{ to_nice_yaml(deep_merge([
@('services.php-base.environment'),
@('services.cron.environment'),
@('services.php-base.environment_secrets'),
@('services.cron.environment_secrets')
]), 2, 6) | raw }}
{% include blocks ~ 'environment.yml.twig' %}
networks:
- private
labels:
- traefik.enable=false
12 changes: 12 additions & 0 deletions _twig/docker-compose.yml/service/elasticsearch.yml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
elasticsearch:
image: {{ @('elasticsearch.image') }}:{{ @('elasticsearch.tag') }}
labels:
- traefik.enable=false
environment:
ES_JAVA_OPTS: -Xms512m -Xmx512m
discovery.type: single-node
networks:
- private
ports:
- 9200
- 9300
6 changes: 6 additions & 0 deletions _twig/docker-compose.yml/service/memcached.yml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
memcached:
image: memcached:1-alpine
labels:
- traefik.enable=false
networks:
- private
19 changes: 19 additions & 0 deletions _twig/docker-compose.yml/service/mysql.yml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% set command = [] %}
{% for var,value in @('database.var') -%}
{% set command = command|merge(['--' ~ var ~ '=' ~ value]) %}
{% endfor %}
mysql:
image: {{ @('mysql.image') }}:{{ @('mysql.tag') }}
labels:
- traefik.enable=false
{% if command|length %}
command: {{ command|join(' ') }}
{% endif %}
environment: {{ to_nice_yaml(deep_merge([
@('services.mysql.environment'),
@('services.mysql.environment_secrets')
]), 2, 6) | raw }}
networks:
- private
ports:
- {% if @('database.port_forward') %}{{ @('database.port_forward') }}:{% endif %}3306
12 changes: 12 additions & 0 deletions _twig/docker-compose.yml/service/php-fpm-exporter.yml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
php-fpm-exporter:
image: hipages/php-fpm_exporter
environment: {{ to_nice_yaml(deep_merge([
@('services.php-fpm-exporter.environment'),
@('services.php-fpm-exporter.environment_secrets')
]), 2, 6) | raw }}
labels:
- traefik.enable=false
depends_on:
- php-fpm
networks:
- private
12 changes: 12 additions & 0 deletions _twig/docker-compose.yml/service/postgres.yml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
postgres:
image: postgres:9.6
labels:
- traefik.enable=false
environment: {{ to_nice_yaml(deep_merge([
@('services.postgres.environment'),
@('services.postgres.environment_secrets')
]), 2, 6) | raw }}
networks:
- private
ports:
- 5432
16 changes: 16 additions & 0 deletions _twig/docker-compose.yml/service/rabbitmq.yml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
rabbitmq:
image: {{ @('rabbitmq.image') }}:{{ @('rabbitmq.tag') }}
environment: {{ to_nice_yaml(deep_merge([
@('services.rabbitmq.environment'),
@('services.rabbitmq.environment_secrets')
]), 2, 6) | raw }}
networks:
- private
- shared
labels:
- traefik.backend={{ @('rabbitmq.host') }}-{{ @('workspace.name') }}
- traefik.frontend.rule=Host:{{ @('rabbitmq.external_host') }}
- traefik.docker.network=my127ws
- traefik.port={{ @('rabbitmq.api_port') }}
- co.elastic.logs/module=rabbitmq
- co.elastic.metrics/module=rabbitmq
8 changes: 8 additions & 0 deletions _twig/docker-compose.yml/service/redis-session.yml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
redis-session:
image: redis:4-alpine
# 1GB; evict key that would expire soonest
command: redis-server --maxmemory 1073742000 --maxmemory-policy volatile-ttl --save 3600 1 --save 300 100 --save 60 10000
labels:
- traefik.enable=false
networks:
- private
8 changes: 8 additions & 0 deletions _twig/docker-compose.yml/service/redis.yml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
redis:
image: redis:4-alpine
# 1GB; evict any least recently used key even if they don't have a TTL
command: redis-server --maxmemory 1073742000 --maxmemory-policy allkeys-lru --save 3600 1 --save 300 100 --save 60 10000
labels:
- traefik.enable=false
networks:
- private
49 changes: 49 additions & 0 deletions _twig/docker-compose.yml/service/varnish.yml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{% if 'varnish' in @('app.services') %}
{% set hostnames = [@('hostname')] %}
{% set hostnames = hostnames|merge(@('hostname_aliases')|map(alias => "#{alias}." ~ @('domain'))) %}
varnish:
image: varnish:6
labels:
- traefik.backend={{ @('workspace.name') }}
- traefik.frontend.rule=Host:{{ hostnames|join(',') }}
- traefik.docker.network=my127ws
- traefik.port=80
environment: {{ to_nice_yaml(deep_merge([
@('services.varnish.environment'),
@('services.varnish.environment_secrets')
]), 2, 6) | raw }}
links:
- nginx:nginx
volumes:
- .my127ws/docker/image/varnish/root/etc/varnish/default.vcl:/etc/varnish/default.vcl:ro
- type: tmpfs
target: /var/lib/varnish:exec
tmpfs:
size: "100000"
networks:
private:
aliases:
- varnish-0.varnish-headless
{% if @('replicas.varnish') > 1 %}
{% for instanceNumber in 1..(@('replicas.varnish')-1) %}
- varnish-{{ instanceNumber }}.varnish-headless
{% endfor %}
{% endif %}
shared: {}

# Provide TLS offloading for integration tests via varnish
tls-offload:
build:
context: .my127ws/docker/image/tls-offload/
labels:
- traefik.enable=false
links:
- varnish:varnish
networks:
private:
aliases:
{% for alias in hostnames %}
- {{ alias }}
{% endfor %}
shared: {}
{% endif %}
8 changes: 8 additions & 0 deletions application/overlay/.dockerignore.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% set build = @('app.build') %}
{% set blocks = 'application/overlay/_twig/.dockerignore/' %}

{% if build == 'dynamic' %}
{% include blocks ~ 'dynamic.twig' %}
{% else %}
{% include blocks ~ 'static.twig' %}
{% endif %}
69 changes: 69 additions & 0 deletions application/overlay/Jenkinsfile.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
pipeline {
agent { label "my127ws" }
environment {
MY127WS_KEY = credentials('{{ @('jenkins.credentials.my127ws_key') }}')
MY127WS_ENV = "pipeline"
}
triggers { cron(env.BRANCH_NAME == '{{ @('git.main_branch') }}' ? 'H H(0-6) * * *' : '') }
stages {
stage('Build') {
steps {
sh 'ws install'
milestone(10)
}
}
stage('Checks without development dependencies') {
steps {
sh 'ws exec composer test-production-quality'
sh 'ws exec app composer:development_dependencies'
milestone(20)
}
}
stage('Test') {
parallel {
stage('quality') { steps { sh 'ws exec composer test-quality' } }
stage('unit') { steps { sh 'ws exec composer test-unit' } }
stage('acceptance') { steps { sh 'ws exec composer test-acceptance' } }
stage('helm kubeval qa') { steps { sh 'ws helm kubeval qa' } }
}
}
{% if @('pipeline.publish.enabled') == 'yes' %}
stage('Publish') {
when { not { triggeredBy 'TimerTrigger' } }
steps {
milestone(50)
sh 'ws app publish'
{% if @('pipeline.publish.chart.enabled') %}
sh 'ws app publish chart "${GIT_BRANCH}" "{{ @('workspace.name') }} build artifact ${GIT_COMMIT}"'
{% endif %}
}
}
{% endif %}
{% if @('pipeline.qa.enabled') == 'yes' %}
stage('Deploy (QA)') {
environment {
{% for key, value in @('pipeline.qa.environment') %}
{{ key }} = {{ value|raw }}
{% endfor %}
}
when {
not { triggeredBy 'TimerTrigger' }
branch '{{ @('pipeline.qa.branch') }}'
}
steps {
milestone(100)
lock(resource: '{{ @('workspace.name') }}-qa-deploy', inversePrecedence: true) {
milestone(101)
sh 'ws app deploy qa'
}
}
}
{% endif %}
}
post {
always {
sh 'ws destroy'
cleanWs()
}
}
}
2 changes: 2 additions & 0 deletions application/overlay/_twig/.dockerignore/dynamic.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.my127ws
1 change: 1 addition & 0 deletions application/overlay/_twig/.dockerignore/static.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# no need for exclusions for now
15 changes: 15 additions & 0 deletions application/overlay/auth.json.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"http-basic": {
{% for repo in @('composer.auth.basic') %}
"{{ repo.path }}": {
"username": "{{ repo.username }}",
"password": "{{ repo.password }}"
}{% if not loop.last %},{% endif %}
{% endfor %}
},
"github-oauth": {
{% if @('composer.auth.github') %}
"github.com": "{{ @('composer.auth.github') }}"
{% endif %}
}
}
Loading

0 comments on commit c591f12

Please sign in to comment.