Skip to content

Commit 24067b3

Browse files
committed
Add Docker support with nginx for containerized serving. Issue #1
1 parent 3006464 commit 24067b3

File tree

5 files changed

+61
-5
lines changed

5 files changed

+61
-5
lines changed

.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.git
2+
cli
3+
docs
4+
CLAUDE.md
5+
LICENSE
6+
README.md
7+
Makefile
8+
Dockerfile
9+
.dockerignore
10+
.github

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM nginx:alpine
2+
3+
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
4+
COPY --chmod=644 web/ /usr/share/nginx/html/
5+
6+
EXPOSE 8000

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Makefile for EPUB to XTC Converter & Optimizer
22

3-
.PHONY: all serve tag help
3+
.PHONY: all serve docker-serve tag help
4+
5+
PORT ?= 8000
46

57
# Default target
68
all: help
@@ -11,6 +13,11 @@ serve: ## Run local web server (http://localhost:8000)
1113
@echo "Starting server at http://localhost:8000"
1214
@cd web && python3 -m http.server 8000
1315

16+
docker-serve: ## Run in Docker (Ctrl+C to stop). Usage: make docker-serve [PORT=8000]
17+
@docker build -t epub-to-xtc .
18+
@echo "Running at http://localhost:$(PORT) (Ctrl+C to stop)"
19+
@docker run --rm -p $(PORT):8000 epub-to-xtc
20+
1421
## Release:
1522

1623
tag: ## Create and push a version tag (triggers GitHub release)

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,20 @@ Clone the repository and serve the web directory:
125125

126126
```bash
127127
git clone https://github.com/bigbag/epub-optimizer-xteink.git
128-
cd epub-optimizer-xteink/web
128+
cd epub-optimizer-xteink
129+
130+
# Using Docker
131+
make docker-serve # http://localhost:8000
132+
make docker-serve PORT=3000 # custom port
129133

130134
# Using Python
131-
python -m http.server 8000
135+
cd web && python -m http.server 8000
132136

133137
# Using Node.js
134-
npx serve .
138+
cd web && npx serve .
135139

136140
# Using PHP
137-
php -S localhost:8000
141+
cd web && php -S localhost:8000
138142
```
139143

140144
Then open http://localhost:8000 in your browser.

docker/nginx.conf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
server {
2+
listen 8000;
3+
server_name localhost;
4+
root /usr/share/nginx/html;
5+
index index.html;
6+
7+
types {
8+
text/html html htm;
9+
text/css css;
10+
application/javascript js;
11+
application/json json;
12+
application/wasm wasm;
13+
image/png png;
14+
image/jpeg jpg jpeg;
15+
image/svg+xml svg;
16+
image/x-icon ico;
17+
font/woff2 woff2;
18+
font/woff woff;
19+
font/ttf ttf;
20+
application/octet-stream bin;
21+
}
22+
23+
gzip on;
24+
gzip_types text/css application/javascript application/json application/wasm image/svg+xml;
25+
26+
location / {
27+
try_files $uri $uri/ =404;
28+
}
29+
}

0 commit comments

Comments
 (0)