Dockerfile ਇੱਕ ਟੈਕਸਟ ਫਾਈਲ ਹੈ ਜਿਸ ਵਿੱਚ Docker image ਬਣਾਉਣ ਲਈ ਹਦਾਇਤਾਂ ਹਨ — ਇਹ ਬੇਸ image, ਡਿਪੈਂਡੈਂਸੀਜ, ਕਾਪੀ ਕਰਨ ਲਈ ਫਾਈਲਾਂ, ਅਤੇ ਐਪਲੀਕੇਸ਼ਨ ਨੂੰ ਕਿਵੇਂ ਚਲਾਉਣਾ ਹੈ ਦਰਸਾਉਂਦਾ ਹੈ। ਇਹ image builds ਨੂੰ reproducible ਅਤੇ version-controllable ਬਣਾਉਂਦਾ ਹੈ।
ਇੱਕ ਬੁਨਿਆਦੀ Dockerfile
# FROM — the base image to build on
FROM node:20-alpine
# WORKDIR — set the working directory inside the image
WORKDIR /app
# COPY dependency files first (for better layer caching)
COPY package*.json ./
# RUN — execute a command during the BUILD (install dependencies)
RUN npm install
# COPY the rest of the application code
COPY . .
# EXPOSE — document the port the app listens on
EXPOSE 3000
# CMD — the command to run when a CONTAINER starts
CMD ["node", "server.js"]
