P
💻DeveloppementIntermediateChatGPT

Create an Optimized Production Dockerfile

Create a multi-stage Dockerfile optimized for production with maximum security, lightweight image, and best practices.

Paste in your AI

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

Tu es un expert Docker et DevOps spécialisé dans l'optimisation des conteneurs pour la production. Je dois créer un Dockerfile optimisé pour l'application suivante :

Type d'application : [EX: API Node.js, application Python Flask, application Go, frontend React]
Version du runtime : [EX: Node.js 20, Python 3.12, Go 1.22]
Dépendances : [EX: PostgreSQL client, Redis, librairies système spécifiques]
Variables d'environnement sensibles : [LISTER_LES_VARS_SANS_VALEURS]
Commande de démarrage : [EX: npm start, gunicorn app:app, ./binary]

Crée un Dockerfile de production qui respecte toutes les meilleures pratiques :

  1. Multi-stage build : sépare les étapes de build et de runtime pour minimiser la taille de l'image finale.
  2. Image de base : choisis l'image de base la plus légère et sécurisée appropriée (Alpine, Distroless, Slim).
  3. Utilisateur non-root : crée et utilise un utilisateur sans privilèges pour des raisons de sécurité.
  4. Optimisation du cache : ordonne les instructions pour maximiser l'utilisation du cache Docker.
  5. Gestion des secrets : utilise des build args pour les secrets de build, jamais de secrets dans les layers.
  6. Health check : ajoute une instruction HEALTHCHECK appropriée.
  7. Métadonnées : ajoute les labels LABEL standards (maintainer, version, description).

Fournis également un fichier .dockerignore adapté et une commande docker build et docker run de test.

100% found this useful

Personalize this prompt with Léa

Léa rewrites this prompt for your job and your exact goal — 3 quick questions.

Why this prompt works

<p>This prompt targets the four most important Docker optimization axes in production: image size (multi-stage, Alpine), security (non-root user, no secrets in layers), build performance (cache optimization), and reliability (health checks).</p><p>Requesting a .dockerignore in addition to the Dockerfile is often overlooked but crucial: a poorly configured .dockerignore can accidentally include sensitive files (node_modules, .env) or unnecessarily bloat the build context.</p><p>By specifying the application type and runtime upfront, the AI can choose optimal base images (e.g., Distroless for Go, Node Alpine for Node.js) rather than proposing a generic Dockerfile poorly suited to the actual context.</p>

Use Cases

Containerizing applications for productionAuditing existing DockerfilesReducing image size and build time

Expected Output

A complete multi-stage Dockerfile, an adapted .dockerignore, and build and run commands with explanations.

Improve this prompt

Run this prompt through the Optimizer to strengthen its context, constraints and expected format.

Improve this prompt with the Optimizer

Comments

  • LéaAI

    Astuce : pour Node.js, remplacez `npm install` par `npm ci` dans le stage de build. Cela force l'utilisation exacte du `package-lock.json` (installations reproductibles) et est plus rapide. Ajoutez `--production` pour exclure les devDependencies. Copiez d'abord `package*.json` puis les dépendances avant le code source pour maximiser le cache Docker.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementIntermediateAll AIs

Feature Flag Management

Progressive deployments with feature flags

0213
💻DeveloppementIntermediateAll AIs

Midjourney Prompt for Creating a Chatbot

Midjourney has become an essential tool for designing a chatbot's visual identity. Whether you're developing a virtual assistant for customer service, a conversational bot for your e-commerce site, or an AI companion for a mobile app, your chatbot's appearance plays a crucial role in user engagement. A well-designed avatar inspires trust, humanizes the interaction, and reinforces your brand image. With Midjourney, you can generate avatars, conversational interfaces, mascots, and UI visual elements without needing graphic design skills. The right prompts let you create visuals consistent with your brand guidelines, from accessible cartoon styles to clean corporate designs. In this guide, you'll find optimized prompts to generate all the visual assets your chatbot needs: main avatar, emotion variations, stylized speech bubbles, and welcome screens. Each prompt has been tested and refined to produce professional results you can use directly in your development projects.

0238
💻DeveloppementAdvancedClaude

Configure a CI/CD Pipeline with GitHub Actions

Configure a professional CI/CD pipeline with GitHub Actions covering tests, security, Docker build, and multi-environment deployment.

45512
💻DeveloppementBeginnerAll AIs

Encryption at rest and in transit

Securing data at rest and in transit

0229