Linux@Operating-System:~$ cat 'Docker and Podman.txt'

Podman/Docker is containerization tools allow you to testing and fast deploy without mind about the lower layout of archtecture of cpu, or what operating system is running on, etc … It isolates itself from pretty much everyhting and only the bare bone enough to run your dedicated application.

So today, with me, we will learn how to make your own application ? What you will need for today lab. Your application, that’s obvious. In my case, it will be backend for my todo application.

Linux@OperatingSystem:~/Workstation/$ls

  • Controllers
  • Database
  • Middleware
  • Models
  • Services
  • Utility
  • package.josn
  • node_modules
  • index.js

Linux@OperatingSystem:~/Workstation/$ cat ‘Instruction.txt’

First of all, you need to include everything you want to deploy because this is the stage where we will put everything into a box, seal it and then send it wherever it need to be deploy.

So, we need to create docker file at the same location of the config file. In this case, configure file is package.json, create a file name ‘Dockerfile’. Inside of it, it should contains the following things

FROM node:20 -> Where is start, this case i use the image of node, version 20. That means it will contains linux images with nodesjs and npm pre-installed

WORKDIR /app -> Here, it set the working directory to be app. It also will be contains all the sources in case you need to configure inside the docker

Now, it copy package files and install dependencies

COPY package*.json ./

RUN npm install

COPY . . -> Copy the source code

EXPOSE 3000 -> Expose the port your app runs on (e.g., 3000)

CMD [ “node”, “index.js” ] -> Run the server

Linux@OperatingSystem:~/Workstation/$ docker build -t myapp .

Linux@OperatingSystem:~/Workstation/$ docker run -p 3000:3000 myapp

Linux@Operating-System:~$ /bye