Skip to content

Commit b6bfd10

Browse files
authored
Serverless (#8)
* chore: Remove unused files and update dependencies * chore: update dependencies and compatibility date in configuration files * feat: implement error handling and refactor server setup with new bucket management * change worker name to metowolf-ip * feat: update Dockerfile for Node.js 22 and add new environment variables
1 parent 597a4ba commit b6bfd10

File tree

21 files changed

+1120
-989
lines changed

21 files changed

+1120
-989
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/
22

33
.env.local
4+
.wrangler/

Dockerfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
FROM node:19-alpine
1+
FROM node:22-alpine
22

33
LABEL maintainer="[email protected]"
44

5-
ENV NODE_ENV=production
5+
ENV NODE_ENV=production \
6+
HTTP_PORT=80 \
7+
BUCKET_PATH=/tmp/openipdb
68

7-
EXPOSE 3000
9+
EXPOSE 80
810

9-
RUN addgroup -S webapp && adduser -S -G webapp webapp \
10-
&& mkdir /app && chown webapp /app \
11+
RUN mkdir /app \
1112
&& corepack enable
1213

13-
USER webapp
14-
1514
WORKDIR /app
1615
ENTRYPOINT ["pnpm", "start"]
1716

1817
COPY package.json pnpm-lock.yaml /app/
1918

20-
RUN pnpm i
19+
RUN pnpm i \
20+
&& mkdir $BUCKET_PATH \
21+
&& wget https://cdn.jsdelivr.net/npm/[email protected]/openipdb.ipdb -O $BUCKET_PATH/openipdb.ipdb
2122

2223
COPY src /app/src

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@
66
Open Source REST API for IP database, includes qqwry, ipipdotnet.
77
</h3>
88

9+
## Docker
10+
11+
### Run container
12+
13+
```bash
14+
docker run -d -p 80:80 ghcr.io/metowolf/ipdb-api/server:1.3.0
15+
```
16+
17+
### Mount Bucket Path
18+
19+
```bash
20+
docker run -d -p 80:80 -v /tmp/openipdb:/tmp/openipdb ghcr.io/metowolf/ipdb-api/server:1.3.0
21+
```
22+
923
## Usage
1024
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fmetowolf%2Fipdb-API.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fmetowolf%2Fipdb-API?ref=badge_shield)
1125

package.json

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
{
22
"name": "docker-ipdb",
3-
"version": "1.2.1",
3+
"version": "1.3.0",
44
"main": "src/server.js",
5+
"type": "module",
56
"repository": "[email protected]:metowolf/docker-ipdb.git",
67
"author": "metowolf <[email protected]>",
78
"license": "MIT",
89
"scripts": {
9-
"start": "node src/server.js",
10-
"dev": "nodemon src/server.js"
10+
"dev:worker": "wrangler dev",
11+
"deploy": "wrangler deploy",
12+
"dev": "nodemon node src/server.js",
13+
"start": "node src/server.js"
1114
},
1215
"dependencies": {
13-
"@ipdb/database": "^2019.7.3",
14-
"@ipdb/range": "^0.1.1",
15-
"dotenv-flow": "^3.3.0",
16-
"ipdb": "^0.3.3",
17-
"koa": "^2.14.2",
18-
"koa-helmet": "^7.0.2",
19-
"koa-pino-logger": "^4.0.0",
20-
"koa-router": "^12.0.0",
21-
"koa2-cors": "^2.0.6",
22-
"pino": "^8.15.0",
23-
"pino-pretty": "^10.2.0",
24-
"qqwry.ipdb": "^2023.8.23"
16+
"@hono/node-server": "^1.13.7",
17+
"hono": "^4.6.13"
2518
},
2619
"devDependencies": {
27-
"nodemon": "^3.0.1"
20+
"nodemon": "^3.1.9",
21+
"wrangler": "^3.94.0"
2822
}
2923
}

0 commit comments

Comments
 (0)