Open struanb opened 7 months ago
The server build should be relatively simple since it only requires typescript compilation (no bundling, and no Rust dependencies). Try building the server directly first:
pnpm i
pnpm tsc -p ./tsconfig.server.json
At that point it's a standard node.js server which you can run via:
node ./dist-server/server.js
Thanks for this. These commands do (now) work, and it turns out at least part of my problem was that I was trying to build inside a repo directory that was bind-mounted from my Mac. This led to the ERR_PNPM_LINKING_FAILED error. Additionally, I found that building from source on an overlay filesystem (e.g. inside a plain docker container) can cause node-gyp build to fail.
Building inside a fresh copy of the repo in a Docker volume inside a container, or using docker build
seems to work (and I don't really know why the docker build failed before when I raised this issue).
I've also managed to launch my sync server behind https and resync my local chat.prompta.dev storage to it. So far so good!
I also managed to build and load the client, but had to add NODE_OPTIONS="--max-old-space-size=2048"
before pnpm build ui:build
and pnpm build ui:build-static
.
I think you can close this issue, but I suggest modifying Dockerfile and docs to add NODE_OPTIONS="--max-old-space-size=2048"
to the client build instructions.
It would be neat if the sync server could also serve the static client, so that everything can be built and run off one IP and port. In the meantime here is a Dockerfile
that builds and (hackily) serves both client and sync server.
FROM node:20 as builder
RUN apt-get update; apt install -y curl python-is-python3 pkg-config build-essential
RUN mkdir /app
WORKDIR /app
COPY . .
RUN npm install -g pnpm
RUN pnpm install
RUN sed -r -i.bak 's!https://prompta-production.up.railway.app!http://localhost:8081!' src/lib/sync/vlcn.ts
RUN pnpm run build:server
RUN NODE_OPTIONS="--max-old-space-size=2048" pnpm run ui:build
EXPOSE 8080
EXPOSE 8081
CMD [ "bash", "-c", "PORT=8081 node ./dist-server/server.js & pnpm run preview --host 0.0.0.0 --port 8080" ]
I am trying to build my own client talking to its own sync server.
I have built the sync server using
docker build -t prompta .
and run it usingdocker run --name=prompta -p 8080:8080 prompta
.To use it, I understand I have to serve the client over http to allow it to access the server on http://0.0.0.0:8080/.
Dockerfile
I get this error: