Skip to content

Commit

Permalink
refactor(server): build support env (immich-app#13163)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasm91 authored Oct 3, 2024
1 parent 3ddb5b8 commit 0eb7714
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 18 deletions.
16 changes: 0 additions & 16 deletions server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,19 +408,3 @@ export const clsConfig: ClsModuleOptions = {
},
},
};

export const getBuildMetadata = () => ({
build: process.env.IMMICH_BUILD,
buildUrl: process.env.IMMICH_BUILD_URL,
buildImage: process.env.IMMICH_BUILD_IMAGE,
buildImageUrl: process.env.IMMICH_BUILD_IMAGE_URL,
repository: process.env.IMMICH_REPOSITORY,
repositoryUrl: process.env.IMMICH_REPOSITORY_URL,
sourceRef: process.env.IMMICH_SOURCE_REF,
sourceCommit: process.env.IMMICH_SOURCE_COMMIT,
sourceUrl: process.env.IMMICH_SOURCE_URL,
thirdPartySourceUrl: process.env.IMMICH_THIRD_PARTY_SOURCE_URL,
thirdPartyBugFeatureUrl: process.env.IMMICH_THIRD_PARTY_BUG_FEATURE_URL,
thirdPartyDocumentationUrl: process.env.IMMICH_THIRD_PARTY_DOCUMENTATION_URL,
thirdPartySupportUrl: process.env.IMMICH_THIRD_PARTY_SUPPORT_URL,
});
16 changes: 16 additions & 0 deletions server/src/interfaces/config.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ export interface EnvData {
configFile?: string;
logLevel?: LogLevel;

buildMetadata: {
build?: string;
buildUrl?: string;
buildImage?: string;
buildImageUrl?: string;
repository?: string;
repositoryUrl?: string;
sourceRef?: string;
sourceCommit?: string;
sourceUrl?: string;
thirdPartySourceUrl?: string;
thirdPartyBugFeatureUrl?: string;
thirdPartyDocumentationUrl?: string;
thirdPartySupportUrl?: string;
};

database: {
skipMigrations: boolean;
vectorExtension: VectorExtension;
Expand Down
17 changes: 17 additions & 0 deletions server/src/repositories/config.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ export class ConfigRepository implements IConfigRepository {
environment,
configFile: process.env.IMMICH_CONFIG_FILE,
logLevel: process.env.IMMICH_LOG_LEVEL as LogLevel,

buildMetadata: {
build: process.env.IMMICH_BUILD,
buildUrl: process.env.IMMICH_BUILD_URL,
buildImage: process.env.IMMICH_BUILD_IMAGE,
buildImageUrl: process.env.IMMICH_BUILD_IMAGE_URL,
repository: process.env.IMMICH_REPOSITORY,
repositoryUrl: process.env.IMMICH_REPOSITORY_URL,
sourceRef: process.env.IMMICH_SOURCE_REF,
sourceCommit: process.env.IMMICH_SOURCE_COMMIT,
sourceUrl: process.env.IMMICH_SOURCE_URL,
thirdPartySourceUrl: process.env.IMMICH_THIRD_PARTY_SOURCE_URL,
thirdPartyBugFeatureUrl: process.env.IMMICH_THIRD_PARTY_BUG_FEATURE_URL,
thirdPartyDocumentationUrl: process.env.IMMICH_THIRD_PARTY_DOCUMENTATION_URL,
thirdPartySupportUrl: process.env.IMMICH_THIRD_PARTY_SUPPORT_URL,
},

database: {
skipMigrations: process.env.DB_SKIP_MIGRATIONS === 'true',
vectorExtension: getVectorExtension(),
Expand Down
3 changes: 1 addition & 2 deletions server/src/services/server.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BadRequestException, Injectable, NotFoundException } from '@nestjs/common';
import { getBuildMetadata } from 'src/config';
import { serverVersion } from 'src/constants';
import { StorageCore } from 'src/cores/storage.core';
import { OnEvent } from 'src/decorators';
Expand Down Expand Up @@ -36,7 +35,7 @@ export class ServerService extends BaseService {

async getAboutInfo(): Promise<ServerAboutResponseDto> {
const version = `v${serverVersion.toString()}`;
const buildMetadata = getBuildMetadata();
const { buildMetadata } = this.configRepository.getEnv();
const buildVersions = await this.serverInfoRepository.getBuildVersions();
const licensed = await this.systemMetadataRepository.get(SystemMetadataKey.LICENSE);

Expand Down
2 changes: 2 additions & 0 deletions server/test/repositories/config.repository.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const envData: EnvData = {
port: 3001,
environment: ImmichEnvironment.PRODUCTION,

buildMetadata: {},

database: {
skipMigrations: false,
vectorExtension: DatabaseExtension.VECTORS,
Expand Down

0 comments on commit 0eb7714

Please sign in to comment.