Skip to content

Commit

Permalink
chore: 修改docker编译配置
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Nov 13, 2024
1 parent be75d39 commit b229427
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 29 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 20
- run: npm install -g pnpm
- run: pnpm install
- run: pnpm run build
- run: node ./dist/index.js
- run: make install && make all
4 changes: 1 addition & 3 deletions .github/workflows/cloudflare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ jobs:
cat << 'EOF' > wrangler.toml
${{secrets.WRANGLER_TOML}}
EOF
- run: npm install -g pnpm
- run: pnpm install
- run: pnpm run build
- run: make install && make workers
- run: CLOUDFLARE_API_TOKEN=${{ secrets.CF_API_TOKEN }} pnpm run wrangler deploy --config=wrangler.toml > /dev/null

- name: Check CF_WORKERS_DOMAIN exists
Expand Down
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FROM node:alpine AS build
WORKDIR /app
COPY package.json tsconfig.json vite.config.ts ./
RUN npm install
COPY packages src
RUN npm run build:local
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN npm install && npm install -g pnpm
COPY . .
RUN pnpm install && pnpm -r run build


FROM node:alpine AS production
WORKDIR /app
COPY package.json ./
RUN npm install --omit=dev
COPY --from=build /app/dist ./dist
COPY packages/apps/local/package.docker.json package.json
RUN npm install
COPY --from=build /app/packages/apps/local/dist/index.js index.js
EXPOSE 8787
CMD ["npm", "run", "start:dist"]
CMD ["npm", "run", "start"]
53 changes: 53 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
export PATH := $(shell pwd)/node_modules/.bin:$(PATH)
SHELL := /bin/bash

.PHONY: init
init:
npm install -g pnpm
pnpm install

.PHONY: version
version:
pnpm run version

.PHONY: core
core: version
pnpm run --filter @chatgpt-telegram-workers/core build

.PHONY: next
next: core
pnpm run --filter @chatgpt-telegram-workers/next build

.PHONY: local
local: next
pnpm run --filter @chatgpt-telegram-workers/local build

.PHONY: vercel
vercel: core
pnpm run --filter @chatgpt-telegram-workers/vercel build

.PHONY: workers
workers: core
pnpm run --filter @chatgpt-telegram-workers/workers build
cp -r packages/apps/workers/dist/* dist/

.PHONY: workers-next
workers-next: next
pnpm run --filter @chatgpt-telegram-workers/workers build

.PHONY: all
all:
pnpm -r run build

.PHONY: docker
docker:
docker build -t chatgpt-telegram-workers:latest .

.PHONY: docker-all
docker-all:
docker build --platform linux/amd64,linux/arm64 -t tbxark/chatgpt-telegram-workers:latest --push .

.PHONY: deploy-workers
deploy-workers: workers
wrangler deploy --config=wrangler.toml

3 changes: 1 addition & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ services:
volumes:
- ./config.json:/app/config.json:ro # change `./config.json` to your local path
- ./wrangler.toml:/app/wrangler.toml:ro # change `./wrangler.toml` to your local path
network_mode: "host" # If you access the proxy port based on the host
entrypoint: ["npm", "run", "start:dist"]
network_mode: "host" # If you access the proxy port based on the host
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
"scripts": {
"lint": "eslint --fix *.js *.ts packages plugins scripts",
"version": "tsx scripts/gen-version.ts",
"build": "pnpm run version && pnpm -r run build && cp packages/apps/workers/dist/index.js dist/index.js",
"deploy:dist": "wrangler deploy",
"deploy:build": "pnpm run build && wrangler deploy",
"build:core": "make core",
"build:next": "make next",
"build:local": "make local",
"build:vercel": "make vercel",
"build:workers": "make workers",
"build:workers-next": "make workers-next",
"build:all": "make all",
"wrangler": "wrangler"
},
"workspaces": [
Expand Down
11 changes: 11 additions & 0 deletions packages/apps/local/package.docker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@chatgpt-telegram-workers/local",
"type": "module",
"version": "1.10.2",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"cloudflare-worker-adapter": "^1.3.3"
}
}
9 changes: 0 additions & 9 deletions packages/apps/vercel/vercel.json

This file was deleted.

9 changes: 9 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"buildCommand": "pnpm run build",
"builds": [
{ "src": "packages/apps/vercel/dist//**", "use": "@vercel/node" }
],
"routes": [
{ "src": "/(.*)", "dest": "/packages/apps/vercel/dist/**" }
]
}

0 comments on commit b229427

Please sign in to comment.