Skip to content

Commit 1b983e7

Browse files
committed
chore: Update Dockerfile to use node:18.18.0-buster-slim as builder and production images
1 parent ee19738 commit 1b983e7

File tree

4 files changed

+35
-16
lines changed

4 files changed

+35
-16
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ jobs:
108108
# - run: node-prune
109109

110110
- name: Build
111-
run: pkg dist/main.js -o sesame-daemon --targets linux,macos,win -C Brotli
111+
run: pkg dist/main.js -o sesame-daemon --targets linux,macos,win -C Brotli --config package.json
112112

113113
- name: Upload Build Artifact
114114
uses: actions/upload-artifact@v3

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:18-bookworm-slim as builder
1+
FROM node:18.18.0-buster-slim as builder
22

33
ENV TIMEZONE=Europe/Paris \
44
LANGUAGE=fr_FR.UTF-8 \
@@ -18,7 +18,7 @@ RUN yarn install \
1818

1919
RUN yarn run build
2020

21-
FROM node:18-bookworm-slim as production
21+
FROM node:18.18.0-buster-slim as production
2222

2323
ENV TIMEZONE=Europe/Paris \
2424
LANGUAGE=fr_FR.UTF-8 \
@@ -36,7 +36,7 @@ ADD *.lock .
3636

3737
RUN apt clean -y \
3838
&& apt update -y \
39-
&& apt upgrade -y \
39+
# && apt upgrade -y \
4040
&& apt install -y locales \
4141
&& export LANGUAGE=${LANGUAGE} \
4242
&& export LANG=${LANG} \
@@ -59,6 +59,8 @@ RUN yarn install \
5959
# && yarn autoclean --init \
6060
# && yarn autoclean --force
6161

62+
RUN npm i -g pkg
63+
6264
COPY --from=builder /data/dist ./dist
6365

6466
CMD ["yarn", "run", "start:prod"]

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ IMG_NAME = "ghcr.io/libertech-fr/sesame-deamon"
33
BASE_NAME = "sesame"
44
APP_NAME = "sesame-daemon"
55
PLATFORM = "linux/amd64"
6+
PKG_TARGETS = "linux,macos,win"
67

78
.DEFAULT_GOAL := help
89
help:
@@ -44,6 +45,25 @@ exec: ## Run a shell in the container
4445
-v $(CURDIR):/data \
4546
$(IMG_NAME) sh
4647

48+
pkg: ## Package the application
49+
@rm sesame-daemon-* || true
50+
@docker run -it --rm \
51+
-e NODE_ENV=development \
52+
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
53+
--add-host host.docker.internal:host-gateway \
54+
--platform $(PLATFORM) \
55+
--network dev \
56+
-v $(CURDIR):/data \
57+
$(IMG_NAME) yarn build
58+
@docker run -it --rm \
59+
-e NODE_ENV=development \
60+
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
61+
--add-host host.docker.internal:host-gateway \
62+
--platform $(PLATFORM) \
63+
--network dev \
64+
-v $(CURDIR):/data \
65+
$(IMG_NAME) pkg dist/main.js -o sesame-daemon-macos --targets $(PKG_TARGETS) --config package.json
66+
4767
dbs: ## Start databases
4868
@docker volume create $(BASE_NAME)-mongodb
4969
@docker run -d --rm \

src/backend-runner/backend-runner.service.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ import { ActionType } from './_enum/action-type.enum';
1010
import { ExecutorConfigInterface } from '~/_common/interfaces/executor-config.interface';
1111
import Redis from 'ioredis';
1212
import { DumpPackageConfigExecutor } from './_executors/dump-package-config.executor';
13-
// import { PackageJson } from 'types-package-json';
1413
import { readFileSync } from 'node:fs';
15-
//import { PackageJson } from 'types-package-json';
16-
//import { readFileSync } from 'node:fs';
14+
import { PackageJson } from 'types-package-json';
1715

1816
@Injectable()
1917
export class BackendRunnerService implements OnApplicationBootstrap, OnModuleInit {
20-
protected _package: Partial<any>;
18+
protected _package: Partial<PackageJson | object>;
2119
private readonly _logger = new Logger(BackendRunnerService.name);
2220

2321
protected executors: Map<string, ExecutorInterface> = new Map<string, ExecutorInterface>();
@@ -30,7 +28,7 @@ export class BackendRunnerService implements OnApplicationBootstrap, OnModuleIni
3028
return this._logger;
3129
}
3230

33-
public get packageJson(): Partial<any> {
31+
public get packageJson(): Partial<PackageJson | object> {
3432
return this._package;
3533
}
3634

@@ -43,14 +41,13 @@ export class BackendRunnerService implements OnApplicationBootstrap, OnModuleIni
4341
private readonly _backendsConfig: BackendConfigService,
4442
@InjectRedis() private readonly redis: Redis,
4543
) {
46-
console.log('pkg', (process as any).pkg)
4744
this._package = {};
48-
// try {
49-
// this._package = JSON.parse(readFileSync('package.json', 'utf-8'));
50-
// } catch (e) {
51-
// this._logger.error('Error reading package.json file: ', e);
52-
// this._package = {};
53-
// }
45+
try {
46+
this._package = JSON.parse(readFileSync('package.json', 'utf-8'));
47+
} catch (e) {
48+
this._logger.error('Error reading package.json file: ', e);
49+
this._package = {};
50+
}
5451
}
5552

5653
public async onModuleInit() {

0 commit comments

Comments
 (0)