Commit d50a69e6 authored by Yechang's avatar Yechang
Browse files

chore(deployment): move to fly

parent 6346ec90
Loading
Loading
Loading
Loading

.dockerignore

0 → 100644
+18 −0
Original line number Diff line number Diff line
# flyctl launch added from .gitignore
**/.DS_Store
**/node_modules
build
.svelte-kit
package
**/.env
**/.env.*
!**/.env.example
# Sentry Config File
**/.sentryclirc

# flyctl launch added from node_modules/.ignored/tailwindcss/stubs/.gitignore
!node_modules/.ignored/tailwindcss/stubs/**/*

# flyctl launch added from node_modules/.pnpm/tailwindcss@3.4.1_ts-node@10.9.2_@types+node@20.11.24_typescript@5.3.3_/node_modules/tailwindcss/stubs/.gitignore
!node_modules/.pnpm/tailwindcss@3.4.1_ts-node@10.9.2_@types+node@20.11.24_typescript@5.3.3_/node_modules/tailwindcss/stubs/**/*
fly.toml
+12 −16
Original line number Diff line number Diff line
@@ -13,12 +13,9 @@ RUN pnpm fetch

COPY --chown=node:node . .
RUN pnpm install -r --offline
RUN pnpm prisma:generate

FROM builder as migration
CMD pnpm prisma:deploy
RUN pnpm run prisma:generate

FROM builder as building_stage
ENV NODE_ENV production

ARG ORIGIN=https://lms.sustech.cloud
@@ -30,28 +27,27 @@ ENV PUBLIC_COMMIT_SHORT_SHA $COMMIT_SHORT_SHA
ARG SENTRY_DSN
ENV PUBLIC_SENTRY_DSN $SENTRY_DSN

RUN NODE_OPTIONS=--max_old_space_size=4096 pnpm run build \
RUN NODE_OPTIONS=--max_old_space_size=4000 pnpm run build \
    && pnpm prune --production

FROM node:20-alpine
# ---

RUN echo "Asia/shanghai" > /etc/timezone
FROM node:20-alpine

USER node
ENV PORT 3000
ENV NODE_ENV production
ENV TZ="Asia/Shanghai"
WORKDIR /app

ARG ORIGIN=https://lms.sustech.cloud
ENV ORIGIN $ORIGIN

WORKDIR /home/app

COPY --from=building_stage --chown=node:node /home/node/package*.json ./
COPY --from=building_stage --chown=node:node /home/node/node_modules/ ./node_modules/
COPY --from=building_stage --chown=node:node /home/node/build/ ./build/
COPY --from=builder --chown=node:node /home/node/package*.json ./
COPY --from=builder --chown=node:node /home/node/node_modules/ ./node_modules/
COPY --from=builder --chown=node:node /home/node/.svelte-kit/ ./.svelte-kit/
COPY --from=builder --chown=node:node /home/node/build/ ./build/
COPY --from=builder --chown=node:node /home/node/prisma/ ./prisma/

HEALTHCHECK --interval=5s --timeout=3s \
    CMD wget --spider -q http://127.0.0.1:3000 || exit 1
    CMD wget --spider -q http://127.0.0.1:3000/api/healthCheck || exit 1
EXPOSE 3000

CMD ["node","build/index.js"]

fly.toml

0 → 100644
+52 −0
Original line number Diff line number Diff line
# fly.toml app configuration file generated for lms on 2024-08-11T17:51:30+08:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'lms'
primary_region = 'hkg'

[build]

[deploy]
  strategy = "canary"
  release_command = 'npx prisma migrate deploy'

[env]
  CLIENT_ID="19a8aebc-6626-492f-8112-ec0ec05f7ba5"
  CLIENT_CALLBACK="https://lms.sustech.cloud/auth/callback"

  MINIO_HOST="mirrors.sustech.edu.cn"
  MINIO_PORT="443"
  MINIO_USESSL="true"
  MINIO_USER="sustech-mirror"
  MINIO_BUCKET="mirrors3-ioj"

  QINIU_AK="AGgqR42nMMQ8eXztPE-7D7f0gdpptLAFl3BFVo-f"
  QINIU_CALLBACK_URL="https://lms.fly.dev/api/storage/callback"

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = 'suspend'
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

[checks]
  [checks.http_check]
    port = 3000
    type = 'http'
    interval = '15s'
    timeout = '10s'
    grace_period = '30s'
    method = 'get'
    path = '/api/healthCheck'

    [checks.http_check.headers]
      Content-Type = 'application/json'

[[vm]]
  memory = '512mb'
  cpu_kind = 'shared'
  cpus = 1
+2 −3
Original line number Diff line number Diff line
@@ -55,11 +55,10 @@
		"prisma": "^5.12.1",
		"prismjs": "^1.29.0",
		"refractor": "^4.8.1",
		"sass": "^1.71.1",
		"svelte": "^4.2.7",
		"svelte-check": "^3.6.0",
		"svelte-headless-table": "^0.18.2",
		"sveltekit-superforms": "^2.8.0",
		"sveltekit-superforms": "^2.16.1",
		"tailwindcss": "^3.3.6",
		"ts-node": "^10.9.2",
		"tslib": "^2.4.1",
@@ -67,7 +66,7 @@
		"vite": "^5.0.3",
		"vite-plugin-prismjs": "^0.0.11",
		"vite-tsconfig-paths": "^4.3.2",
		"vitest": "^1.3.1",
		"vitest": "^1.6.0",
		"vitest-mock-extended": "^1.3.1",
		"zod": "^3.22.4"
	},
+309 −234

File changed.

Preview size limit exceeded, changes collapsed.

Loading