Skip to content

Commit 637f81b

Browse files
authored
Merge pull request #104 from Alexigbokwe/4.2.1
Optimise production build script, Update DockerFile
2 parents 4a5e754 + df41cdf commit 637f81b

File tree

4 files changed

+30
-18
lines changed

4 files changed

+30
-18
lines changed

DockerFile

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
1-
FROM node:14-alpine
2-
3-
RUN mkdir -p /app/expressweb-version4
4-
5-
WORKDIR /app/expressweb-version4
6-
7-
COPY package.json .
1+
FROM node:21-alpine3.18 as base
82

3+
# Stage 1: All dependencies
4+
FROM base as deps
5+
WORKDIR /app
6+
ADD package.json ./
97
RUN npm install
108

9+
# Stage 2: Production dependencies
10+
FROM base as production-deps
11+
WORKDIR /app
12+
ADD package.json ./
1113
RUN npm install ts-node
14+
RUN npm install --omit=dev
1215

13-
COPY . .
14-
16+
# Stage 3: Project Build
17+
FROM base as build
18+
WORKDIR /app
19+
COPY --from=deps /app/node_modules /app/node_modules
20+
ADD . .
1521
RUN npm run build
1622

17-
EXPOSE 5200
18-
23+
# Stage 4: Production stage
24+
FROM base
25+
ENV NODE_ENV=production
26+
WORKDIR /app
27+
COPY --from=production-deps /app/node_modules /app/node_modules
28+
COPY --from=production-deps /app/package.json /app/package.json
29+
COPY --from=build /app/build /app
30+
COPY --from=build /app/.env /app/.env
31+
EXPOSE 8080
1932
CMD ["npm","start"]

Resources/Command.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const commands = [
3636
"ExpressWebJs/commands/run-dev",
3737
"ExpressWebJs/commands/run-build",
3838
"ExpressWebJs/commands/run-start",
39-
"ExpressWebJs/commands/run-prod",
4039
"ExpressWebJs/commands/make-domain",
4140
"ExpressWebJs/commands/domain:make-controller",
4241
"ExpressWebJs/commands/domain:make-model",

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"maker": "ts-node maker",
88
"test": "jest",
99
"dev": "ts-node maker run-dev",
10-
"start": "node ./build/maker run-start",
10+
"start": "ts-node maker run-start",
1111
"build": "ts-node maker run-build"
1212
},
1313
"keywords": [
@@ -36,7 +36,7 @@
3636
"expresswebcorets": "2.1.41",
3737
"expresswebjs-preset-ts": "1.0.5",
3838
"log4js": "^6.3.0",
39-
"maker-console-ts": "2.1.15",
39+
"maker-console-ts": "2.1.16",
4040
"module-alias": "^2.2.2",
4141
"recursive-copy": "^2.0.13",
4242
"set-value": "^4.1.0"

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,10 +2144,10 @@ make-fetch-happen@^13.0.0, make-fetch-happen@^13.0.1:
21442144
promise-retry "^2.0.1"
21452145
ssri "^10.0.0"
21462146

2147-
2148-
version "2.1.15"
2149-
resolved "https://registry.yarnpkg.com/maker-console-ts/-/maker-console-ts-2.1.15.tgz#38f90b98d47190cf2b0f9a1fcde5054bb400b0e4"
2150-
integrity sha512-ND9RaHGf0fxRYvd8SpzWcAXQdbWLYeF6mMxYYrVy10kEeR1K+vsT/rpE7kw1gyABTZijITvP75VfmsYv5XePug==
2147+
2148+
version "2.1.16"
2149+
resolved "https://registry.yarnpkg.com/maker-console-ts/-/maker-console-ts-2.1.16.tgz#cf55b679570beb63024f371e0a246d2387ed6eae"
2150+
integrity sha512-ABc6JjsSlea5B9XRYZTqL9RcpHQxzRhsKt7CB8EZbPaRBZsGjuJD/niPavj1Fm2TMsoqLoZAFutJCABOGc/EOQ==
21512151
dependencies:
21522152
commander "^11.1.0"
21532153
dotenv "^8.2.0"

0 commit comments

Comments
 (0)