Skip to content

Commit 7241f6f

Browse files
author
AiQL.com
committed
update runtime
1 parent 7576e41 commit 7241f6f

File tree

3 files changed

+33
-22
lines changed

3 files changed

+33
-22
lines changed

Dockerfile

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,37 @@
1-
FROM node:lts-alpine
2-
RUN npm install pm2 -g
1+
# use the official Bun image
2+
# see all versions at https://hub.docker.com/r/oven/bun/tags
3+
FROM oven/bun:slim AS base
4+
WORKDIR /usr/src/app
35

4-
WORKDIR /app
6+
# install dependencies into temp directory
7+
# this will cache them and speed up future builds
8+
FROM base AS install
9+
RUN mkdir -p /temp/dev
10+
COPY package.json package-lock.json /temp/dev/
11+
RUN cd /temp/dev && bun install --frozen-lockfile
512

6-
COPY package*.json ./
7-
8-
RUN npm install ci
13+
# install with --production (exclude devDependencies)
14+
RUN mkdir -p /temp/prod
15+
COPY package.json package-lock.json /temp/prod/
16+
RUN cd /temp/prod && bun install --frozen-lockfile --production
917

18+
# copy node_modules from temp directory
19+
# then copy all (non-ignored) project files into the image
20+
FROM base AS prerelease
21+
COPY --from=install /temp/dev/node_modules node_modules
1022
COPY . .
1123

12-
CMD ["pm2-runtime", "app.js"]
24+
# [optional] tests & build
25+
ENV NODE_ENV=production
26+
# RUN bun test
27+
# RUN bun run build
28+
29+
# copy production dependencies and source code into final image
30+
FROM base AS release
31+
COPY --from=install /temp/prod/node_modules node_modules
32+
COPY --from=prerelease /usr/src/app/app.js .
33+
COPY --from=prerelease /usr/src/app/package.json .
34+
35+
# run the app
36+
USER bun
37+
ENTRYPOINT [ "bun", "run", "app.js" ]

README.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,6 @@ You can change default port and default target by setting `-e` in docker, which
3232
| PORT | 9017 |
3333
| TARGET | https://api.openai.com |
3434

35-
## How to maintain
36-
Use PM2 to scale up this proxy application accross CPU(s):
37-
- Listing managed processes
38-
> ```shell
39-
> docker exec -it <container-id> pm2 list
40-
> ```
41-
- Monitoring CPU/Usage of each process
42-
> ```shell
43-
> docker exec -it <container-id> pm2 monit
44-
> ```
45-
- 0sec downtime reload all applications
46-
> ```shell
47-
> docker exec -it <container-id> pm2 reload allk
48-
> ```
4935

5036
## How to dev
5137

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openai-proxy-docker",
3-
"version": "1.0.0",
3+
"version": "1.3.0",
44
"description": "OpenAI API Proxy by Docker",
55
"main": "app.js",
66
"keywords": [],

0 commit comments

Comments
 (0)