Skip to content

Dockerfile

Posted on:May 25, 2020 at 12:00 AM

tp.web.random_picture

Dockerfile 101.

# Base image
FROM node:19-alpine

# Copies package.json from host to docker env.
# The "/" at the end ensures directory creation at the Linux root (front "/")
COPY package.json /app/

COPY src /app/

# WORKDIR sets the working directory for all following commands.
WORKDIR /app

# Runs this command in a shell inside the container environment
RUN npm install

# The instruction that is to be executed when a Docker container starts
# There can be only on "CMD" instruction in a Dockerfile.
CMD ["node", "server.js"]

Build an image

# -t or --tag
docker build -t node-app:1.0 .

References