Docker

Shamelessly taken from Eric Pearson @nyloneric, as I haven't documented my own process yet.

Create a Container

Make the thing: https://flaviocopes.com/docker-node-container-example/

Create a simple Node.js Hello World Docker Container from scratch

You will run into errors, so:

Container: docker exec -it <container id> /bin/bash``docker run -p 49160:8080 -d <your username>/node-web-app

Docker Hub Dockerizing a Node.js web app | Node.js I also really like Mosh Hamadani tutorials

Make a dockerfile

FROM node:14

COPY package*.json ./
COPY tsconfig.json ./
COPY yarn.lock ./

RUN yarn install

COPY . .

RUN yarn build

EXPOSE 3000

CMD ["yarn", "start"]

Build

$ docker build -t NAME .

Run

$ docker run -dp 3000:3000 NAME

The package should now be available on your local machine

References

  1. https://www.freecodecamp.org/news/the-docker-handbook/

Last modified: 202209222156