This document explains how to start server (@affine/server) locally with Docker
Warning:
This document is not guaranteed to be up-to-date. If you find any outdated information, please feel free to open an issue or submit a PR.
docker pull postgres
docker run --rm --name affine-postgres -e POSTGRES_PASSWORD=affine -p 5432:5432 -v ~/Documents/postgres:/var/lib/postgresql/data postgres
docker volume create affine-postgres
docker run --rm --name affine-postgres -e POSTGRES_PASSWORD=affine -p 5432:5432 -v affine-postgres:/var/lib/postgresql/data postgres
docker run --rm --name mailhog -p 1025:1025 -p 8025:8025 mailhog/mailhog
docker ps
docker exec -it CONTAINER_ID psql -U postgres ## change container_id
psql (15.3 (Debian 15.3-1.pgdg120+1))
Type "help" for help.
postgres=# CREATE USER affine WITH PASSWORD 'affine';
CREATE ROLE
postgres=# ALTER USER affine WITH SUPERUSER;
ALTER ROLE
postgres=# CREATE DATABASE affine;
CREATE DATABASE
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
affine | Superuser | {}
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
In the following setup, we assume you have postgres server running at localhost:5432 and mailhog running at localhost:1025.
When logging in via email, you will see the mail arriving at localhost:8025 in a browser.
DATABASE_URL="postgresql:https://affine:affine@localhost:5432/affine"
MAILER_SENDER="[email protected]"
MAILER_USER="auth"
MAILER_PASSWORD="auth"
MAILER_HOST="localhost"
MAILER_PORT="1025"
yarn workspace @affine/server prisma db push
yarn workspace @affine/server data-migration run
Note, you may need to do it again if db schema changed.
yarn workspace @affine/server prisma studio
# build native
yarn workspace @affine/server-native build
yarn workspace @affine/native build
yarn workspace @affine/server dev
yarn dev
Now you should be able to start developing affine with server enabled.