2.2.8 • Published 3 months ago

bear-node-docker v2.2.8

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

bear-node-docker

Common tools build docker image for node project development

NPM npm

Install

yarn add -D bear-node-docker

Setting

$ cp ./node_modules/bear-node-docker/config/nginx ./deploy/nginx

in your package.json

{
   "dockerRegistry": "docker.io/imagine10255",
   "scripts": {
     "docker:build": "bear-node-docker docker --dockerfile=./node_modules/bear-node-docker/config/dockerfile/react/Dockerfile",
     "docker:push": "bear-node-docker push"
   }
}

imagine10255 is your dockerhub account

Options Custom dockerfile in root type command

# react
$ cp ./node_modules/bear-node-docker/config/dockerfile/react/Dockerfile ./

# nest 
$ cp ./node_modules/bear-node-docker/config/dockerfile/nest/Dockerfile ./ 

package.json

{
    "scripts": {
      "docker:build": "bear-node-docker build --dockerfile=./Dockerfile"
    }
}

Options Custom use provider docker registry

package.json

{
   "dockerRegistry": "myDockerProvider.bear.com:8443"
}

Options Custom publicUrl

package.json

{
  "scripts": {
    "docker:build": "bear-node-docker build --publicUrl=/recommend  --dockerfile=./Dockerfile"
  }
}

Only packaged into docker image

In some old projects, npm build gets stuck when run inside Docker. In such cases, you can build locally and then only put the build path into the Docker image.

Dockerfile

# And then copy over node_modules, etc from that stage to the smaller base image
FROM nginx:1.19-alpine
COPY build /usr/share/nginx/html
COPY deploy/config-nginx/nginx.conf /etc/nginx/conf.d/default.conf
WORKDIR /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

Be aware that .dockerignore should not include the build folder (the default for create-react-app is 'build', while for Vite it's 'dist').

package.json

{
  "scripts": {
      "build": "react-scripts build",
      "docker:build": "yarn build && bear-node-docker build --publicUrl=/recommend  --dockerfile=./Dockerfile"
  }
}

Test

ts-node lib/build-docker/node-run.ts

License

MIT © imagine10255

2.2.8

3 months ago

2.2.7

4 months ago

2.2.6-alpha.0

4 months ago

2.2.6-alpha.1

4 months ago

2.2.6

4 months ago

2.2.5

4 months ago

2.2.5-alpha.0

4 months ago

2.2.4-alpha.1

4 months ago

2.2.4

4 months ago

2.2.4-alpha.0

4 months ago

2.2.3

6 months ago

2.2.2

2 years ago

2.2.1

2 years ago