@travetto/pack 3.2.6 → 3.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/__index__.ts CHANGED
@@ -1 +1,2 @@
1
- export type { CommonPackConfig, DockerPackFactory, DockerPackConfig } from './support/bin/types';
1
+ export type { CommonPackConfig, DockerPackFactory, DockerPackConfig } from './support/bin/types';
2
+ export { PackConfigUtil } from './support/bin/config-util';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/pack",
3
- "version": "3.2.6",
3
+ "version": "3.2.7",
4
4
  "description": "Code packing utilities",
5
5
  "keywords": [
6
6
  "travetto",
@@ -0,0 +1,24 @@
1
+ import { DockerPackConfig } from './types';
2
+
3
+ /**
4
+ * Common utils for setting up pack config
5
+ */
6
+ export class PackConfigUtil {
7
+ /**
8
+ * Generate a docker user creation command
9
+ */
10
+ static dockerUserCommand(cfg: DockerPackConfig): string {
11
+ const { user, group, uid, gid } = cfg.dockerRuntimeUser;
12
+ if (user !== 'root') {
13
+ return [
14
+ '',
15
+ `RUN which addgroup && \
16
+ ( addgroup -g ${gid} ${group} && adduser -S -u ${uid} ${user} ${group} ) || \
17
+ ( groupadd -g ${gid} ${group} && useradd -r -u ${uid} -g ${group} ${user} )`,
18
+ `USER ${user}`
19
+ ].join('\n');
20
+ } else {
21
+ return '';
22
+ }
23
+ }
24
+ }
@@ -4,7 +4,6 @@ import { path, RootIndex } from '@travetto/manifest';
4
4
  import { AppError, ExecUtil, ExecutionOptions } from '@travetto/base';
5
5
 
6
6
  import { ActiveShellCommand } from './shell';
7
- import { DockerPackConfig } from './types';
8
7
 
9
8
  export class PackUtil {
10
9
  /**
@@ -78,22 +77,4 @@ export class PackUtil {
78
77
  throw new AppError(stderr || message || 'An unexpected error has occurred');
79
78
  }
80
79
  }
81
-
82
- /**
83
- * Generate a docker user creation command
84
- */
85
- static generateDockerUserCommand(cfg: DockerPackConfig): string {
86
- const { user, group, uid, gid } = cfg.dockerRuntimeUser;
87
- if (user !== 'root') {
88
- return [
89
- '',
90
- `RUN which addgroup && \
91
- ( addgroup -g ${gid} ${group} && adduser -S -u ${uid} ${user} ${group} ) || \
92
- ( groupadd -g ${gid} ${group} && useradd -r -u ${uid} -g ${group} ${user} )`,
93
- `USER ${user}`
94
- ].join('\n');
95
- } else {
96
- return '';
97
- }
98
- }
99
80
  }
@@ -1,9 +1,9 @@
1
1
  import { DockerPackFactory } from './bin/types';
2
- import { PackUtil } from './bin/util';
2
+ import { PackConfigUtil } from './bin/config-util';
3
3
 
4
4
  export const factory: DockerPackFactory = cfg => `
5
5
  FROM ${cfg.dockerImage}
6
- ${PackUtil.generateDockerUserCommand(cfg)}
6
+ ${PackConfigUtil.dockerUserCommand(cfg)}
7
7
  WORKDIR /app
8
8
  COPY . .
9
9
  ${cfg.dockerPort?.map(port => `EXPOSE ${port}`).join('\n') ?? ''}