A Node.js application demonstrating container deployment on Cloudflare Workers with Docker.
- Simple REST API with health check endpoint
- Containerized with Docker for easy deployment
- Pre-configured for Cloudflare Workers
- Development and production environment support
- Docker (for containerized deployment)
- Node.js (v14 or later recommended)
- npm or Yarn
- Cloudflare Wrangler CLI (for Cloudflare deployment)
.
├── .dockerignore # Specifies files to exclude from Docker builds
├── .gitignore # Specifies files to exclude from version control
├── Dockerfile # Docker configuration for containerization
├── README.md # This file
├── index.js # Main application entry point
├── package.json # Project dependencies and scripts
└── wrangler.toml # Cloudflare Workers configuration
-
Clone the repository:
git clone https://github.com/your-username/cloudflare-container-demo.git cd cloudflare-container-demo -
Install dependencies:
npm install # or yarn -
Start the development server:
npm start # or yarn start -
Access the API at http://localhost:3000/health
- Should return:
{"status":"ok"}
- Should return:
-
Build the Docker image:
docker build -t cloudflare-container-demo . -
Run the container:
docker run -p 3000:3000 -d cloudflare-container-demo -
Access the API:
- Health check: http://localhost:3000/health
- Should return:
{"status":"ok"}
-
Make sure you have Wrangler CLI installed and authenticated:
npm install -g wrangler wrangler login -
Deploy your worker:
wrangler deploy
Create a .env file in the root directory with the following variables:
NODE_ENV=development
PORT=3000
# Add other environment variables as needed
.gitignore: Excludes development and system files from version control.dockerignore: Optimizes Docker builds by excluding unnecessary files
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.