Skip to content

Commit

Permalink
Brand version into source code
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusklocke committed Dec 11, 2023
1 parent a874c3b commit f5cffdf
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 3 additions & 1 deletion docker/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ WORKDIR ${APP_HOME}
# Install dependencies first
COPY composer.lock composer.json ./
RUN composer install --optimize-autoloader --no-cache --no-dev --no-progress
RUN echo "$APP_VERSION" > VERSION

# Install own application sources
COPY templates templates/
Expand All @@ -51,6 +50,9 @@ COPY migrations migrations/
COPY config config/
COPY bin bin/

# Apply version branding
RUN sed -i "s/APP_VERSION=development/APP_VERSION=$APP_VERSION/" src/init.php

# Configure ownership and permissions
RUN chown -R www-data:www-data ${APP_HOME} && chmod +x bin/*
USER www-data
Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/CLI/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct()

parent::__construct(
'Liga-Manager',
$this->container->get('version')
getenv('APP_VERSION') ?: 'development'
);

foreach ($this->getOwnCommands() as $command) {
Expand Down
3 changes: 0 additions & 3 deletions src/Infrastructure/ContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ class ContainerBuilder
*/
public static function build(array $serviceProviders): ContainerInterface
{
$versionFilePath = join(DIRECTORY_SEPARATOR, [getenv('APP_HOME'), 'VERSION']);

$builder = new DI\ContainerBuilder();
$builder->useAutowiring(true);
$builder->addDefinitions(['version' => @file_get_contents($versionFilePath) ?: 'development']);

foreach ($serviceProviders as $provider) {
$builder->addDefinitions($provider->getDefinitions());
Expand Down
1 change: 1 addition & 0 deletions src/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_once __DIR__ . '/../vendor/autoload.php';

putenv("APP_HOME=" . realpath(join(DIRECTORY_SEPARATOR, [__DIR__ , '..'])));
putenv("APP_VERSION=development");

switch (php_sapi_name()) {
case 'fpm-fcgi':
Expand Down

0 comments on commit f5cffdf

Please sign in to comment.