Skip to content

Commit

Permalink
Add support for local s3 and tachyon
Browse files Browse the repository at this point in the history
  • Loading branch information
joehoyle committed Mar 15, 2019
1 parent 14301bb commit 8577d7a
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 24 deletions.
128 changes: 104 additions & 24 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,44 @@
version: '2.3'

x-php: &php
init: true
depends_on:
- db
- redis
- elasticsearch
- xray
image: humanmade/php
networks:
- proxy
links:
- "db:db-read-replica"
- "s3:s3-${COMPOSE_PROJECT_NAME:-default}.s3.localhost"
volumes:
- "${VOLUME}:/usr/src/app:delegated"
environment:
DB_HOST: db
DB_READ_REPLICA_HOST: db-read-replica
DB_PASSWORD: wordpress
DB_NAME: wordpress
DB_USER: wordpress
REDIS_HOST: redis
REDIS_PORT: 6379
WP_DEBUG: 1
WP_DEBUG_DISPLAY: 0
PAGER: more
HM_ENV_ARCHITECTURE: 'ecs'
HM_DEPLOYMENT_REVISION: 'dev'
ELASTICSEARCH_HOST: elasticsearch
ELASTICSEARCH_PORT: 9200
AWS_XRAY_DAEMON_HOST: xray
S3_UPLOADS_ENDPOINT: http://s3.localhost:8000/
S3_UPLOADS_BUCKET: s3-${COMPOSE_PROJECT_NAME:-default}
S3_UPLOADS_BUCKET_URL: http://s3-${COMPOSE_PROJECT_NAME:-default}.hmdocker
S3_UPLOADS_KEY: not-needed
S3_UPLOADS_SECRET: not-needed
S3_UPLOADS_REGION: not-needed
TACHYON_URL: http://tachyon-${COMPOSE_PROJECT_NAME:-default}.hmdocker/uploads

services:
db:
image: mysql:5.7
Expand All @@ -20,32 +60,9 @@ services:
ports:
- '6379'
php:
init: true
depends_on:
- db
- redis
image: humanmade/php
<<: *php
ports:
- '9000'
networks:
- proxy
links:
- "db:db-read-replica"
volumes:
- "${VOLUME}:/usr/src/app:delegated"
environment:
DB_HOST: db
DB_READ_REPLICA_HOST: db-read-replica
DB_PASSWORD: wordpress
DB_NAME: wordpress
DB_USER: wordpress
REDIS_HOST: redis
REDIS_PORT: 6379
WP_DEBUG: 1
WP_DEBUG_DISPLAY: 0
PAGER: more
HM_ENV_ARCHITECTURE: 'ecs'
HM_ENV: "${COMPOSE_PROJECT_NAME}"
nginx:
image: humanmade/nginx
networks:
Expand All @@ -61,6 +78,67 @@ services:
- "traefik.protocol=https"
- "traefik.docker.network=proxy"
- "traefik.frontend.rule=HostRegexp:${COMPOSE_PROJECT_NAME:-default}.hmdocker,{subdomain:[a-z.-_]+}.${COMPOSE_PROJECT_NAME:-default}.hmdocker"
xray:
image: amazon/aws-xray-daemon
ports:
- 2000
environment:
AWS_ACCESS_KEY_ID: YOUR_KEY_HERE
AWS_SECRET_ACCESS_KEY: YOUR_SECRET_HERE
AWS_REGION: us-east-1
networks:
- proxy
cavalcade:
<<: *php
entrypoint:
- /usr/local/bin/cavalcade
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.5.4
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- es-data:/usr/share/elasticsearch/data
ports:
- "9200"
networks:
- proxy
labels:
- "traefik.port=9200"
- "traefik.protocol=http"
- "traefik.docker.network=proxy"
- "traefik.frontend.rule=HostRegexp:elasticsearch.${COMPOSE_PROJECT_NAME:-default}.hmdocker,{subdomain:[a-z.-_]+}.${COMPOSE_PROJECT_NAME:-default}.hmdocker"
s3:
image: fingershock/fakes3
volumes:
- "s3:/fakes3_data:rw"
ports:
- "8000"
networks:
- proxy
labels:
- "traefik.port=8000"
- "traefik.protocol=http"
- "traefik.docker.network=proxy"
- "traefik.frontend.rule=HostRegexp:s3-${COMPOSE_PROJECT_NAME:-default}.hmdocker"
tachyon:
image: humanmade/tachyon
ports:
- "8081:8080"
networks:
- proxy
labels:
- "traefik.port=8080"
- "traefik.protocol=http"
- "traefik.docker.network=proxy"
- "traefik.frontend.rule=HostRegexp:tachyon-${COMPOSE_PROJECT_NAME:-default}.hmdocker"
environment:
AWS_REGION: not-needed
AWS_S3_BUCKET: s3-${COMPOSE_PROJECT_NAME:-default}
AWS_S3_ENDPOINT: http://s3.localhost:8000/
links:
- "s3:s3.localhost"

networks:
proxy:
Expand All @@ -69,4 +147,6 @@ networks:

volumes:
db-data:
es-data:
tmp:
s3:
2 changes: 2 additions & 0 deletions inc/Composer/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ protected function execute( InputInterface $input, OutputInterface $output ) {
}

$proxy = new Process( 'docker-compose -f proxy.yml up', 'vendor/humanmade/local-server/docker' );
$proxy->setTimeout( 0 );
$proxy->start();

$compose = new Process( 'docker-compose up', 'vendor/humanmade/local-server/docker', [
'VOLUME' => getcwd(),
'COMPOSE_PROJECT_NAME' => basename( getcwd() ),
] );
$compose->setTimeout( 0 );

$compose->start( function ( $type, $buffer ) {
echo $buffer;
Expand Down
16 changes: 16 additions & 0 deletions wp-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,26 @@
define( 'ELASTICSEARCH_HOST', getenv( 'ELASTICSEARCH_HOST' ) );
define( 'ELASTICSEARCH_PORT', getenv( 'ELASTICSEARCH_PORT' ) );

define( 'S3_UPLOADS_BUCKET', getenv( 'S3_UPLOADS_BUCKET' ) );
define( 'S3_UPLOADS_REGION', getenv( 'S3_UPLOADS_REGION' ) );
define( 'S3_UPLOADS_KEY', getenv( 'S3_UPLOADS_KEY' ) );
define( 'S3_UPLOADS_SECRET', getenv( 'S3_UPLOADS_SECRET' ) );
define( 'S3_UPLOADS_ENDPOINT', getenv( 'S3_UPLOADS_ENDPOINT' ) );
define( 'S3_UPLOADS_BUCKET_URL', getenv( 'S3_UPLOADS_BUCKET_URL' ) );

define( 'TACHYON_URL', getenv( 'TACHYON_URL' ) );

global $redis_server;
$redis_server = [
'host' => getenv( 'REDIS_HOST' ),
'port' => getenv( 'REDIS_PORT' ),
];

ini_set( 'display_errors', 'on' );

add_filter( 's3_uploads_s3_client_params', function ( $params ) {
if ( defined( 'S3_UPLOADS_ENDPOINT' ) ) {
$params['endpoint'] = S3_UPLOADS_ENDPOINT;
}
return $params;
}, 5, 1 );

0 comments on commit 8577d7a

Please sign in to comment.