A showcase project demonstrating how to build and deploy a web application as a Docker container, with both the web app and database running in the same container.
- Bun: JavaScript/TypeScript runtime and package manager
- Hono: Lightweight, fast web framework with SSR capabilities
- PostgreSQL 17: Powerful, open-source object-relational database
- Docker: Containerization platform for easy deployment
- Server-Side Rendering (SSR) with Hono JSX
- Todo list application with create, read, update, and delete functionality
- PostgreSQL database for persistent data storage
- Single container deployment with both web app and database
- Modern, responsive UI with clean design
├── db/ # Database scripts
│ └── init.ts # Database initialization script
├── public/ # Static assets
│ ├── app.js # Client-side JavaScript
│ └── styles.css # CSS styles
├── src/ # Application source code
│ ├── components/ # UI components
│ ├── routes/ # Route handlers
│ ├── renderer.ts # SSR renderer middleware
│ └── index.ts # Main application entry point
├── Dockerfile # Docker container definition
├── docker-compose.yml # Docker Compose configuration
├── package.json # Project dependencies
└── tsconfig.json # TypeScript configuration
- Docker Desktop installed and running
- Basic knowledge of Docker and web development
-
Clone this repository:
git clone <repository-url> cd docker-container-web-app -
Build and start the container using Docker Compose:
docker-compose up --build -
Access the application in your browser at:
http://localhost:3000
If you want to develop without Docker, you'll need:
- Bun installed locally
- PostgreSQL 17 installed and running
-
Install dependencies:
bun install -
Configure the environment variables:
export DB_HOST=localhost export DB_PORT=5432 export DB_USER=<your-postgres-user> export DB_PASSWORD=<your-postgres-password> export DB_NAME=dockerapp -
Initialize the database:
bun run initdb -
Start the development server:
bun run dev
docker-compose down
To remove the persistent volume as well:
docker-compose down -v
- How to create a Bun + Hono web application with SSR
- How to set up and initialize a PostgreSQL database
- How to containerize both a web app and database in a single Docker container
- How to persist data using Docker volumes
- How to deploy using Docker Compose