To self-host OpenStock on a managed VPS is to keep your accounts, watchlists and alerts on a server of your own, which our teams keep up to date and monitor day and night. OpenStock is a free, open source alternative to paid market platforms, under the AGPL-3.0 license, built by the Open Dev Society. This guide follows its official Docker Compose file and prebuilt image at release v2026.11.22, and we ran every command on a Simafri VPS before writing it: installation with MongoDB, HTTPS, the first account, the API keys, backups and updates.
By Simon Vasconcelos Lee
Published on 3 December 202612 minute read
ghcr.io/open-dev-society/openstock and MongoDB 7, with port 8120 published on 127.0.0.1 behind an HTTPS reverse proxy.MONGODB_URI, BETTER_AUTH_SECRET and your public address in a .env file; scripts/check-env.mjs tells you what is still missing.mongodump and a copy of compose.yaml and .env. To update, change the image tag, then pull and recreate the container.OpenStock is a web application written with Next.js and React, which stores its accounts and watchlists in MongoDB. It follows markets with charts embedded from TradingView and quotes, company data and news from Finnhub.
Quotes are refreshed every hour in the default cached mode, shared by every user of your instance. The realtime mode refreshes them every 15 seconds and turns on price alerts; it is fixed when the application is built, so it means building the image yourself instead of using the prebuilt one.
OpenStock is published under the GNU Affero General Public License, version 3 (AGPL-3.0). You can use it free of charge, for yourself, your company or your clients, copy it and modify it. Its particularity is the network clause: if you modify OpenStock and let people use it over a network, you offer them the source code of your version, under the same license. Its README also asks you to credit the original authors. The software is provided without warranty.
The data services it connects to have their own terms: Finnhub, Inngest, your email provider and the AI provider you choose. Their free tiers are enough to try every feature.
Here is what we measured on our test VPS, with 2 vCPU and 4 GB of memory, after the installation, an account and a watchlist:
Server size therefore depends on the number of users and on the other applications you run beside OpenStock. On a managed VPS, tell us about your usage and we will recommend the right size.
OpenStock publishes a docker-compose.yml that runs the application and MongoDB together, and a prebuilt image on GitHub Container Registry, for x86-64 and ARM64. On a server with Docker Engine and its Compose plugin, installed from Docker’s repository for Ubuntu, create the folder of the instance:
mkdir -p /opt/openstock
Put this compose.yaml in it. It is the official file, with the prebuilt image in place of the build, as the README describes:
services:
openstock:
image: ghcr.io/open-dev-society/openstock:2026.11.22
ports:
- "127.0.0.1:8120:3000"
env_file:
- .env
restart: unless-stopped
depends_on:
mongodb:
condition: service_healthy
mongodb:
image: mongo:7
restart: unless-stopped
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD:?set MONGO_ROOT_PASSWORD in .env}
volumes:
- mongo-data:/data/db
healthcheck:
test: ["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
volumes:
mongo-data:
The settings go in a .env file next to it, which Docker Compose reads for the MongoDB password and passes whole to the application. Create it readable by root only, with your address in BETTER_AUTH_URL, then start the stack:
umask 077
P=$(openssl rand -hex 24)
printf 'MONGO_ROOT_PASSWORD=%s\nMONGODB_URI=mongodb://root:%s@mongodb:27017/openstock?authSource=admin\nBETTER_AUTH_SECRET=%s\nBETTER_AUTH_URL=https://openstock.example.com\nFINNHUB_API_KEY=\n' "$P" "$P" "$(openssl rand -hex 32)" > .env
umask 022
docker compose up -d
docker compose ps
latest, which follows every change on the main branch. The image is also tagged by release and by commit: 2026.11.22, release v2026.11.22, the latest when we tested, is the same image as sha-62da391. One release, v2026.11.09, was published under its commit tag only, sha-fe2cbde. Check the release page for the tag of a newer release.127.0.0.1: the official file publishes port 3000 on every address of the server. Published locally, OpenStock is reachable only through the reverse proxy. MongoDB publishes no port at all, as in the official file: only the application reaches it.MONGO_ROOT_PASSWORD creates the MongoDB administrator on the first start, and MONGODB_URI carries the same password for the application. In hexadecimal, it needs no encoding in the URI. With :?, Compose refuses to start without it, where the official file falls back to example.BETTER_AUTH_SECRET signs the sessions: the application refuses to run its authentication in production without it. Since release v2026.11.22, it also reads the name AUTH_SECRET. Keep it secret and stable, or every user is signed out.BETTER_AUTH_URL is your public address, with https://: OpenStock builds its sign-in callbacks and the links of its emails from it.mongodb, a name that must be unique on the whole server. Without it, Compose names the containers after the folder, and the service keeps its name mongodb for the application.mongo-data holds the database. OpenStock keeps no other files: accounts, sessions, watchlists, alerts and rate limits are all in MongoDB.On our test VPS, OpenStock answered within a few seconds of its container starting. To check that it is ready, and which settings are still missing:
until curl -sf -o /dev/null http://127.0.0.1:8120/sign-in; do sleep 5; done
curl -s http://127.0.0.1:8120/sign-in | grep -o -E '<title>[^<]*</title>'
docker compose exec -T openstock node scripts/check-env.mjs
The second command returns <title>OpenStock</title>. The checker lists each variable, with the first and last characters of its value only, and ends on “3/4 required variables present” and “1 critical variable(s) are missing”: the Finnhub key, which we come to below. Once the key is set, it reads “4/4”.
The container serves OpenStock over HTTP, on port 8120 of the server. HTTPS is handled by a reverse proxy in front of it. We tested Caddy, installed from its official Debian and Ubuntu repository: it obtains the Let’s Encrypt certificate itself, renews it, and forwards the Host header and X-Forwarded-* headers by default.
openstock.example.com {
reverse_proxy 127.0.0.1:8120
}
systemctl reload caddy
curl -sI https://openstock.example.com/sign-in returns HTTP/2 200, with via: 1.1 Caddy and x-powered-by: Next.js.Open your address and choose Sign up. The form asks for your name, email and password, at least 8 characters, then your country, investment goals, risk tolerance and preferred industry, which OpenStock keeps on your profile and uses for the welcome email. Once the account is created, you are signed in.
On our test VPS, we created the account through the sign-up endpoint of Better Auth, the one the form calls, then signed in again: the session opened the dashboard and the watchlist, while a visitor without a session was sent to the sign-in page. We added Apple to the watchlist, and it was there on the watchlist page and in MongoDB.
Sign-up is open to anyone who reaches your address: OpenStock has no setting to close it. The form limits sign-ups to five an hour per address. If the instance is for you or your team only, keep its address private, or put an access control in front of it at the reverse proxy.
Without any key, OpenStock serves its pages, creates accounts and saves watchlists; the charts come from TradingView, in the browser. Its log then shows “No Finnhub API key configured” for each quote it could not fetch. Each key goes on its own line in .env, after the = sign; then recreate the container, which reads the file again, and run the checker:
docker compose up -d
docker compose exec -T openstock node scripts/check-env.mjs
FINNHUB_API_KEY, free at finnhub.io: quotes, search, company profiles, news and the watchlist prices. Several free keys, comma-separated in FINNHUB_API_KEYS, are used in turn, each adding 60 requests a minute.INNGEST_SIGNING_KEY and INNGEST_EVENT_KEY: the background jobs, which send the welcome email, check the price alerts every five minutes and send the weekly digest. In Inngest, add your instance as an app, at https://openstock.example.com/api/inngest.NODEMAILER_EMAIL and NODEMAILER_PASSWORD: the account that sends the emails, a Gmail address with an app password in the official setup, password reset included. Without them, emails are skipped.GEMINI_API_KEY, or a MiniMax or Siray key with AI_PROVIDER: the AI-written welcome email and news digest.ADANOS_API_KEY: the sentiment card on stock pages. ALPHAI_API_KEY: the scored news card on stock pages. KIT_API_KEY, KIT_API_SECRET and KIT_WELCOME_FORM_ID: the weekly digest as a Kit newsletter.GOOGLE_CLIENT_ID and GITHUB_CLIENT_ID, with their secrets: Google and GitHub sign-in, each turned on once its ID is set. The callbacks are https://openstock.example.com/api/auth/callback/google and /github.On our test VPS, a value added to .env was in the container after docker compose up -d, which recreated it, and gone once removed. We created no key with these services: the features behind them are described from the official documentation.
Everything lives in two places: the MongoDB database, and your compose.yaml and .env files. Keep the latter safe: it holds the database password, the session secret and your keys. The MongoDB image includes mongodump:
umask 077
docker compose exec -T mongodb sh -c 'exec mongodump -u root -p "$MONGO_INITDB_ROOT_PASSWORD" --authenticationDatabase admin --db openstock --archive --gzip' > openstock-$(date +%F).archive.gz
tar -czf config-$(date +%F).tar.gz compose.yaml .env
umask 022
The dump reads the database password inside the container, so it never appears on the command line, and umask 077 makes both files readable by root only. Schedule this copy and send it off the server. Stored on the disk, the files are also included in the server’s nightly backups.
On a new server, or after losing the instance, put the two files back in /opt/openstock, start MongoDB alone, load the dump, then start OpenStock:
BACKUP_DATE=2026-12-03
(
set -e
for f in config-$BACKUP_DATE.tar.gz openstock-$BACKUP_DATE.archive.gz; do
test -s "$f" || { echo "Missing or empty: $f"; exit 1; }
done
tar -xzf config-$BACKUP_DATE.tar.gz
docker compose up -d --wait mongodb
docker compose exec -T mongodb sh -c 'exec mongorestore -u root -p "$MONGO_INITDB_ROOT_PASSWORD" --authenticationDatabase admin --nsInclude "openstock.*" --drop --stopOnError --archive --gzip' < openstock-$BACKUP_DATE.archive.gz
docker compose up -d
)
Set BACKUP_DATE, on the first line, to the date in the names of the backup you restore, as listed by ls. The commands run in parentheses with set -e, which stops them at the first error. They first check that each file exists and is not empty, before anything is stopped, removed or overwritten: a wrong date stops there, with your data untouched, and a failed step stops every step after it, so the application is never started again on a partial restore.
With --stopOnError, mongorestore stops at the first error and returns a non-zero code; --drop replaces each collection that already exists. We tested the whole cycle on our VPS: dump and archive, then docker compose down -v and the two files deleted, the database volume gone with them. A date with no backup stopped before anything started. A dump cut short was refused, with exit code 1, nothing restored and OpenStock not started. The full dump brought back the five documents, the account signed in again with the same password, and Apple was back in its watchlist.
OpenStock publishes a release every few weeks, named after its date, and its notes list what changed. Every release and every change on the main branch builds a new image. This guide pins release v2026.11.22, the most recent when we tested it: check the releases page, and the tags of the image, before you install. Take a backup, change the image tag in compose.yaml, then pull the new image and recreate the container:
docker compose pull
docker compose up -d
docker compose images openstock
docker compose pull and docker compose up -d. The account signed in again and its watchlist was intact, with no migration step: MongoDB keeps the same collections, and the new release adds its own for named lists. We had tested the previous update, from 2026.10.25 to v2026.11.09, the same way.docker image inspect --format '{{index .Config.Labels "org.opencontainers.image.revision"}}' ghcr.io/open-dev-society/openstock:2026.11.22 shows the commit it was built from, here 62da391edb, the commit of release v2026.11.22.latest tag follows the main branch, between releases: stay on release tags.docker compose pull also fetches the latest 7.0 image, 7.0.48 when we tested. A move to a newer major version of MongoDB is a separate step, which MongoDB documents version by version.Self-hosting means running the server on top of the application. On a managed VPS, our teams take charge of the server and proactively monitor your instance; OpenStock remains your software, with your data and your keys.
| Topic | Our teams | You |
|---|---|---|
| The server | System and security updates, server interventions included | The timing that suits you |
| Monitoring | Server monitored 24/7, with intervention without waiting for your call | Your accounts, watchlists and alerts in OpenStock |
| OpenStock | Proactive monitoring: errors, slowdowns, database and disk space spotted, fix recommended | Its installation, updates, keys and settings, which you apply, yourself or through your AI assistant |
| Users | The server that carries them, monitored and backed up | Who signs up, and how the address is shared |
| Backups | Every night, encrypted and kept off the machine; restores included | OpenStock’s own database dumps, and the restore request, when you need one |
| Migration | Your current server migrated, free of charge | The timing of the switch |
If you would rather have our teams work inside the application itself, that service is billed by the hour or at a fixed rate, with an estimate shared before the work starts.
With a Simafri Managed VPS, our teams keep your OpenStock instance’s server up to date, monitor it day and night and step in without waiting for your call; they also proactively monitor your instance and recommend useful fixes, which you apply, yourself or through your AI assistant. Backups are encrypted every night and kept off the machine, restores are included, and migrating your current server is free.
Yes. OpenStock is under the AGPL-3.0 license: you can run it for yourself, your team or your clients with no license to buy. If you modify it and let people use it over a network, you offer them your source code. The data services have free tiers, and what remains is the cost of the server.
Use the official docker-compose.yml with the prebuilt image ghcr.io/open-dev-society/openstock at a release tag and MongoDB 7. Put MONGO_ROOT_PASSWORD, MONGODB_URI with the same password, BETTER_AUTH_SECRET and BETTER_AUTH_URL in a .env file, publish its port on 127.0.0.1, run docker compose up -d, and put an HTTPS reverse proxy in front.
Partly. On our test VPS, the pages, sign-up, sign-in and the watchlist worked without any key, and the charts come from TradingView. Quotes, search, company data and the watchlist prices need a Finnhub key, free at finnhub.io, set in FINNHUB_API_KEY in .env.
A release tag, never latest, which follows the main branch. Releases are tagged by version, such as 2026.11.22, and every image by commit. Release v2026.11.09 was published under its commit tag sha-fe2cbde only: check the releases page and the registry for the newest one.
Little. On our test VPS, the OpenStock container used about 200 to 250 MB and MongoDB 80 to 210 MB, and the two images take about 2.9 GB of disk. A small VPS is enough to start.
Dump the openstock database with mongodump from the MongoDB container, in an archive, and keep a copy of compose.yaml and .env. Restore with mongorestore --drop --stopOnError into MongoDB started alone, then start OpenStock.
Take a backup, change the image tag in compose.yaml to the new release, then run docker compose pull and docker compose up -d. MongoDB keeps the data: our update from v2026.11.09 to v2026.11.22 needed no migration step.
A managed VPS covers the server: system, security, monitoring and backups. Our teams also proactively monitor your instance and recommend useful fixes, which you apply. Work inside the application is billed by the hour or at a fixed rate.
Simafri
Let's talk about your project
Tell us what you need in a few words: we will get back to you quickly.
Thank you! Your request has been sent. We'll get back to you shortly.
Prefer email? Write to us at support@simafri.com.