speckle-server/packages/preview-service
Adam Hathcock 86f5c3da2b
Add stream destroy where db streams are used on download (#3300)
2024-10-17 11:35:39 +02:00
..
.vscode chore(server): core IoC #40 - favoriteStreamFactory (#3252) 2024-10-14 10:44:45 +02:00
bin feat(preview-service): use axios for proper timeout support (#2939) 2024-09-11 10:55:37 +02:00
docs Preview service readme (#243) 2021-05-14 13:45:39 +03:00
renderPage refactor(preview-service): conforms to design patterns, adds tests, and is typed (#2429) 2024-09-04 13:06:23 +01:00
src Add stream destroy where db streams are used on download (#3300) 2024-10-17 11:35:39 +02:00
tests chore(preview service): acceptance test loads geometry from csv file (#3083) 2024-09-24 16:26:31 +01:00
.env.example feat(preview-service): allow chromium exec path & puppeteer user data dir to be configured (#2462) 2024-07-02 10:39:19 +01:00
.gitignore feat: Standardized & cleaned up formatting & linting across repo #617 (#618) 2022-03-16 10:10:30 +02:00
Dockerfile chore(preview-service): fix docker compose to avoid pinning chrome (#3030) 2024-09-18 13:32:45 +02:00
eslint.config.mjs refactor(preview-service): conforms to design patterns, adds tests, and is typed (#2429) 2024-09-04 13:06:23 +01:00
package.json chore(preview service): acceptance test loads geometry from csv file (#3083) 2024-09-24 16:26:31 +01:00
readme.md refactor(preview-service): conforms to design patterns, adds tests, and is typed (#2429) 2024-09-04 13:06:23 +01:00
tsconfig.build.json refactor(preview-service): conforms to design patterns, adds tests, and is typed (#2429) 2024-09-04 13:06:23 +01:00
tsconfig.json refactor(preview-service): conforms to design patterns, adds tests, and is typed (#2429) 2024-09-04 13:06:23 +01:00
vitest.config.ts refactor(preview-service): conforms to design patterns, adds tests, and is typed (#2429) 2024-09-04 13:06:23 +01:00
webpack.config.renderPage.cjs refactor(preview-service): conforms to design patterns, adds tests, and is typed (#2429) 2024-09-04 13:06:23 +01:00

readme.md

PreviewService

This component generates object previews for Speckle Objects.

It reads preview tasks from the DB and uses Puppeteer and an internal Viewer to generate previews, which are currently stored in the DB.

This is an overview of this service:

overview

Run locally

To run the preview service locally, you need to have a running database and server service. You can use the docker-compose file in the root of this repository to start the database. Please follow instructions in the packages/server README to start the server service. The server is required to provide the database migrations.

Firstly, copy the .env.example file to .env and fill in the required values.

cp .env.example .env

The install the dependencies with:

yarn install

Then build the service:

yarn build

This builds both typescript and webpack (for the page that is deployed to chromium to create the views). It should be rerun whenever you make changes to the viewer (if you make local viewer changes, don't forget to build the viewer module before running this)

Finally, you can run the preview service with:

yarn dev

This will use the default dev DB connection of postgres://speckle:speckle@127.0.0.1/speckle. You can pass the environment variable PG_CONNECTION_STRING to change this to a different DB.

In a docker image

Navigate to the root of this git repository and build the preview service Dockerfile:

docker build -f packages/preview-service/Dockerfile -t speckle-preview-service:local .

Once you have built the preview service Dockerfile, you can run it like so:

docker run --rm -p 3001:3001 -e PORT=3001 -e PG_CONNECTION_STRING=postgres://speckle:speckle@host.docker.internal/speckle speckle-preview-service:local

Deployment notes

When deploying the PreviewService, it's important to pay attention to the memory requirements: Speckle streams can be arbitrarily large and the preview service must load the entire stream in order to generate the preview image.

You must limit the PreviewService container memory to a value that you want to allocate for preview generation. If a stream requires more memory then the limit, the preview for that stream will fail, but the entire system remains stable.

To limit the container memory when running with docker run, you can use the -m flag.

To limit the memory used in the v3 docker compose file, you can use the mem_limit key in the preview-service service definition.