Skip to content

Commit

Permalink
chore: 调整编译工具链
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Aug 27, 2024
1 parent a6bb27f commit 33ae95a
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 28 deletions.
18 changes: 0 additions & 18 deletions .dockerignore

This file was deleted.

6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
FROM node:20 as DEV
FROM node:alpine as DEV

WORKDIR /app
COPY package.json vite.config.ts tsconfig.json ./
COPY src ./src
CMD ["/bin/bash"]
RUN npm install && npm run build:local

FROM node:20 as PROD
FROM node:alpine as PROD

WORKDIR /app
COPY --from=DEV /app/dist /app/dist
COPY --from=DEV /app/package.json /app/
RUN npm install --only=production --omit=dev
RUN apk add --no-cache sqlite
EXPOSE 8787
CMD ["npm", "run", "start:dist"]
2 changes: 1 addition & 1 deletion doc/en/LOCAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ docker build -t chatgpt-telegram-bot:latest .
### 2. Run container

```bash
docker run -v $(pwd)/config.json:/app/config.json $(pwd)/config.toml:/app/config.toml -p 8787:8787 chatgpt-telegram-bot:latest --name chatgpt-telegram-bot
docker run -d -p 8787:8787 -v $(pwd)/config.json:/app/config.json:ro -v $(pwd)/wrangler.toml:/app/config.toml:ro chatgpt-telegram-worker:latest
```


Expand Down
4 changes: 1 addition & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
version: '3.8'
name: chatgpt-telegram-bot
name: chatgpt-telegram-worker
services:
chatgpt-telegram-worker:
build: .
container_name: chatgpt-telegram-worker
ports:
- "8787:8787"
volumes:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"deploy:dist": "wrangler deploy",
"deploy:build": "npm run build && wrangler deploy",
"start:dist": "node dist/index.js",
"start:local": "CONFIG_PATH=./config.json TOML_PATH=./wrangler.toml tsx index.ts",
"start:local": "CONFIG_PATH=./config.json TOML_PATH=./wrangler.toml tsx src/adapter/local.ts",
"start:debug": "wrangler dev --local"
},
"dependencies": {
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { nodeResolve } from '@rollup/plugin-node-resolve';
import cleanup from 'rollup-plugin-cleanup';
import checker from 'vite-plugin-checker';
import dts from 'vite-plugin-dts';
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore
import nodeExternals from 'rollup-plugin-node-externals'

import nodeExternals from 'rollup-plugin-node-externals';

const { BUILD_MODE } = process.env;

Expand All @@ -30,7 +30,7 @@ const plugins: Plugin[] = [
nodeExternals(),
];
const define: Record<string, string> = {};
const entry = path.resolve(__dirname, BUILD_MODE === 'local' ? 'src/entry/local.ts' : 'src/index.ts');
const entry = path.resolve(__dirname, BUILD_MODE === 'local' ? 'src/adapter/local.ts' : 'src/index.ts');

if (BUILD_MODE !== 'local') {
const TIMESTAMP_FILE = './dist/timestamp';
Expand Down

0 comments on commit 33ae95a

Please sign in to comment.