From 47a3cd0edeb1dc6d1559014a7bbcf79a3ec9884a Mon Sep 17 00:00:00 2001 From: Vozhak Date: Fri, 17 May 2024 13:44:22 +0200 Subject: [PATCH] Dockerfile added --- .dockerignore | 2 ++ Dockerfile | 17 +++++++++++++++++ package.json | 2 +- vite.config.ts | 29 +++++++++++++++++++++++++++++ yarn.lock | 18 ++++-------------- 5 files changed, 53 insertions(+), 15 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..afff1aff1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules/ +.dockerignore \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..4fa01a804 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM node:alpine + +WORKDIR "/app" + +# Copy package.json and package-lock.json +COPY package.json ./ +COPY yarn.lock ./ + +# Install npm production packages +RUN yarn + +COPY . /app + +EXPOSE 3000 +EXPOSE 3001 + +CMD [ "yarn", "start"] \ No newline at end of file diff --git a/package.json b/package.json index ddf0c03c4..0705902e6 100644 --- a/package.json +++ b/package.json @@ -150,7 +150,7 @@ "start": "cross-env NODE_ENV=development concurrently yarn:start:react yarn:start:api", "start:ci": "cross-env NODE_ENV=test concurrently yarn:start:react:proxy-server yarn:start:api", "prestart:ci": "yarn predev:cognito:ci", - "start:react": "vite", + "start:react": "vite --host", "start:empty": "cross-env NODE_ENV=development EMPTY_SEED=true concurrently yarn:start:react yarn:start:api:watch", "lint": "eslint && prettier --check \"**/**.{ts,js,tsx}\" \"*.{json,md,yml}\"", "list:dev:users": "cat data/database.json | json -a users | json -a id username", diff --git a/vite.config.ts b/vite.config.ts index 148bf6f0c..d1ddca16d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,6 +3,34 @@ import react from "@vitejs/plugin-react"; import eslint from "vite-plugin-eslint"; import istanbul from "vite-plugin-istanbul"; +import type { Plugin } from "vite"; +import fs from "fs"; +import path from "path"; + +const WRONG_CODE = `import { bpfrpt_proptype_WindowScroller } from "../WindowScroller.js";`; + +export function reactVirtualized(): Plugin { + return { + name: "flat:react-virtualized", + // Note: we cannot use the `transform` hook here + // because libraries are pre-bundled in vite directly, + // plugins aren't able to hack that step currently. + // so instead we manually edit the file in node_modules. + // all we need is to find the timing before pre-bundling. + configResolved() { + const file = require + .resolve("react-virtualized") + .replace( + path.join("dist", "commonjs", "index.js"), + path.join("dist", "es", "WindowScroller", "utils", "onScroll.js") + ); + const code = fs.readFileSync(file, "utf-8"); + const modified = code.replace(WRONG_CODE, ""); + fs.writeFileSync(file, modified); + }, + }; +} + export default defineConfig(({ command, mode }) => { const env = loadEnv(mode, process.cwd(), "VITE"); return { @@ -26,6 +54,7 @@ export default defineConfig(({ command, mode }) => { exclude: ["node_modules", "cypress", "dist"], forceBuildInstrument: true, }), + reactVirtualized(), ], // to get aws amplify to work with vite resolve: { diff --git a/yarn.lock b/yarn.lock index d6a42b5a9..df5878fbf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5248,20 +5248,10 @@ camelcase@^5.0.0, camelcase@^5.3.1: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== -caniuse-lite@^1.0.30001503: - version "1.0.30001513" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001513.tgz#382fe5fbfb0f7abbaf8c55ca3ac71a0307a752e9" - integrity sha512-pnjGJo7SOOjAGytZZ203Em95MRM8Cr6jhCXNF/FAXTpCTRTECnqQWLpiTRqrFtdYcth8hf4WECUpkezuYsMVww== - -caniuse-lite@^1.0.30001541: - version "1.0.30001550" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001550.tgz#6ec6a2239eb2a8123cc26cfe0571db5c79eb8669" - integrity sha512-p82WjBYIypO0ukTsd/FG3Xxs+4tFeaY9pfT4amQL8KWtYH7H9nYwReGAbMTJ0hsmRO8IfDtsS6p3ZWj8+1c2RQ== - -caniuse-lite@^1.0.30001580: - version "1.0.30001583" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001583.tgz#abb2970cc370801dc7e27bf290509dc132cfa390" - integrity sha512-acWTYaha8xfhA/Du/z4sNZjHUWjkiuoAi2LM+T/aL+kemKQgPT1xBb/YKjlQ0Qo8gvbHsGNplrEJ+9G3gL7i4Q== +caniuse-lite@^1.0.30001503, caniuse-lite@^1.0.30001541, caniuse-lite@^1.0.30001580: + version "1.0.30001620" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001620.tgz" + integrity sha512-WJvYsOjd1/BYUY6SNGUosK9DUidBPDTnOARHp3fSmFO1ekdxaY6nKRttEVrfMmYi80ctS0kz1wiWmm14fVc3ew== caseless@~0.12.0: version "0.12.0"