diff --git a/.dockerignore b/.dockerignore index 37a0a977b4..04574b3b35 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,4 +8,8 @@ coverage .docs .github .pytest_cache -data \ No newline at end of file +data + +client/node_modules +client/.nx +client/dist \ No newline at end of file diff --git a/client/project.json b/client/project.json index ab8bb5f36b..a14436f35c 100644 --- a/client/project.json +++ b/client/project.json @@ -10,7 +10,7 @@ "defaultConfiguration": "production", "options": { "outputPath": "dist/client", - "base": "/static" + "base": "/static/react-assets" }, "configurations": { "development": { diff --git a/client/index.html b/client/react-assets.html similarity index 100% rename from client/index.html rename to client/react-assets.html diff --git a/client/vite.config.ts b/client/vite.config.ts index dd9bf3b56f..6ed597a8a6 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -2,6 +2,7 @@ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; +import path from 'path'; export default defineConfig({ root: __dirname, @@ -30,6 +31,11 @@ export default defineConfig({ commonjsOptions: { transformMixedEsModules: true, }, + rollupOptions: { + input: { + imports: path.resolve(__dirname, 'react-assets.html'), + }, + }, }, test: { diff --git a/conf/docker/Dockerfile b/conf/docker/Dockerfile index f9fb25c2c0..129fc182fd 100644 --- a/conf/docker/Dockerfile +++ b/conf/docker/Dockerfile @@ -6,6 +6,15 @@ RUN npm ci COPY . /designsafe/ RUN npm run build +FROM node:20 as node_nx_build +COPY client/package.json client/package-lock.json /designsafe/ +WORKDIR /designsafe/client +RUN npm ci + +COPY client/ /designsafe/client/ +RUN npm run build + + FROM python:3.11-buster @@ -46,9 +55,15 @@ RUN groupadd --gid 816877 G-816877 && \ useradd --uid 458981 --gid G-816877 -m --shell /bin/bash tg458981 -d /home/tg458981 COPY --from=node_build /designsafe/ /srv/www/designsafe + +COPY --from=node_nx_build /designsafe/client/dist/client/ /srv/www/designsafe/designsafe/static/react-assets/ +COPY --from=node_nx_build /designsafe/client/dist/client/react-assets.html /srv/www/designsafe/designsafe/templates/react-assets.html + RUN chown tg458981:G-816877 /srv/www/designsafe /srv/www/designsafe/* RUN chown -R tg458981:G-816877 /srv/www/designsafe/designsafe + + USER tg458981 WORKDIR /srv/www/designsafe diff --git a/designsafe/apps/data/templates/data/data_depot.j2 b/designsafe/apps/data/templates/data/data_depot.j2 index db4e795f05..014650c3c0 100644 --- a/designsafe/apps/data/templates/data/data_depot.j2 +++ b/designsafe/apps/data/templates/data/data_depot.j2 @@ -121,7 +121,10 @@ Data Depot {% else %} - + + {% endif %} + {% if react_flag and not debug %} + {% include react-assets.html %} {% endif %} {% if not react_flag %}