Closed Diegovictorbr closed 3 years ago
I am specifically talking about the viewer package.json. The PUBLIC_URL can be changed here
"build:viewer": "cross-env PUBLIC_URL=/ohif/ NODE_ENV=production node --max_old_space_size=4096 ./../../node_modules/webpack/bin/webpack.js --config .webpack/webpack.pwa.js --progress",
I realized that this is a build time configuration and had to pull the source code inside my Docker Compose project. I've made two changes:
Changed the package.json a step before the build started. So i could add the PUBLIC_URL=/ohif/ to the build:viewer script.
I also needed to change the DicomWeb URLs on app-config.js based on which production server OHIF was running, so i changed the original OHIF Dockerfile to use a variable called SERVER_FULL_URL. Here is the changed Dockerfile (from ohif/base):
FROM node:10.16.3-slim as builder
ARG SERVER_FULL_URL
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
COPY .docker /usr/src/app/.docker
COPY .webpack /usr/src/app/.webpack
COPY extensions /usr/src/app/extensions
COPY platform /usr/src/app/platform
COPY .browserslistrc /usr/src/app/.browserslistrc
COPY aliases.config.js /usr/src/app/aliases.config.js
COPY babel.config.js /usr/src/app/babel.config.js
COPY lerna.json /usr/src/app/lerna.json
COPY package.json /usr/src/app/package.json
COPY postcss.config.js /usr/src/app/postcss.config.js
COPY yarn.lock /usr/src/app/yarn.lock
RUN yarn config set workspaces-experimental true
RUN yarn install
ENV PATH /usr/src/app/node_modules/.bin:$PATH
ENV QUICK_BUILD true
RUN yarn run build
FROM nginx:1.15.5-alpine
RUN apk add --no-cache bash
RUN rm -rf /etc/nginx/conf.d
COPY .docker/Viewer-v2.x /etc/nginx/conf.d
COPY .docker/Viewer-v2.x/entrypoint.sh /usr/src/
RUN chmod 777 /usr/src/entrypoint.sh
COPY --from=builder /usr/src/app/platform/viewer/dist /usr/share/nginx/html
COPY app-config.js /usr/share/nginx/html/app-config.js
RUN sed -i 's/###SERVER_FULL_URL###/'"$SERVER_FULL_URL"'/g' /usr/share/nginx/html/app-config.js
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["/usr/src/entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
Hello!
I am moving an OHIF viewer that was hosted inside Tomcat to a container. At the time I needed to change the PUBLIC_URL variable to /ohif/ so that the viewer could pick the scripts and assets at the right location. I've changed the routerBasename to /ohif/, but now i need to also change the PUBLIC_URL to that same value.
So my question is: can I change the PUBLIC_URL variable inside the OHIF viewer container?