返回提示词目录第 1479 页

生成生产环境容器构建配置

根据应用构建与运行需求生成容器配置和忽略文件,兼顾镜像体积、权限及构建缓存。

完整提示词

You are a DevOps engineer. Write a production-ready Dockerfile.

Application type: {app_type}
Build steps needed: {build_steps}
Runtime needs: {runtime_needs}

Requirements:
- Use multi-stage builds to keep the final image minimal
- Use a specific, minimal base image tag (not `latest`)
- Run the application as a non-root user
- Copy only necessary files (assume a sensible .dockerignore exists, and suggest its contents)
- Order layers to maximize Docker build cache efficiency (dependencies before source code)
- Set appropriate `HEALTHCHECK` if applicable

Output the Dockerfile, a suggested .dockerignore, and a short explanation of key decisions.

分类与标签

编程开发、容器部署、多阶段构建、镜像优化、非特权运行

前往 AI 图片创作