DEV Community 👩‍💻👨‍💻

Japroz Saini
Japroz Saini

Posted on

Backend Dockerfile Setup

How to setup a dockerfile to containerize yout appliaction for deployment to various VPS of your choice and how to install it on your VPS. You can use the following dockerfile for your projects that are specially using typescript and yarn.

FROM node:latest

WORKDIR /usr/src/app

COPY package.json ./
COPY yarn.lock ./

RUN yarn

COPY . .
COPY .env.production .env

RUN yarn build

ENV NODE_ENV production

CMD ["node", "dist/index.js"]
USER node

Enter fullscreen mode Exit fullscreen mode

Then you can use the following commands to push it from your system and pull it from your VPS

docker build -t <tagname>
docker push <tagname>

## on your vps
docker pull <username>:<tagname>

Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Find what you were looking for? Join hundreds of thousands of developers on DEV so you can:

🌚 Enable dark mode
🔠 Change your default font
📚 Adjust your experience level to see more relevant content