Add docker-compose file for self hosting to fix #7

This commit is contained in:
David Dworken 2022-11-04 23:41:56 -07:00
parent e7ec0a3ad2
commit 36f776053b
No known key found for this signature in database
3 changed files with 36 additions and 2 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
web/landing/www/binaries/hishtory-linux
hishtory
server
backend/server/server

View File

@ -107,7 +107,7 @@ Download the latest binary from [Github Releases](https://github.com/ddworken/hi
<summary>Self-Hosting</summary>
By default, hiSHtory relies on a backend for syncing. All data is end-to-end encrypted, so the backend can't view your history.
But if you'd like to self-host the hishtory backend, you can! The backend is a simple go binary in `backend/server/server.go` that uses postgres to store data. It reads the connection string for the postgres database from the environment variable `HISHTORY_POSTGRES_DB`.
But if you'd like to self-host the hishtory backend, you can! The backend is a simple go binary in `backend/server/server.go` that uses postgres to store data. It reads the connection string for the postgres database from the environment variable `HISHTORY_POSTGRES_DB`. If you don't yet have a postgres DB to use, you can use [`docker-compose.yml`](https://github.com/ddworken/hishtory/blob/master/backend/server/docker-compose.yml).
You can then point your local hishtory CLI to use this backend via the `HISHTORY_SERVER` environment variable (e.g. by doing `export HISHTORY_SERVER='https://hishtory.yourwebsite.example'` in your shellrc).
</details>

View File

@ -0,0 +1,34 @@
# A docker-compose file to host a hiSHtory backend. To use:
# 1. Update TODO_YOUR_POSTGRES_PASSWORD_HERE
# 2. `docker compose up`
# 3. Point your hiSHtory client at the server by putting `export HISHTORY_SERVER=http://1.2.3.4` in your shellrc
# 4. [Optional, but recommended] Add a TLS proxy to enable https
networks:
hishtory:
driver: bridge
services:
postgres:
image: postgres
restart: unless-stopped
networks:
- hishtory
environment:
POSTGRES_PASSWORD: TODO_YOUR_POSTGRES_PASSWORD_HERE
POSTGRES_DB: hishtory
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- ./postgres-data:/var/lib/postgresql/data
hishtory:
image: hishtory
depends_on:
- postgres
networks:
- hishtory
build:
context: ./
dockerfile: ./backend/server/Dockerfile
restart: unless-stopped
environment:
POSTGRESQL_PASSWORD: TODO_YOUR_POSTGRES_PASSWORD_HERE
ports:
- 80:8080