Adriano Freitas
11/29/2023, 5:49 PMrahul1
11/30/2023, 8:13 PMrahul1
11/30/2023, 8:14 PMrahul1
11/30/2023, 8:15 PMapp.medplum.com
rahul1
11/30/2023, 8:18 PMAdriano Freitas
11/30/2023, 8:21 PMrahul1
11/30/2023, 8:21 PMAdriano Freitas
11/30/2023, 8:22 PMAdriano Freitas
11/30/2023, 8:24 PMrahul1
11/30/2023, 8:43 PMnpm run dev
does not produce an optimized bundle. And the server isn't built for production traffic
I think a cleaner / more optimized approach would be:
1. use npm run build -- --filter=app
to create a optimized html/css/js files
2. Use a standard HTTP server docker container (e.g. NGinX) to deploy the files: https://www.dailysmarty.com/posts/steps-for-deploying-a-static-html-site-with-docker-and-nginxAdriano Freitas
11/30/2023, 8:54 PMAdriano Freitas
11/30/2023, 9:00 PMrahul1
12/01/2023, 9:22 PMFROM nginx:alpine
COPY ./dist /usr/share/nginx/html
you could download the dist folder directly from NPM (https://www.npmjs.com/package/@medplum/app?activeTab=code)
- npm run dev
just runs the vite
command (https://vitejs.dev/guide/cli#dev-server). You could just set the hostname to 0.0.0.0 via command line args, before your PR is supportedAdriano Freitas
12/07/2023, 12:00 PMgeoheil
04/28/2024, 4:15 PM# syntax=docker/dockerfile:1.7.1
FROM nginx:1.26.0-alpine3.19-slim
RUN rm /usr/share/nginx/html/50x.html && \
rm /usr/share/nginx/html/index.html
RUN wget -qO- https://registry.npmjs.org/@medplum/app/-/app-3.1.4.tgz | tar --strip-components=2 -xz -C /usr/share/nginx/html
WORKDIR /usr/share/nginx/html
# monkeypatch logo error
RUN cp img/medplum-logo-512-512.png img/medplum-logo-512x512.png
When serving via docker-compose like:
medplum-frontend:
image: medplum-app:latest
build:
context: ./medplum-app
ports:
- 8080:80
environment:
- MEDPLUM_BASE_URL=${MEDPLUM_FRONTEND_BASE_URL}
- __MEDPLUM_BASE_URL__=${MEDPLUM_FRONTEND_BASE_URL}
- MEDPLUM_CLIENT_ID=${MEDPLUM_FRONTEND_CLIENT_ID}
- GOOGLE_CLIENT_ID=${GOOGLE_FRONTEND_CLIENT_ID}
- RECAPTCHA_SITE_KEY=${RECAPTCHA_FRONTEND_SITE_KEY}
- MEDPLUM_REGISTER_ENABLED=${MEDPLUM_FRONTEND_REGISTER_ENABLED}
networks:
- medplum
I receive these errors:
Error: Base URL must start with http or https
wT client.ts:777
IQ index.tsx:31
<anonymous> index.tsx:80
suppress-nextjs-warning.mjs:6:6
Retrieving "b5x-stateful-inline-icon" flag errored: timed out - falling back
the docker container of nginx indeed has the right variables set i.e.
/usr/share/nginx/html # echo ${MEDPLUM_BASE_URL}
http://medplum:8103/
/usr/share/nginx/html # echo ${__MEDPLUM_BASE_URL__}
http://medplum:8103/
These variables are NOT set on the client i.e. the system which is browing the http://localhost:8080 of Nginx which is serving the frontend.
Do you have any idea how to fix the loading for these env variables? It looks like the JS cannot properly resolve them.geoheil
04/28/2024, 4:21 PMgeoheil
04/28/2024, 4:23 PMgeoheil
04/28/2024, 5:44 PM# syntax=docker/dockerfile:1.7.1
FROM node:20.12.2-alpine as builder
WORKDIR /app
RUN apk add --no-cache git && \
git clone https://github.com/medplum/medplum.git && \
cd medplum && \
git checkout v3.1.4
WORKDIR /app/medplum
RUN npm ci
RUN npm run build:fast -- --filter=app
FROM nginx:1.26.0-alpine3.19-slim as frontend
RUN rm /usr/share/nginx/html/50x.html && \
rm /usr/share/nginx/html/index.html
COPY --from=builder /app/medplum/packages/app/dist /usr/share/nginx/html
WORKDIR /usr/share/nginx/html
I can move further.
Interestingly, I still get a different result compared to running the frontend locally.
when loading http://localhost:8080 - and the app frontend starts to talk to the server
POST
http://localhost:8103/fhir/R4/$graphql
this fails with an unauthenticated code.geoheil
04/28/2024, 5:48 PMrahul1
04/30/2024, 9:23 PMrahul1
04/30/2024, 9:25 PMrahul1
04/30/2024, 9:26 PMrahul1
04/30/2024, 9:26 PMupdate-app
code for an example:
https://github.com/medplum/medplum/blob/main/packages/cli/src/aws/update-app.ts#L44-L50geoheil
05/01/2024, 6:51 AMgeoheil
05/01/2024, 12:01 PM# syntax=docker/dockerfile:1.7.1
FROM node:20-slim as builder
WORKDIR /app
ARG MEDPLUM_VERSION
RUN apt-get update && \
apt-get install -y git && \
git clone https://github.com/medplum/medplum.git && \
cd medplum && \
git checkout v${MEDPLUM_VERSION}
WORKDIR /app/medplum
RUN npm ci --maxsockets 1
ARG MEDPLUM_BASE_URL
ARG MEDPLUM_CLIENT_ID
ARG GOOGLE_CLIENT_ID
ARG RECAPTCHA_SITE_KEY
ARG MEDPLUM_REGISTER_ENABLED
RUN npm run build:fast -- --filter=app
FROM nginx:1.26.0-alpine3.19-slim as frontend
RUN rm /usr/share/nginx/html/50x.html && \
rm /usr/share/nginx/html/index.html
COPY --from=builder /app/medplum/packages/app/dist /usr/share/nginx/html
WORKDIR /usr/share/nginx/html
# Optional: Fix any file name issues (e.g., the logo file)
#RUN cp img/medplum-logo-512-512.png img/medplum-logo-512x512.png
#RUN cp assets/favicon-*.ico ../favicon.ico
with a compose of:
medplum-frontend:
image: medplum-app:latest
build:
context: ./services/medplum-app
dockerfile: Dockerfile
target: frontend
args:
MEDPLUM_VERSION: ${MEDPLUM_VERSION}
MEDPLUM_BASE_URL: ${MEDPLUM_FRONTEND_BASE_URL}
MEDPLUM_CLIENT_ID: ${MEDPLUM_FRONTEND_CLIENT_ID}
GOOGLE_CLIENT_ID: ${GOOGLE_FRONTEND_CLIENT_ID}
RECAPTCHA_SITE_KEY: ${RECAPTCHA_FRONTEND_SITE_KEY}
MEDPLUM_REGISTER_ENABLED: ${MEDPLUM_FRONTEND_REGISTER_ENABLED}
geoheil
05/01/2024, 12:02 PMrror: Unauthenticated
handleUnauthenticated https://app.mydomain.com/assets/index-GwzdS-hp.js:132
request https://app.mydomain.com/assets/index-GwzdS-hp.js:132
post https://app.mydomain.com/assets/index-GwzdS-hp.js:93
graphql https://app.mydomain.com/assets/index-GwzdS-hp.js:132
o https://app.mydomain.com/assets/index-GwzdS-hp.js:132
requestSchema https://app.mydomain.com/assets/index-GwzdS-hp.js:132
yB https://app.mydomain.com/assets/index-GwzdS-hp.js:522
xf https://app.mydomain.com/assets/index-GwzdS-hp.js:83
va https://app.mydomain.com/assets/index-GwzdS-hp.js:83
mA https://app.mydomain.com/assets/index-GwzdS-hp.js:83
j https://app.mydomain.com/assets/index-GwzdS-hp.js:68
I https://app.mydomain.com/assets/index-GwzdS-hp.js:68
EventHandlerNonNull* https://app.mydomain.com/assets/index-GwzdS-hp.js:68
<anonymous> https://app.mydomain.com/assets/index-GwzdS-hp.js:68
index-GwzdS-hp.js:60:584
error https://app.mydomain.com/assets/index-GwzdS-hp.js:60
(Async: promise callback)
catch https://app.mydomain.com/assets/index-GwzdS-hp.js:93
yB https://app.mydomain.com/assets/index-GwzdS-hp.js:522
xf https://app.mydomain.com/assets/index-GwzdS-hp.js:83
va https://app.mydomain.com/assets/index-GwzdS-hp.js:83
mA https://app.mydomain.com/assets/index-GwzdS-hp.js:83
j https://app.mydomain.com/assets/index-GwzdS-hp.js:68
I https://app.mydomain.com/assets/index-GwzdS-hp.js:68
(Async: EventHandlerNonNull)
<anonym> https://app.mydomain.com/assets/index-GwzdS-hp.js:68
<anonym> https://app.mydomain.com/assets/index-GwzdS-hp.js:68
geoheil
05/01/2024, 12:02 PMgeoheil
05/01/2024, 2:42 PMgeoheil
05/01/2024, 3:11 PMgeoheil
05/01/2024, 3:14 PMrahul1
05/01/2024, 4:20 PMgeoheil
05/02/2024, 9:22 PMrahul1
05/02/2024, 9:27 PMrahul1
05/02/2024, 9:28 PMrahul1
05/02/2024, 9:28 PMgeoheil
05/03/2024, 6:39 AMgeoheil
05/03/2024, 6:39 AMoruchovets
10/21/2024, 10:54 PM