feat: add Docker support with Dockerfile, Docker Compose, and Makefile for containerized deployment

This commit is contained in:
2026-06-01 14:55:19 +08:00
parent 0db5058a83
commit 407e5debe2
5 changed files with 119 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
.git
.gitignore
node_modules
.svelte-kit
build
dist
coverage
.vscode
.idea
README.md
docs
+13
View File
@@ -0,0 +1,13 @@
FROM oven/bun:1.2.17
WORKDIR /app
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile
COPY . .
RUN bun run build
EXPOSE 3000
CMD ["bun", "run", "preview", "--", "--host", "0.0.0.0", "--port", "3000"]
+39
View File
@@ -0,0 +1,39 @@
ENGINE ?= docker
COMPOSE_FILE ?= compose.yaml
ifeq ($(ENGINE),docker)
COMPOSE_CMD = docker compose
else ifeq ($(ENGINE),podman)
COMPOSE_CMD = podman compose
else
$(error Unsupported ENGINE='$(ENGINE)'. Use ENGINE=docker or ENGINE=podman)
endif
.PHONY: help build up down restart logs ps config pull
help:
@echo "Usage: make <target> [ENGINE=docker|podman]"
@echo "Targets: build up down restart logs ps config pull"
build:
$(COMPOSE_CMD) -f $(COMPOSE_FILE) build
up:
$(COMPOSE_CMD) -f $(COMPOSE_FILE) up -d --build
down:
$(COMPOSE_CMD) -f $(COMPOSE_FILE) down
restart: down up
logs:
$(COMPOSE_CMD) -f $(COMPOSE_FILE) logs -f app
ps:
$(COMPOSE_CMD) -f $(COMPOSE_FILE) ps
config:
$(COMPOSE_CMD) -f $(COMPOSE_FILE) config
pull:
$(COMPOSE_CMD) -f $(COMPOSE_FILE) pull
+45
View File
@@ -39,6 +39,51 @@ bun run preview
You can also use `bun run start` to run preview mode.
## Containerized run (Docker and Podman)
This project includes:
- `Dockerfile`
- `compose.yaml`
- `Makefile` wrapper for Docker Compose and Podman Compose
By default, the container expects your gateway at:
- `http://host.containers.internal:8067`
If you use Docker Desktop on macOS and need Docker host mapping instead, set:
- `API_ORIGIN=http://host.docker.internal:8067`
### Start with Docker Compose
```bash
make up ENGINE=docker
```
### Start with Podman Compose
```bash
make up ENGINE=podman
```
### Useful commands
```bash
make build ENGINE=docker
make logs ENGINE=docker
make ps ENGINE=docker
make down ENGINE=docker
```
You can replace `ENGINE=docker` with `ENGINE=podman` in all commands.
### Optional environment overrides
```bash
APP_PORT=3001 API_ORIGIN=http://host.docker.internal:8067 make up ENGINE=docker
```
## Screenshot
![Nearby Bus Arrivals UI](docs/screenshots/bus-ui.jpeg)
+11
View File
@@ -0,0 +1,11 @@
services:
app:
build:
context: .
dockerfile: Dockerfile
image: bus-sg-app:latest
ports:
- "${APP_PORT:-3000}:3000"
environment:
API_ORIGIN: "${API_ORIGIN:-http://host.containers.internal:8067}"
restart: unless-stopped