diff --git a/.gitignore b/.gitignore index bdfe2e8..3731d27 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ web/landing/www/binaries/hishtory-linux hishtory -server +backend/server/server diff --git a/README.md b/README.md index f26972a..b2c1bdf 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ Download the latest binary from [Github Releases](https://github.com/ddworken/hi Self-Hosting 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). diff --git a/backend/server/docker-compose.yml b/backend/server/docker-compose.yml new file mode 100644 index 0000000..c1b0f20 --- /dev/null +++ b/backend/server/docker-compose.yml @@ -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