hmu.ai
Back to Builder Agents
Builder Agent

Hyper-Focused Dockerfile for Application Container for Freelance Developers

Stop doing this manually. Deploy an autonomous Builder agent to handle dockerfile for application container entirely in the background.

Zero-Shot Command Setup

Generate a Dockerfile for a production-ready Node.js application. Use an Nginx reverse proxy, PM2 for process management, and ensure a multi-stage build for a small image size. The app runs on port 3000.

Core Benefits & ROI

  • Automates containerization setup
  • Ensures consistent deployment environments
  • Optimizes image size for faster deployments
  • Improves application reliability with process management
  • Reduces infrastructure setup time

Ecosystem Integration

This agent primarily supports the "Project Management/Planning" and "Code Generation/Automation" pillars by automating the creation of critical infrastructure-as-code. It empowers freelance developers to quickly containerize their applications for consistent deployment, scaling, and environment management. By generating optimized Dockerfiles, it streamlines the DevOps workflow, reduces setup complexities, and ensures that applications are robust and ready for production, fitting perfectly into the initial setup and deployment phases of a project.

Sample Output

```dockerfile # Stage 1: Build the Node.js application FROM node:18-alpine AS builder WORKDIR /app COPY package.json package-lock.json ./ RUN npm install --production COPY . . RUN npm run build # Assuming a build script exists for your frontend/app # Stage 2: Create a minimal production image for Node.js using PM2 FROM node:18-alpine AS app WORKDIR /app # Install PM2 globally RUN npm install -g pm2 # Copy only necessary files from the builder stage COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/package.json ./package.json COPY --from=builder /app/build ./build # If you have a build folder for frontend COPY --from=builder /app/dist ./dist # Or a dist folder for compiled backend COPY --from=builder /app/server.js ./server.js # Your main application entry point # Copy any other necessary application files EXPOSE 3000 CMD ["pm2-runtime", "server.js"] # Stage 3: Setup Nginx reverse proxy FROM nginx:alpine AS proxy # Remove default Nginx config RUN rm /etc/nginx/conf.d/default.conf # Copy custom Nginx configuration COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 # Command to run Nginx CMD ["nginx", "-g", "daemon off;"] # Example nginx/nginx.conf for your project (create this file in your project root) # server { # listen 80; # server_name your_domain.com; # # location / { # proxy_pass http://app:3000; # 'app' refers to your Node.js service name in docker-compose # proxy_http_version 1.1; # proxy_set_header Upgrade $http_upgrade; # proxy_set_header Connection 'upgrade'; # proxy_set_header Host $host; # proxy_cache_bypass $http_upgrade; # } # } ```

Frequently Asked Questions

How can I customize the base image or Node.js version?

You can specify your desired base image and Node.js version directly in the prompt (e.g., "FROM node:16-slim" or "FROM python:3.9-alpine"), and the agent will adjust the Dockerfile accordingly.

Does this agent also generate `docker-compose.yml` files for multi-service applications?

Yes, if your prompt describes multiple services (e.g., "Node.js app with MongoDB and Nginx proxy"), the agent can extend its output to include a `docker-compose.yml` file to orchestrate these services.