mirror of
https://github.com/ddworken/hishtory.git
synced 2024-11-22 00:03:58 +01:00
Add fully tested instructions for self hosting
This commit is contained in:
parent
63130cc714
commit
9ddae45b03
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
web/landing/www/binaries/hishtory-linux
|
||||
hishtory
|
||||
backend/server/server
|
||||
postgres-data/
|
||||
|
@ -107,9 +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`. 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).
|
||||
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. Check out the [`docker-compose.yml`](https://github.com/ddworken/hishtory/blob/master/backend/server/docker-compose.yml) file for an example config to start a hiSHtory server and how to configure it.
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
@ -1,8 +1,10 @@
|
||||
# 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
|
||||
# 2. `docker compose -f backend/server/docker-compose.yml build`
|
||||
# 3. `docker compose -f backend/server/docker-compose.yml up`
|
||||
# 4. Point your hiSHtory client at the server by putting `export HISHTORY_SERVER=http://1.2.3.4` in your shellrc
|
||||
# 5. Run `hishtory init` to initialize hiSHtory with the local server
|
||||
# 6. [Optional, but recommended] Add a TLS proxy to enable https
|
||||
networks:
|
||||
hishtory:
|
||||
driver: bridge
|
||||
@ -19,16 +21,15 @@ services:
|
||||
volumes:
|
||||
- ./postgres-data:/var/lib/postgresql/data
|
||||
hishtory:
|
||||
image: hishtory
|
||||
depends_on:
|
||||
- postgres
|
||||
networks:
|
||||
- hishtory
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: ./backend/server/Dockerfile
|
||||
context: ../../
|
||||
dockerfile: ./backend/server/native-arch-Dockerfile
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRESQL_PASSWORD: TODO_YOUR_POSTGRES_PASSWORD_HERE
|
||||
HISHTORY_POSTGRES_DB: postgresql://postgres:TODO_YOUR_POSTGRES_PASSWORD_HERE@postgres:5432/hishtory?sslmode=disable
|
||||
ports:
|
||||
- 80:8080
|
||||
|
11
backend/server/native-arch-Dockerfile
Normal file
11
backend/server/native-arch-Dockerfile
Normal file
@ -0,0 +1,11 @@
|
||||
FROM golang:1.18 AS builder
|
||||
COPY go.mod ./
|
||||
COPY go.sum ./
|
||||
RUN unset GOPATH; go mod download
|
||||
COPY . ./
|
||||
RUN unset GOPATH; go build -o /server -ldflags "-X main.ReleaseVersion=v0.`cat VERSION`" backend/server/server.go
|
||||
|
||||
FROM golang:1.18
|
||||
COPY --from=builder /server /server
|
||||
# TODO: use wait-for-it.sh instead of a janky sleep
|
||||
CMD ["sh", "-c", "sleep 5; /server"]
|
Loading…
Reference in New Issue
Block a user