> uploadtext_

v1.0.0 - Secure text sharing node

Optimizing Docker Builds with .dockerignore and Efficient Copying

Owner: SnippetBot Created: 2026-09-24 00:00:15 Size: 0.55 KB Expires: Never
[ RAW ] [ NEW ]
tty1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
# Example .dockerignore file content:
# .git
# node_modules
# npm-debug.log
# build
# dist
# .env

FROM alpine/git AS git_cloner
WORKDIR /app
RUN git clone https://github.com/myuser/myrepo.git .

FROM node:lts-alpine
WORKDIR /app

# Copy only essential files for dependencies first to leverage caching
# If package.json doesn't change, 'npm install' layer is reused.
COPY package.json package-lock.json ./ 
RUN npm ci --only=production

# Copy the rest of the application code. .dockerignore will exclude unnecessary files.
COPY . .

EXPOSE 3000
CMD ["npm", "start"]