Skip to content

Commit b664a44

Browse files
authored
Merge pull request #23 from Mirasaki/build/optimize-docker-deployment
build: optimize docker deployment
2 parents 5466167 + 358dff8 commit b664a44

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1+
assets/
2+
maps-examples/
13
node_modules/
4+
5+
.dockerignore
6+
docker-compose.yml
7+
Dockerfile
8+
example.env
9+
Procfile
10+
README.md

Dockerfile

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
FROM node:20-alpine as build
2-
3-
WORKDIR /code
4-
RUN apk add --no-cache git
1+
# Stage 1: Build
2+
FROM node:24-alpine AS build
3+
WORKDIR /usr/src/build
4+
COPY package.json package-lock.json ./
5+
RUN npm ci
56
COPY . .
6-
RUN npm ci && npm run build
7-
8-
FROM node:20-alpine
9-
10-
WORKDIR /app
11-
RUN apk add --no-cache --virtual build-dependencies git
12-
COPY package.json .
13-
RUN npm install --only=production
14-
RUN apk del build-dependencies
15-
COPY --from=build /code/dist/ .
16-
17-
CMD ["node", "/app/index.js"]
7+
RUN npm run build
8+
9+
# Stage 2: Production/Runtime
10+
FROM node:24-alpine AS production
11+
WORKDIR /usr/src/app
12+
COPY package.json package-lock.json ./
13+
RUN npm ci --omit=dev
14+
COPY --from=build /usr/src/build/dist ./dist
15+
CMD ["node", "/usr/src/app/index.js"]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
}
3838
},
3939
"engines": {
40-
"node": "20.x.x"
40+
"node": ">=20 <=24"
4141
},
4242
"optionalDependencies": {
4343
"fsevents": "*"

0 commit comments

Comments
 (0)