Cov txheej txheem:

Yuav ua li cas koj ntim cov node app?
Yuav ua li cas koj ntim cov node app?

Video: Yuav ua li cas koj ntim cov node app?

Video: Yuav ua li cas koj ntim cov node app?
Video: Ntshe Ua Tsis Tau Koj Niam Tu Nyab |Leela Xiong| 2024, Kaum ib hlis
Anonim

Sau Dockerfile

  1. Los ntawm node :7. Kab 2: Teem ua haujlwm dir hauv lub thawv rau / app .
  2. KEV PAB / app . Kab 3-5: Luam daim ntawv thov rau / app directory thiab nruab dependencies.
  3. COPY package.json / app RUN npm install COPY. / app .
  4. CMD node qhov ntsuas. js . Kab 7: Tshem tawm qhov chaw nres nkoj 8081 mus rau sab nraud ib zaug thawv tau launched:

Ib yam li ntawd, nws tau nug, Kuv yuav ntim cov node app li cas?

Koj tuaj yeem sim qhov teeb tsa hauv qab no:

  1. Tau txais koj cov apps qhov chaws.
  2. npm nruab tag nrho cov kev vam khom (ntawm pob. json) mus rau lub zos node_modules directory.
  3. Luam the Node. js binary – node.exe ntawm Windows, (tej zaum) /usr/local/bin/node ntawm OS X/Linux rau koj qhov project hauv paus nplaub tshev.

Yuav ua li cas koj Dockerize ib react app? Tutorial siv 'create-react-app'

  1. Kauj ruam 1: Nruab tsim-react-app. xov xwm ntiaj teb no ntxiv tsim-react-app.
  2. Kauj ruam 2: Tsim ib qhov project tshiab.
  3. Kauj ruam 4: Ntxiv cov txheej txheem tsim rau Dockerfile.
  4. Kauj Ruam 5: Ntxiv qhov chaw tsim khoom rau SAME Dockerfile.
  5. Kauj Ruam 6: Tsim cov duab!
  6. Kauj Ruam 7: Khiav nws hauv zos los sim nws ua haujlwm!

Khaws qhov no hauv kev xav, Docker node yog dab tsi?

Tus neeg ua haujlwm nodes kuj yog piv txwv ntawm Docker Lub cav uas nws lub hom phiaj yog los ua cov ntim khoom. Tus neeg ua haujlwm nodes tsis txhob koom nrog Raft faib xeev, txiav txim siab teem sijhawm, lossis ua haujlwm rau hom HTTP API.

Kuv yuav ua li cas thiaj tau lub thawv ID hauv lub thawv?

Ua kom yooj yim, Thawv ID yog koj lub npe host hauv docker.

Yog li, koj tuaj yeem:

  1. nruab docker-io pob hauv koj lub thawv nrog tib lub version raws li tus tswv tsev.
  2. pib nws nrog --volume /var/run/docker. sock:/var/run/docker. sock --privileged.
  3. Thaum kawg, khiav: docker tshuaj xyuas $(hostname) hauv lub thawv.

Pom zoo: