Skip to content

Commit 87d804f

Browse files
committed
feat: add nest dockerfile sample
1 parent ed2d063 commit 87d804f

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,19 @@ in your package.json
2525
{
2626
"dockerRegistry": "myDockerProvider.bear.com:8443",
2727
"scripts": {
28-
"docker:build": "bear-react-docker docker --publicUrl=/recommend --dockerfile=./node_modules/bear-react-docker/config/Dockerfile",
28+
"docker:build": "bear-react-docker docker --publicUrl=/recommend --dockerfile=./node_modules/bear-react-docker/config/dockerfile/react/Dockerfile",
2929
"docker:push": "bear-react-docker push"
3030
}
3131
}
3232
```
3333

34-
### [Options] Custom dockerfile
34+
### [Options] Custom dockerfile in root type command
3535
```bash
36-
$ cp ./node_modules/bear-react-docker/config/Dockerfile ./
36+
# react
37+
$ cp ./node_modules/bear-react-docker/config/dockerfile/react/Dockerfile ./
38+
39+
# nest
40+
$ cp ./node_modules/bear-react-docker/config/dockerfile/nest/Dockerfile ./
3741
```
3842

3943
package.json

config/dockerfile/nest/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM node:18.3.0-alpine AS builder
2+
ARG MAX_OLD_SPACE_SIZE=2048
3+
WORKDIR /opt/app/
4+
COPY package.json yarn.lock ./
5+
RUN awk '/},/ { p = 0 } { if (!p) { print $0 } } /"devDependencies":/ { p = 1 }' package.json > package.json.tmp && mv package.json.tmp package.json && yarn install --prod --frozen-lockfile
6+
COPY . .
7+
RUN yarn build
8+
RUN mkdir ./copy-tmp && \
9+
mv asset ./copy-tmp && \
10+
mv node_modules ./copy-tmp && \
11+
mv dist ./copy-tmp
12+
13+
14+
# And then copy over node_modules, etc from that stage to the smaller base image
15+
FROM node:18.3.0-alpine
16+
WORKDIR /opt/app/
17+
COPY --from=builder /opt/app/copy-tmp .
18+
RUN mkdir /tmp/bearests
19+
20+
EXPOSE 8080
21+
CMD ["node", "--max_old_space_size=$MAX_OLD_SPACE_SIZE", "dist/main.js"]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG PUBLIC_URL
44
WORKDIR /opt/app/
55
COPY package.json yarn.lock ./
66
RUN awk '/},/ { p = 0 } { if (!p) { print $0 } } /"devDependencies":/ { p = 1 }' package.json > package.json.tmp && mv package.json.tmp package.json && yarn install --prod --frozen-lockfile
7-
COPY . .
7+
COPY ../.. .
88
ENV REACT_APP_CDN_ASSETS_PATH=$REACT_APP_CDN_ASSETS_PATH
99
ENV PUBLIC_URL=$PUBLIC_URL
1010
RUN yarn build

0 commit comments

Comments
 (0)