feat(package): adjust packages to workspaces

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2022-11-02 16:24:45 +01:00 committed by David Mehren
parent 046a173891
commit 2241a3faea
26 changed files with 5157 additions and 11075 deletions

View file

@ -71,7 +71,7 @@ jobs:
container:
image: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-ci:${{ github.sha }}
steps:
- run: cd /usr/src/app && yarn run test
- run: cd /usr/src/app/backend && yarn run test
sqlite-e2e:
runs-on: ubuntu-latest
@ -80,7 +80,7 @@ jobs:
container:
image: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-ci:${{ github.sha }}
steps:
- run: cd /usr/src/app && yarn run test:e2e
- run: cd /usr/src/app/backend && yarn run test:e2e
build-prod:
runs-on: ubuntu-latest

View file

@ -79,7 +79,7 @@ jobs:
uses: docker/build-push-action@v3
with:
push: true
file: frontend/Dockerfile
file: frontend/docker/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha

View file

@ -87,7 +87,7 @@ Files: frontend/public/robots.txt
Copyright: 2021 The HedgeDoc developers (see AUTHORS file)
License: CC0-1.0
Files: frontend/.yarnrc.yml
Files: .yarnrc.yml
Copyright: 2021 The HedgeDoc developers (see AUTHORS file)
License: CC0-1.0

11
.yarnrc.yml Normal file
View file

@ -0,0 +1,11 @@
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
yarnPath: .yarn/releases/yarn-3.3.0.cjs

View file

@ -52,6 +52,9 @@ module.exports = {
jest: true,
},
rules: {
"prettier/prettier": ["error",
require('./.prettierrc.json')
],
'local-rules/correct-logger-context': 'error',
'func-style': ['error', 'declaration'],
'@typescript-eslint/no-unused-vars': [

View file

@ -1,11 +0,0 @@
nodeLinker: node-modules
plugins:
- path: ../.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
- path: ../.yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
- path: ../.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
yarnPath: ../.yarn/releases/yarn-3.3.0.cjs

View file

@ -1,3 +0,0 @@
SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
SPDX-License-Identifier: CC0-1.0

View file

@ -16,60 +16,71 @@ FROM docker.io/node:19-alpine@sha256:80844b6643f239c87fceae51e6540eeb054fc7114d9
RUN apk add --no-cache tini
ENTRYPOINT ["tini"]
ENV YARN_CACHE_FOLDER /tmp/.yarn
USER node
WORKDIR /usr/src/app
COPY --chown=node .yarn ../.yarn
COPY --chown=node backend/package.json backend/yarn.lock backend/.yarnrc.yml ./
## Stage 1: Code with all dependencies
FROM base as code-with-deps
USER node
WORKDIR /usr/src/app
COPY --chown=node .yarn/plugins .yarn/plugins
COPY --chown=node .yarn/releases .yarn/releases
COPY --chown=node .yarnrc.yml .yarnrc.yml
COPY --chown=node package.json package.json
COPY --chown=node yarn.lock yarn.lock
COPY --chown=node backend/package.json backend/
COPY --chown=node frontend/package.json frontend/
# Install dependencies first to not invalidate the cache on every source change
RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/tmp/.yarn \
YARN_CACHE_FOLDER=/tmp/.yarn yarn install --immutable
COPY --chown=node backend/nest-cli.json backend/tsconfig.json backend/tsconfig.build.json ./
COPY --chown=node backend/src src
yarn install --immutable && yarn workspaces focus @hedgedoc/backend
COPY --chown=node backend/nest-cli.json backend/tsconfig.json backend/tsconfig.build.json backend/
COPY --chown=node backend/src backend/src
## Stage 2a: Dev config files and tests
FROM code-with-deps as development
USER node
WORKDIR /usr/src/app
COPY --chown=node backend/.eslintrc.js backend/eslint-local-rules.js backend/.prettierrc backend/jest-e2e.json ./
COPY --chown=node backend/test test
COPY --chown=node eslint-local-rules.js eslint-local-rules.js
COPY --chown=node backend/.eslintrc.js backend/.prettierrc.json backend/jest-e2e.json backend/
COPY --chown=node backend/test backend/test
CMD ["node", "-r", "ts-node/register", "src/main.ts"]
## Stage 2b: Compile TypeScript
FROM code-with-deps as builder
USER node
WORKDIR /usr/src/app
WORKDIR /usr/src/app/backend
RUN yarn run build
## Stage 3a: Install only prod dependencies
FROM code-with-deps as prod-dependencies
USER node
WORKDIR /usr/src/app
## Stage 3: Final image, only production dependencies
RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/tmp/.yarn \
yarn workspaces focus --production @hedgedoc/backend
## Stage 3a: Final image, only production dependencies
FROM base as prod
LABEL org.opencontainers.image.title='HedgeDoc production image'
LABEL org.opencontainers.image.url='https://hedgedoc.org'
LABEL org.opencontainers.image.source='https://github.com/hedgedoc/hedgedoc'
LABEL org.opencontainers.image.documentation='https://github.com/hedgedoc/hedgedoc/blob/develop/docker/README.md'
LABEL org.opencontainers.image.documentation='https://github.com/hedgedoc/hedgedoc/blob/develop/docs/docker/README.md'
LABEL org.opencontainers.image.licenses='AGPL-3.0'
USER node
WORKDIR /usr/src/app
ENV NODE_ENV=production
COPY --chown=node --from=builder /usr/src/app/dist ./dist
COPY --chown=node --from=builder /usr/src/app/backend/dist ./
COPY --chown=node backend/package.json package.json
COPY --chown=node --from=prod-dependencies /usr/src/app/node_modules ./node_modules
RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/tmp/.yarn \
YARN_CACHE_FOLDER=/tmp/.yarn yarn workspaces focus --all --production
CMD ["node", "dist/main.js"]
CMD ["node", "main.js"]

View file

@ -1,6 +1,6 @@
{
"name": "hedgedoc",
"version": "2.0.0",
"name": "@hedgedoc/backend",
"version": "2.0.0-dev",
"description": "Realtime collaborative markdown notes on all platforms.",
"author": "",
"private": true,
@ -141,8 +141,5 @@
"github-actions"
]
},
"packageManager": "yarn@3.3.0",
"resolutions": {
"yjs": "13.5.43"
}
"packageManager": "yarn@3.3.0"
}

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,9 @@
{
/**
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: CC0-1.0
**/
module.exports = {
"root": true,
"parserOptions": {
"tsconfigRootDir": ".",
@ -7,7 +12,9 @@
]
},
"rules": {
"prettier/prettier": "error",
"prettier/prettier": ["error",
require('./.prettierrc.json')
],
"no-use-before-define": "off",
"no-debugger": "warn",
"default-param-last": "off",

View file

@ -1,7 +0,0 @@
nodeLinker: node-modules
plugins:
- path: ../.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
yarnPath: ../.yarn/releases/yarn-3.3.0.cjs

View file

@ -1,36 +0,0 @@
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: CC-BY-SA-4.0
# BUILD
FROM node:18-alpine@sha256:9eff44230b2fdcca57a73b8f908c8029e72d24dd05cac5339c79d3dedf6b208b AS builder
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ARG BUILD_VERSION=CLIENT_VERSION_MISSING
WORKDIR /app
COPY --chown=node .yarn ../.yarn
COPY --chown=node frontend ./
RUN rm -rf public/public && \
rm -rf src/pages/api && \
yarn install --immutable && \
sed -i "s/CLIENT_VERSION_MISSING/${BUILD_VERSION}/" src/version.json && \
yarn build
# RUNNER
FROM node:18-alpine@sha256:9eff44230b2fdcca57a73b8f908c8029e72d24dd05cac5339c79d3dedf6b208b
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
WORKDIR /app
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder --chown=node:node /app/.next/static ./.next/static
COPY --from=builder --chown=node:node /app/.next/standalone ./
USER node
ENV PORT 3001
EXPOSE 3001/tcp
CMD ["node", "server.js"]

View file

@ -0,0 +1,48 @@
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: CC-BY-SA-4.0
# BUILD
FROM docker.io/node:18-alpine@sha256:9eff44230b2fdcca57a73b8f908c8029e72d24dd05cac5339c79d3dedf6b208b AS builder
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ARG BUILD_VERSION=CLIENT_VERSION_MISSING
ENV YARN_CACHE_FOLDER /tmp/.yarn
USER node
WORKDIR /usr/src/app
COPY --chown=node .yarn/plugins .yarn/plugins
COPY --chown=node .yarn/releases .yarn/releases
COPY --chown=node .yarnrc.yml .yarnrc.yml
COPY --chown=node package.json package.json
COPY --chown=node yarn.lock yarn.lock
COPY --chown=node backend/package.json backend/
COPY --chown=node frontend frontend
RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/tmp/.yarn \
yarn install --immutable && yarn workspaces focus @hedgedoc/frontend
WORKDIR /usr/src/app/frontend
RUN rm -rf public/public && \
rm -rf src/pages/api && \
sed -i "s/CLIENT_VERSION_MISSING/${BUILD_VERSION}/" src/version.json
RUN yarn build
# RUNNER
FROM docker.io/node:18-alpine@sha256:9eff44230b2fdcca57a73b8f908c8029e72d24dd05cac5339c79d3dedf6b208b
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
WORKDIR /usr/src/app
COPY --from=builder --chown=node:node /usr/src/app/frontend/.next/standalone ./
COPY --from=builder --chown=node:node /usr/src/app/frontend/.next/static ./.next/static
COPY --from=builder /usr/src/app/frontend/next.config.js next.config.js
COPY --from=builder /usr/src/app/frontend/public ./public
USER node
ENV PORT 3001
EXPOSE 3001/tcp
CMD ["node", "frontend/server.js"]

View file

@ -85,7 +85,10 @@ const rawNextConfig = {
}
])
},
output: 'standalone'
output: 'standalone',
experimental: {
outputFileTracingRoot: path.join(__dirname, '../')
}
}
const completeNextConfig = withBundleAnalyzer(rawNextConfig)

View file

@ -1,5 +1,5 @@
{
"name": "@hedgedoc/react-client",
"name": "@hedgedoc/frontend",
"version": "2.0.0-dev",
"private": true,
"license": "AGPL-3.0",
@ -79,6 +79,7 @@
"i18next": "22.0.6",
"i18next-browser-languagedetector": "7.0.1",
"i18next-resources-to-backend": "1.0.0",
"isomorphic-ws": "5.0.0",
"js-yaml": "4.1.0",
"katex": "0.16.3",
"luxon": "3.1.1",
@ -146,6 +147,7 @@
"@types/sass": "1.43.1",
"@types/testing-library__jest-dom": "5.14.5",
"@types/uuid": "8.3.4",
"@types/ws": "8.5.3",
"@typescript-eslint/eslint-plugin": "5.43.0",
"@typescript-eslint/parser": "5.43.0",
"csstype": "3.1.1",
@ -171,12 +173,5 @@
"ts-node": "10.9.1",
"typescript": "4.9.3"
},
"packageManager": "yarn@3.3.0",
"resolutions": {
"domhandler": "5.0.3",
"@codemirror/state": "6.1.4",
"@codemirror/view": "6.6.0",
"@codemirror/language": "6.3.1",
"yjs": "13.5.43"
}
"packageManager": "yarn@3.3.0"
}

View file

@ -3,15 +3,15 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import {
encodeAwarenessUpdateMessage,
encodeCompleteAwarenessStateRequestMessage,
encodeDocumentUpdateMessage,
WebsocketTransporter
} from '@hedgedoc/realtime'
import type { Doc } from 'yjs'
import WebSocket from 'isomorphic-ws'
import type { Awareness } from 'y-protocols/awareness'
import type { Doc } from 'yjs'
/**
* Handles the communication with the realtime endpoint of the backend and synchronizes the given y-doc and awareness with other clients.

View file

@ -17,5 +17,5 @@
"types": ["node", "@testing-library/jest-dom", "@types/jest"]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules", "cypress", "cypress.config.ts"]
"exclude": ["node_modules", "cypress", "cypress.config.ts", ".eslintrc.js"]
}

View file

@ -1,3 +0,0 @@
SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
SPDX-License-Identifier: CC0-1.0

17
package.json Normal file
View file

@ -0,0 +1,17 @@
{
"name": "hedgedoc",
"version": "2.0.0-dev",
"private": true,
"workspaces": [
"backend",
"frontend"
],
"packageManager": "yarn@3.3.0",
"resolutions": {
"domhandler": "5.0.3",
"yjs": "13.5.42",
"@codemirror/state": "6.1.4",
"@codemirror/view": "6.6.0",
"@codemirror/language": "6.3.1"
}
}

View file

@ -1,3 +1,3 @@
SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
SPDX-License-Identifier: CC0-1.0
SPDX-License-Identifier: AGPL-3.0-only

File diff suppressed because it is too large Load diff