-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (38 loc) · 1.29 KB
/
Dockerfile
File metadata and controls
58 lines (38 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Build stage
FROM node:22.11.0-slim as build_env
RUN useradd -m su-amaas
USER su-amaas
## Copy source codes and documents
COPY --chown=su-amaas:su-amaas package.json package-lock.json tsconfig.json LICENSE .eslintrc.json README.md /home/su-amaas/
COPY --chown=su-amaas:su-amaas protos /home/su-amaas/protos
COPY --chown=su-amaas:su-amaas src /home/su-amaas/src
WORKDIR /home/su-amaas
RUN npm ci
RUN mkdir -p ./src/lib/protos
## Generate protobuf files with protobuf-ts
RUN npx protoc \
--ts_out ./src/lib/protos \
--ts_opt generate_dependencies \
--ts_opt long_type_string \
--ts_opt output_javascript \
--ts_opt client_grpc1 \
--proto_path ./protos \
./protos/scan.proto
RUN mkdir -p ./output
RUN npm run build
## Copy package.json and documents
RUN cp package.json LICENSE README.md ./output/
FROM build_env as unit_test
ARG TM_AM_LOG_LEVEL
COPY --chown=su-amaas:su-amaas jest.config.ts /home/su-amaas
COPY --chown=su-amaas:su-amaas __tests__ /home/su-amaas/__tests__
## Run tests
RUN TM_AM_LOG_LEVEL=${TM_AM_LOG_LEVEL} npm test
# Publish stage
FROM node:22.11.0-slim
RUN useradd -m su-amaas
USER su-amaas
COPY --from=build_env --chown=su-amaas:su-amaas /home/su-amaas/output /home/su-amaas/output
WORKDIR /home/su-amaas/output
## Pack JavaScript node package
RUN npm pack