Skip to content

Commit

Permalink
Add env variable APP_LOGOS_PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusklocke committed Dec 3, 2023
1 parent 8027093 commit df452ae
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ by the application. Static values must be supplied from the outside (e.g. by usi
| ADMIN_EMAIL | Static | Email address for default admin user |
| ADMIN_PASSWORD | Static | Password for default admin user |
| APP_HOME | Dynamic | Path to application home directory |
| APP_LOGOS_PATH | Dynamic | Path to directory for logos |
| EMAIL_SENDER_ADDRESS | Static | Sender address for outbound emails |
| EMAIL_SENDER_NAME | Static | Sender name for outbound emails |
| EMAIL_URL | Static | URL to use for outbound emails (gateway) |
Expand Down
7 changes: 6 additions & 1 deletion docker/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ COPY docker/php/php.ini /usr/local/etc/php/php.ini
COPY docker/php/entrypoint.sh /usr/local/bin/docker-php-entrypoint
RUN chmod +x /usr/local/bin/docker-php-entrypoint

# Prepare application source directory
# Prepare logos directory
ENV APP_LOGOS_PATH="/var/www/logos"
RUN mkdir ${APP_LOGOS_PATH}

# Prepare application directory
ENV APP_HOME="/var/www/api"
RUN mkdir ${APP_HOME}
WORKDIR ${APP_HOME}
Expand All @@ -57,6 +61,7 @@ COPY bin bin/

# Configure ownership and permissions
RUN chown -R www-data:www-data ${APP_HOME} && chmod +x bin/*
RUN chown www-data:www-data ${APP_LOGOS_PATH}
ENV PATH="${PATH}:${APP_HOME}/bin:${APP_HOME}/vendor/bin"

CMD lima migrations:migrate -n && php-fpm
11 changes: 10 additions & 1 deletion src/Infrastructure/API/Logos/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@

use HexagonalPlayground\Application\ServiceProviderInterface;
use DI;
use HexagonalPlayground\Infrastructure\Config;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;

class ServiceProvider implements ServiceProviderInterface
{
public function getDefinitions(): array
{
return [
UploadAction::class => DI\autowire()
UploadAction::class => DI\factory(function (ContainerInterface $container) {
return new UploadAction(
Config::getInstance()->appLogosPath,
'/logos',
$container->get(LoggerInterface::class)
);
})
];
}
}
6 changes: 3 additions & 3 deletions src/Infrastructure/API/Logos/UploadAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class UploadAction implements ActionInterface
private string $publicBasePath;
private LoggerInterface $logger;

public function __construct(LoggerInterface $logger)
public function __construct(string $storageBasePath, string $publicBasePath, LoggerInterface $logger)
{
$this->storageBasePath = '/var/www/logos';
$this->publicBasePath = '/logos';
$this->storageBasePath = $storageBasePath;
$this->publicBasePath = $publicBasePath;
$this->logger = $logger;
}

Expand Down
2 changes: 2 additions & 0 deletions src/Infrastructure/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Config
public string $adminEmail;
public string $adminPassword;
public string $appHome;
public string $appLogosPath;
public string $emailSenderAddress;
public string $emailSenderName;
public string $emailUrl;
Expand All @@ -27,6 +28,7 @@ private function __construct()
$this->adminEmail = getenv('ADMIN_EMAIL') ?: '';
$this->adminPassword = getenv('ADMIN_PASSWORD') ?: '';
$this->appHome = getenv('APP_HOME') ?: '';
$this->appLogosPath = getenv('APP_LOGOS_PATH') ?: '';
$this->emailSenderAddress = getenv('EMAIL_SENDER_ADDRESS') ?: 'noreply@example.com';
$this->emailSenderName = getenv('EMAIL_SENDER_NAME') ?: 'No Reply';
$this->emailUrl = getenv('EMAIL_URL') ?: 'null://localhost';
Expand Down

0 comments on commit df452ae

Please sign in to comment.