diff --git a/Dockerfile b/Dockerfile index 8e0c42e89..6e9de0698 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,8 +14,8 @@ # ignore: all **/node_modules folders and .yarn/cache # ################################################################### -ARG NODE_VERSION=16 -ARG ALPINE_VERSION=3.15 +ARG NODE_VERSION=18 +ARG ALPINE_VERSION=3.18 FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS deps RUN apk add --no-cache rsync @@ -24,6 +24,7 @@ WORKDIR /workspace-install COPY yarn.lock .yarnrc.yml ./ COPY .yarn/ ./.yarn/ +COPY sh/ ./sh/ # Specific to monerepo's as docker COPY command is pretty limited # we use buidkit to prepare all files that are necessary for install @@ -34,17 +35,18 @@ COPY .yarn/ ./.yarn/ # - All package.json present in the host (root, apps/*, packages/*) # - All schema.prisma (cause prisma will generate a schema on postinstall) # -RUN --mount=type=bind,target=/docker-context \ - rsync -amv --delete \ +COPY . /workspace-install +RUN rsync -amv --delete \ --exclude='node_modules' \ --exclude='*/node_modules' \ --include='package.json' \ --include='schema.prisma' \ + --include='.env' \ --include='*/' --exclude='*' \ - /docker-context/ /workspace-install/; + /workspace-install/ /workspace-install/ # @see https://www.prisma.io/docs/reference/api-reference/environment-variables-reference#cli-binary-targets -ENV PRISMA_CLI_BINARY_TARGETS=linux-musl +# ENV PRISMA_CLI_BINARY_TARGETS=linux-musl # # To speed up installations, we override the default yarn cache folder @@ -60,9 +62,7 @@ ENV PRISMA_CLI_BINARY_TARGETS=linux-musl # Does not play well with buildkit on CI # https://github.com/moby/buildkit/issues/1673 -RUN --mount=type=cache,target=/root/.yarn3-cache,id=yarn3-cache \ - YARN_CACHE_FOLDER=/root/.yarn3-cache \ - yarn install --immutable --inline-builds +RUN yarn install --immutable --inline-builds ################################################################### @@ -80,14 +80,12 @@ COPY . . COPY --from=deps /workspace-install ./ # Optional: if the app depends on global /static shared assets like images, locales... -RUN yarn workspace nextjs-app share-static-hardlink && yarn workspace nextjs-app build - +RUN yarn workspace @teable-group/app share-static-hardlink && yarn g:build +RUN yarn workspace @teable-group/db-main-prisma prisma-db-push # Does not play well with buildkit on CI # https://github.com/moby/buildkit/issues/1673 -RUN --mount=type=cache,target=/root/.yarn3-cache,id=yarn3-cache \ - SKIP_POSTINSTALL=1 \ - YARN_CACHE_FOLDER=/root/.yarn3-cache \ - yarn workspaces focus nextjs-app --production +RUN SKIP_POSTINSTALL=1 \ + yarn workspaces focus --production -A ################################################################### # Stage 3: Extract a minimal image from the build # @@ -99,40 +97,50 @@ WORKDIR /app ENV NODE_ENV production -RUN addgroup --system --gid 1001 nodejs && adduser --system --uid 1001 nextjs +# RUN addgroup --system --gid 1001 nodejs && adduser --system --uid 1001 nextjs -COPY --from=builder /app/apps/nextjs-app/next.config.mjs \ +COPY --from=builder /app/apps/nextjs-app/next.config.js \ /app/apps/nextjs-app/next-i18next.config.js \ /app/apps/nextjs-app/package.json \ + /app/apps/nextjs-app/.env \ ./apps/nextjs-app/ COPY --from=builder /app/apps/nextjs-app/public ./apps/nextjs-app/public -COPY --from=builder --chown=nextjs:nodejs /app/apps/nextjs-app/.next ./apps/nextjs-app/.next +COPY --from=builder /app/apps/nestjs-backend/package.json ./apps/nestjs-backend/ +COPY --from=builder /app/apps/nextjs-app/.next ./apps/nextjs-app/.next +COPY --from=builder /app/apps/nestjs-backend/package.json ./apps/nestjs-backend/ +COPY --from=builder /app/apps/nestjs-backend/dist ./apps/nestjs-backend/dist +COPY --from=builder /app/packages/core/ ./packages/core/ +COPY --from=builder /app/packages/db-main-prisma/ ./packages/db-main-prisma/ +COPY --from=builder /app/packages/common-i18n/ ./packages/common-i18n/ +COPY --from=builder /app/packages/openapi/ ./packages/openapi/ COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/package.json ./package.json -USER nextjs +# USER nextjs -EXPOSE ${NEXTJS_APP_PORT:-3000} +ENV PORT=3000 +EXPOSE ${PORT:-3000} ENV NEXT_TELEMETRY_DISABLED 1 -CMD ["./node_modules/.bin/next", "start", "apps/nextjs-app/", "-p", "${NEXTJS_APP_PORT:-3000}"] +WORKDIR /app/apps/nestjs-backend + +CMD ["node", "./dist"] ################################################################### # Optional: develop locally # ################################################################### -FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS develop -ENV NODE_ENV=development +# FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS develop +# ENV NODE_ENV=development -WORKDIR /app +# WORKDIR /app -COPY --from=deps /workspace-install ./ +# COPY --from=deps /workspace-install ./ -EXPOSE ${NEXTJS_APP_PORT:-3000} +# EXPOSE ${PORT:-3000} -WORKDIR /app/apps/nextjs-app - -CMD ["yarn", "dev", "-p", "${NEXTJS_APP_PORT:-3000}"] +# WORKDIR /app/apps/nextjs-app +# CMD ["yarn", "dev", "-p", "${PORT:-3000}"] diff --git a/Procfile b/Procfile new file mode 100644 index 000000000..3d825c7fb --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: yarn app:start diff --git a/apps/nestjs-backend/package.json b/apps/nestjs-backend/package.json index 03e66b35d..11a721310 100644 --- a/apps/nestjs-backend/package.json +++ b/apps/nestjs-backend/package.json @@ -51,6 +51,7 @@ }, "devDependencies": { "@faker-js/faker": "8.0.2", + "@nestjs/cli": "10.1.10", "@nestjs/testing": "9.3.9", "@teable-group/eslint-config-bases": "workspace:^", "@types/cors": "2.8.12", diff --git a/apps/nestjs-backend/src/features/automation/workflow/trigger/workflow-trigger.service.ts b/apps/nestjs-backend/src/features/automation/workflow/trigger/workflow-trigger.service.ts index 455109422..d86f3e508 100644 --- a/apps/nestjs-backend/src/features/automation/workflow/trigger/workflow-trigger.service.ts +++ b/apps/nestjs-backend/src/features/automation/workflow/trigger/workflow-trigger.service.ts @@ -57,7 +57,7 @@ export class WorkflowTriggerService { const result = await (prisma || this.prisma).$transaction(async (tx) => { return tx.automationWorkflowTrigger.deleteMany({ - where: { triggerId, OR: { workflowId } }, + where: { triggerId, OR: [{ workflowId }] }, }); }); diff --git a/apps/nextjs-app/package.json b/apps/nextjs-app/package.json index 9fbec8aa3..a9cdf6d70 100644 --- a/apps/nextjs-app/package.json +++ b/apps/nextjs-app/package.json @@ -124,7 +124,6 @@ "@tanstack/react-query": "4.13.0", "@teable-group/common-i18n": "workspace:^", "@teable-group/core": "workspace:^", - "@teable-group/db-main-prisma": "workspace:^", "@teable-group/openapi": "workspace:^", "@teable-group/sdk": "workspace:^", "@teable/sharedb": "3.3.11", diff --git a/apps/nextjs-app/src/features/app/components/ThemePicker.tsx b/apps/nextjs-app/src/features/app/components/ThemePicker.tsx index ef1814f98..da352f7ba 100644 --- a/apps/nextjs-app/src/features/app/components/ThemePicker.tsx +++ b/apps/nextjs-app/src/features/app/components/ThemePicker.tsx @@ -7,14 +7,15 @@ import { DropdownMenuRadioItem, DropdownMenuTrigger, } from '@teable-group/ui-lib/shadcn/ui/dropdown-menu'; +import classNames from 'classnames'; export const ThemePicker: React.FC<{ className?: string }> = ({ className }) => { const { theme, isAutoTheme, setTheme } = useTheme(); const value = isAutoTheme ? '' : theme; return ( - @@ -27,6 +28,7 @@ export const ThemePicker: React.FC<{ className?: string }> = ({ className }) => {[ThemeKey.Light, ThemeKey.Dark].map((item) => { return ( = ({ className }) => ); })} - auto + system diff --git a/apps/nextjs-app/src/features/app/components/toggle-side-bar/AutoPane.tsx b/apps/nextjs-app/src/features/app/components/toggle-side-bar/AutoPane.tsx index 585a6f534..4760bb7ad 100644 --- a/apps/nextjs-app/src/features/app/components/toggle-side-bar/AutoPane.tsx +++ b/apps/nextjs-app/src/features/app/components/toggle-side-bar/AutoPane.tsx @@ -66,7 +66,7 @@ export const AutoPane: React.FC<{ {left} {center} - + {right} diff --git a/apps/nextjs-app/src/pages/space/index.tsx b/apps/nextjs-app/src/pages/space/index.tsx index 42587d5a3..7da41a850 100644 --- a/apps/nextjs-app/src/pages/space/index.tsx +++ b/apps/nextjs-app/src/pages/space/index.tsx @@ -7,7 +7,7 @@ import type { NextPageWithLayout } from '../_app'; const Space: NextPageWithLayout = () => { return ( -
+

Welcome to Teable

); diff --git a/package.json b/package.json index 2d5feb751..ea4cbc995 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,6 @@ "g:share-static-symlink": "yarn workspaces foreach -pv --include '*-app' run share-static-symlink", "g:share-static-hardlink": "yarn workspaces foreach -pv --include '*-app' run share-static-hardlink", "clean:global-cache": "rimraf --no-glob ./.cache", - "app:start": "yarn workspace @teable-group/backend run start", "apps:build": "yarn workspaces foreach -ptv --include '*-app' run build", "apps:clean": "yarn workspaces foreach -ptv --include '*-app' run clean", "packages:build": "yarn workspaces foreach -ptv --include '@teable-group/*' run build", @@ -67,7 +66,7 @@ "check:install": "yarn dlx @yarnpkg/doctor@3.1.4 .", "check:renovate:config": "docker run -v renovate.json5:/usr/src/app/renovate.json5 -it renovate/renovate renovate-config-validator", "install:playwright": "playwright install", - "postinstall": "is-ci || yarn husky install", + "postinstall": "node ./sh/postinstall.js", "generate-openapi-types": "node ./sh/generate-openapi-types.mjs" }, "helpResolutions": { @@ -103,8 +102,7 @@ }, "engines": { "node": "^14.13.1 || >=16.0.0", - "yarn": ">=1.22.0", - "npm": "please-use-yarn" + "yarn": ">=1.22.0" }, "packageManager": "yarn@4.0.0-rc.26" } diff --git a/packages/db-main-prisma/README.md b/packages/db-main-prisma/README.md index 4022be2d7..c54aa9a98 100644 --- a/packages/db-main-prisma/README.md +++ b/packages/db-main-prisma/README.md @@ -17,8 +17,6 @@ Start the database with `docker-compose up database` then run ```bash cd packages/db-main-prisma yarn prisma-db-push -yarn prisma-migrate dev -yarn prisma-migrate-reset ``` > See the .env(.local|.production|.development) file to edit the connection. diff --git a/packages/db-main-prisma/package.json b/packages/db-main-prisma/package.json index c97b93412..9fdbfd319 100644 --- a/packages/db-main-prisma/package.json +++ b/packages/db-main-prisma/package.json @@ -34,9 +34,9 @@ "postinstall": "yarn prisma generate" }, "dependencies": { - "@prisma/client": "4.7.1", + "@prisma/client": "5.0.0", "dotenv-flow-cli": "1.0.0", - "prisma": "4.7.1" + "prisma": "5.0.0" }, "devDependencies": { "@faker-js/faker": "8.0.2", diff --git a/sh/postinstall.js b/sh/postinstall.js new file mode 100644 index 000000000..0ff4f1b9d --- /dev/null +++ b/sh/postinstall.js @@ -0,0 +1,7 @@ +if (!process.env.SKIP_POSTINSTALL) { + const isCI = require('is-ci'); + const { execSync } = require('child_process'); + if (!isCI) { + execSync('yarn husky install', { stdio: 'inherit' }); + } +} diff --git a/yarn.lock b/yarn.lock index bb3652f38..c68cd4970 100644 Binary files a/yarn.lock and b/yarn.lock differ