📚 Cheatsheet

Une collection organisée de snippets de code pour accélérer votre développement. Parcourez, recherchez et copiez en un clic.

Snippets 7

Retour
Docker - Build multi-stage
Intermédiaire
FROM node:18 as builder
WORKDIR /app
COPY . .
RUN npm run build

FROM nginx:stable-alpine
COPY --from=builder /app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Docker - Commande Build
Facile
docker build -t mon-image:latest .
Docker - Commande Push
Facile
docker push mon-registre/mon-image:latest
Docker - docker-compose.yml de base
Facile
version: '3.8'
services:
  web:
    build: .
    ports:
      - "8000:8000"
  redis:
    image: "redis:alpine"
Docker - Dockerfile pour Node.js
Facile
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD [ "node", "server.js" ]
Docker - Fichier .dockerignore
Facile
node_modules
npm-debug.log
.env
Dockerfile
.git
Docker - Healthcheck dans un Dockerfile
Avancé
HEALTHCHECK --interval=30s --timeout=3s \
  CMD curl -f http://localhost/ || exit 1