Running the server
Start commands
Section titled “Start commands”From the repository root, yarn server:dev starts the server with file watching. From packages/server, you have more choices:
| Command | What it runs |
|---|---|
yarn dev |
The server with file watching, through tsx. |
yarn server |
The server once, through tsx. |
yarn start:server |
The server on plain Node.js. |
yarn start:collect |
The collector on plain Node.js. |
yarn start:server and yarn start:collect run the same thing production runs:
node --import ./src/bin/register-hooks.ts ./src/bin/server.tsPlain Node.js uses less memory than the tsx launcher. Measured at idle in a Linux container, the whole server tree dropped from about 410 MB to about 250 MB. See Architecture for how it works.
Database migrations
Section titled “Database migrations”The service uses Drizzle. Migrations run automatically when the server starts. You need no manual step. yarn db:migrate-latest runs the same migration outside of server start-up, if you want to apply it ahead of time.
Docker
Section titled “Docker”# Builddocker build -t gib-show .
# Rundocker run -p 3000:3000 \ -e DATABASE_URL=postgres://user:pass@host:5432/gibshow \ gib-showThe repository builds two images:
Dockerfilebuilds the server and the interface.Dockerfile.workerbuilds the collector.
Any host that can run containers works. Set the environment variables where you run them.
The artwork repositories
Section titled “The artwork repositories”The collector keeps its artwork repositories (Trust Wallet, SmolDapp, Ethereum Lists, PulseChain assets) current by itself. At the start of every run it fetches the newest commit of each, shallow and sparse. If the network fails, it uses the copy it already has. The image holds a first copy.
To keep the refreshed copy between container restarts, mount a named volume at /usr/src/app/submodules. A named volume starts with the image’s copy. An empty bind mount starts empty, and the first run clones into it.
Set REFRESH_SUBMODULES=false to turn the refresh off. Set SUBMODULES_DIRECTORY to keep the repositories somewhere else.
Monitoring
Section titled “Monitoring”GET /healthreturns status 200 with{"status":"ok"}when the server is ready, and 503 while it starts.- Every response carries an
x-response-timeheader. - The server logs the number of pruned image variants every day.
- Collection progress is logged through a terminal view.
To serve the server on your own domain name with encryption, see Domains and reverse proxies.
Scaling
Section titled “Scaling”- Horizontal. Several instances can share one PostgreSQL database. Resized variants are cached in the database, so every instance benefits.
- Content delivery network. You can put one in front. See Domains and reverse proxies. Set cache rules for the
/image/*paths. - Memory.
sharpneeds about 200 MB to process images. The server itself is light. See Configuration to lower thesharplimits on a small host.