Skip to content

Commit

Permalink
feat(server): add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamerblue committed Sep 19, 2024
1 parent 4274771 commit 8381b84
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 10 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build Server and Push to Docker Hub
on:
push:
branches:
- master
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: v0.9.1
driver-opts: |
image=moby/buildkit:v0.10.6
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push Image
uses: docker/build-push-action@v3.2.0
with:
context: ./
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/thenac_paste:latest
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM algoux/nodebase:16

WORKDIR /app/

RUN npm install -g pnpm@8
COPY common /tmp/common
COPY server /tmp/server
RUN cd /tmp/server && pnpm i --frozen-lockfile && npm run build && cp -r /tmp/server/app /app && mv /tmp/server/node_modules /app/node_modules && rm -rf /tmp/{common,server}

ENV PATH="/app/node_modules/pm2/bin:${PATH}"
CMD npm run deploy:foreground
4 changes: 2 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"init": "pnpm i --frozen-lockfile",
"dev": "cross-env NODE_ENV=development tsnd --respawn --rs --transpile-only -P tsconfig.json --unhandled-rejections=warn --inspect=127.0.0.1:9232 src/index.ts",
"dev:job:clear": "cross-env NODE_ENV=development tsnd --respawn --rs --transpile-only -P tsconfig.json --unhandled-rejections=warn --inspect=127.0.0.1:9233 src/jobs/clear.ts",
"build": "rimraf app && tsc -p tsconfig.json && copyfiles -u1 \"src/**/*.{js,lua}\" app",
"build": "rimraf app && tsc -p tsconfig.json && copyfiles -u1 \"src/**/*.{js,lua}\" app/server/src && copyfiles \"{package.json,pnpm-lock.yaml,pm2.config.js}\" app",
"start": "cross-env NODE_ENV=production node --unhandled-rejections=warn app/index.js",
"deploy": "cross-env NODE_ENV=production pm2 pm2.config.js",
"deploy:foreground": "cross-env NODE_ENV=production pm2-runtime pm2.config.js"
Expand Down Expand Up @@ -50,7 +50,7 @@
"@types/fs-extra": "^9.0.13",
"@types/ip": "^1.1.3",
"@types/koa-favicon": "^2.0.21",
"@types/lodash": "^4.17.7",
"@types/lodash": "~4.14.202",
"@types/node": "^16.18.69",
"@types/statuses": "^2.0.4",
"copyfiles": "^2.4.1",
Expand Down
4 changes: 2 additions & 2 deletions server/pm2.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const apps = [
{
name: 'paste-server',
script: `./app/index.js`,
script: `./server/src/index.js`,
log_date_format: 'YYYY-MM-DD HH:mm:ss',
exec_mode: 'cluster',
max_memory_restart: '256M',
Expand All @@ -18,7 +18,7 @@ const apps = [
},
{
name: 'paste-job-clear',
script: `./app/jobs/clear.js`,
script: `./server/src/jobs/clear.js`,
log_date_format: 'YYYY-MM-DD HH:mm:ss',
exec_mode: 'fork',
max_memory_restart: '128M',
Expand Down
10 changes: 5 additions & 5 deletions server/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/src/modules/piece/piece.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { AddPieceReqDTO, AddPieceRespDTO } from './piece.dto';
import MiscUtils from '@server/utils/misc.util';
import QCloudCosUtils from '@server/utils/qcloud-cos.util';
import { RateLimitIp } from '@server/middlewares/rate-limit.middleware';
import IndexConfig from '../../../../common/configs/index.json';
import IndexConfig from '@root/common/configs/index.json';

@ApiController()
export default class PieceController {
Expand Down

0 comments on commit 8381b84

Please sign in to comment.