Skip to content

Commit

Permalink
Merge pull request #608 from humanmade/mikelittle/clarify-bucket-name…
Browse files Browse the repository at this point in the history
…-in-docker-compose-file

Clarify the bucket name in the docker-compose file.
  • Loading branch information
mikelittle authored Jul 26, 2023
2 parents f44d1ca + 3f541f1 commit 5d2d1e4
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions inc/composer/class-docker-compose-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ class Docker_Compose_Generator {
*/
protected $project_name;

/**
* The S3 bucket name.
*
* @var string
*/
protected $bucket_name;

/**
* The Altis project root directory.
*
Expand Down Expand Up @@ -75,6 +82,7 @@ class Docker_Compose_Generator {
*/
public function __construct( string $root_dir, string $project_name, string $tld, string $url, array $args = [] ) {
$this->project_name = $project_name;
$this->bucket_name = "s3-{$this->project_name}";
$this->config_dir = dirname( __DIR__, 2 ) . '/docker';
$this->root_dir = $root_dir;
$this->tld = $tld;
Expand Down Expand Up @@ -166,8 +174,8 @@ protected function get_php_reusable() : array {
'ELASTICSEARCH_HOST' => 'elasticsearch',
'ELASTICSEARCH_PORT' => 9200,
'AWS_XRAY_DAEMON_HOST' => 'xray',
'S3_UPLOADS_ENDPOINT' => Command::set_url_scheme( "https://s3-{$this->hostname}/s3-{$this->project_name}/" ),
'S3_UPLOADS_BUCKET' => "s3-{$this->project_name}",
'S3_UPLOADS_ENDPOINT' => Command::set_url_scheme( "https://s3-{$this->hostname}/{$this->bucket_name}/" ),
'S3_UPLOADS_BUCKET' => "{$this->bucket_name}",
'S3_UPLOADS_BUCKET_URL' => Command::set_url_scheme( "https://s3-{$this->hostname}" ),
'S3_UPLOADS_KEY' => 'admin',
'S3_UPLOADS_SECRET' => 'password',
Expand Down Expand Up @@ -554,7 +562,7 @@ protected function get_service_s3() : array {
'traefik.client.port=9000',
'traefik.client.protocol=http',
'traefik.client.frontend.passHostHeader=false',
"traefik.client.frontend.rule=HostRegexp:{$this->hostname},{subdomain:[a-z.-_]+}.{$this->hostname},s3-{$this->hostname},localhost,s3-{$this->project_name}.localhost;PathPrefix:/uploads;AddPrefix:/s3-{$this->project_name}",
"traefik.client.frontend.rule=HostRegexp:{$this->hostname},{subdomain:[a-z.-_]+}.{$this->hostname},s3-{$this->hostname},localhost,s3-{$this->project_name}.localhost;PathPrefix:/uploads;AddPrefix:/{$this->bucket_name}",
"traefik.domain=s3-{$this->hostname},s3-console-{$this->hostname}",
],
],
Expand All @@ -574,7 +582,7 @@ protected function get_service_s3() : array {
'links' => [
's3',
],
'entrypoint' => "/bin/sh -c \"mc mb -p local/s3-{$this->project_name} && mc policy set public local/s3-{$this->project_name} && mc mirror --watch --overwrite -a local/s3-{$this->project_name} /content\"",
'entrypoint' => "/bin/sh -c \"mc mb -p local/{$this->bucket_name} && mc policy set public local/{$this->bucket_name} && mc mirror --watch --overwrite -a local/{$this->bucket_name} /content\"",
],
];
}
Expand Down Expand Up @@ -603,7 +611,7 @@ protected function get_service_tachyon() : array {
],
'environment' => [
'AWS_REGION' => 'us-east-1',
'AWS_S3_BUCKET' => "s3-{$this->project_name}",
'AWS_S3_BUCKET' => "{$this->bucket_name}",
'AWS_S3_ENDPOINT' => Command::set_url_scheme( "https://s3-{$this->hostname}/" ),
'AWS_S3_CLIENT_ARGS' => 's3BucketEndpoint=true',
'NODE_TLS_REJECT_UNAUTHORIZED' => 0,
Expand Down

0 comments on commit 5d2d1e4

Please sign in to comment.