Project 1 โ€บ 01 Choose a simple app to containerizeGitHub โ†—
๐Ÿค– AI Prompt โ€” stuck? paste this

โ€œGenerate the smallest possible Node.js Express app with a single route that returns JSON, plus a /health route. Include package.json and index.js.โ€

01 โ€” Choose a simple app to containerize

Category: Dockerfile ยท Priority: High ยท Step: 2

Keep it minimal โ€” a single route returning JSON is enough. The focus is the Docker setup, not the app.

๐ŸŽฏ What is this task?

Before writing any Docker code, you need a real app to containerize. Don't build something complex โ€” a single web page that returns a message is enough. The goal here is to have working code you can wrap in Docker.

๐Ÿค– AI Prompt to generate the app

Copy and paste this into Claude or ChatGPT:

"Create a simple Node.js Express app. It should have two routes: GET / that returns a JSON response { "message": "Hello from Docker!" }, and GET /health that returns { "status": "ok" }. Use port 3000. Put everything in a single file called index.js. Also create a package.json for it."

๐Ÿ“‹ Step-by-step

Step 1 โ€” Install Node.js (if not installed)

Go to https://nodejs.org and download the LTS version. After installing, verify it works:

node --version
npm --version

Both commands should print a version number.

Step 2 โ€” Create a project folder

mkdir my-docker-app
cd my-docker-app

Step 3 โ€” Create the files

Create index.js with this content:

const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;

app.get('/', (req, res) => {
  res.json({ message: 'Hello from Docker!' });
});

app.get('/health', (req, res) => {
  res.json({ status: 'ok' });
});

app.listen(PORT, () => {
  console.log(`Server running on port ${PORT}`);
});

Create package.json with this content:

{
  "name": "my-docker-app",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "express": "^4.18.2"
  }
}

Step 4 โ€” Install dependencies and test it locally

npm install
npm start

Open your browser and go to http://localhost:3000 โ€” you should see the JSON response. Press Ctrl+C to stop.

โœ… Done when

  • You have an index.js and package.json in your folder
  • Running npm start shows the server running message
  • http://localhost:3000 shows { "message": "Hello from Docker!" }
  • http://localhost:3000/health shows { "status": "ok" }

๐Ÿ“ Quiz

Answer all 2 questions correctly to complete this lesson.

1. What kind of app should you pick for this project?
2. Why keep the app minimal?
โ† PreviousPass the quiz to completeNext โ†’