-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
91 lines (66 loc) · 2.5 KB
/
Dockerfile
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
ARG GIT_COMMIT_HASH
ARG PATH_SOURCE=/tmp/ldsa/.source
ARG PATH_LOCAL_BUILDS=/tmp/ldsa/.builds
ARG NX_CACHE_DIRECTORY=/tmp/ldsa/.cache/nx
ARG PATH_FINAL_BUILDS=/usr/local/ladesa-ro/services/
ARG NX_SOCKET_DIR=/tmp/nx-tmp
# ========================================
# BASE NODEJS IMAGE
# ========================================
FROM node:23 AS base
ARG PATH_SOURCE
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR "${PATH_SOURCE}"
COPY package.json .
RUN corepack install
# ========================================
# BUILD ASSETS
# ========================================
FROM base AS build
ARG PATH_LOCAL_BUILDS
ARG GIT_COMMIT_HASH
ARG NX_CACHE_DIRECTORY
ARG NX_SOCKET_DIR
ENV NX_DAEMON=true
# ENV NX_VERBOSE_LOGGING=true
ENV NX_SOCKET_DIR=${NX_SOCKET_DIR}
ENV GIT_COMMIT_HASH=${GIT_COMMIT_HASH}
ENV NX_CACHE_DIRECTORY=${NX_CACHE_DIRECTORY}
COPY . "${PATH_SOURCE}"
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN --mount=type=cache,id=nx,target=${NX_CACHE_DIRECTORY},sharing=locked pnpm run -w build
# ========================================
# BUILD / API-SERVICE
# ========================================
FROM build AS build-api-service
ARG NX_CACHE_DIRECTORY
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm deploy --prod --filter=@ladesa-ro/api.service "${PATH_LOCAL_BUILDS}/api-service"
# ========================================
# BUILD / NPM / API-CLIENT-FETCH / DOCS
# ========================================
FROM build AS build-npm-api-client-fetch-docs
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm deploy --prod --filter=@ladesa-ro/api-client-fetch.docs "${PATH_LOCAL_BUILDS}/npm-api-client-fetch.docs"
# ========================================
# RUNTIME / API-SERVICE
# ========================================
FROM base AS api-service
ARG PATH_LOCAL_BUILDS
ARG PATH_FINAL_BUILDS
COPY --from=build-api-service \
"${PATH_LOCAL_BUILDS}/api-service" \
"${PATH_FINAL_BUILDS}/api-service"
WORKDIR "${PATH_FINAL_BUILDS}/api-service"
CMD pnpm run migration:run && pnpm run start:prod
# ========================================
# RUNTIME / NPM / API-CLIENT-FETCH / DOCS
# ========================================
FROM nginx:alpine AS npm-api-client-fetch-docs
ARG PATH_LOCAL_BUILDS
ARG PATH_FINAL_BUILDS
COPY \
./integrations/npm/api-client-fetch-docs/nginx.conf \
/etc/nginx/nginx.conf
COPY --from=build-npm-api-client-fetch-docs "${PATH_LOCAL_BUILDS}/npm-api-client-fetch.docs" "${PATH_FINAL_BUILDS}/npm-api-client-fetch-docs"
EXPOSE 80