Skip to content

Commit 8154e66

Browse files
committed
added build script, updated dockerfile to build, currently squash TS errors in docker build
1 parent 7c67b6c commit 8154e66

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

Dockerfile

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1-
FROM node:20.10-alpine3.19
1+
ARG NODE_VERSION=20.10-alpine3.19
2+
3+
# Base
4+
FROM node:${NODE_VERSION} as base
25
RUN mkdir -p /mustachebash
36
WORKDIR /mustachebash
47
COPY package.json package-lock.json ./
5-
RUN NODE_ENV=production npm ci --include=prod --no-optional && \
6-
npm --silent cache clean --force
78

8-
COPY lib lib
9+
# Build
10+
FROM base as build
11+
# https://docs.docker.com/build/guide/mounts/
12+
RUN --mount=type=cache,target=/root/.npm \
13+
--mount=type=bind,source=tsconfig.json,target=tsconfig.json \
14+
--mount=type=bind,source=lib,target=lib \
15+
npm ci && \
16+
npm run build; exit 0
17+
18+
# Production
19+
FROM base as production
20+
# https://docs.docker.com/build/guide/mounts/
21+
RUN --mount=type=cache,target=/root/.npm \
22+
NODE_ENV=production npm ci
23+
USER node
24+
COPY --from=build /mustachebash/dist ./dist
925
EXPOSE 4000
10-
CMD npm start
26+
CMD npm --silent --no-update-notifier start
27+

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"author": "Wild Feather LLC",
99
"scripts": {
1010
"dev": "tsx watch --clear-screen=false lib/index.ts",
11+
"build": "rm -rf dist && tsc",
1112
"test": "eslint . && tsc --noEmit",
1213
"start": "node .",
1314
"check:updates": "ncu",

0 commit comments

Comments
 (0)