mirror of
https://github.com/ddworken/hishtory.git
synced 2024-11-25 09:43:20 +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
|
web/landing/www/binaries/hishtory-linux
|
||||||
hishtory
|
hishtory
|
||||||
backend/server/server
|
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>
|
<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.
|
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).
|
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.
|
||||||
|
|
||||||
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>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
# A docker-compose file to host a hiSHtory backend. To use:
|
# A docker-compose file to host a hiSHtory backend. To use:
|
||||||
# 1. Update TODO_YOUR_POSTGRES_PASSWORD_HERE
|
# 1. Update TODO_YOUR_POSTGRES_PASSWORD_HERE
|
||||||
# 2. `docker compose up`
|
# 2. `docker compose -f backend/server/docker-compose.yml build`
|
||||||
# 3. Point your hiSHtory client at the server by putting `export HISHTORY_SERVER=http://1.2.3.4` in your shellrc
|
# 3. `docker compose -f backend/server/docker-compose.yml up`
|
||||||
# 4. [Optional, but recommended] Add a TLS proxy to enable https
|
# 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:
|
networks:
|
||||||
hishtory:
|
hishtory:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
@ -19,16 +21,15 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./postgres-data:/var/lib/postgresql/data
|
- ./postgres-data:/var/lib/postgresql/data
|
||||||
hishtory:
|
hishtory:
|
||||||
image: hishtory
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
networks:
|
networks:
|
||||||
- hishtory
|
- hishtory
|
||||||
build:
|
build:
|
||||||
context: ./
|
context: ../../
|
||||||
dockerfile: ./backend/server/Dockerfile
|
dockerfile: ./backend/server/native-arch-Dockerfile
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
POSTGRESQL_PASSWORD: TODO_YOUR_POSTGRES_PASSWORD_HERE
|
HISHTORY_POSTGRES_DB: postgresql://postgres:TODO_YOUR_POSTGRES_PASSWORD_HERE@postgres:5432/hishtory?sslmode=disable
|
||||||
ports:
|
ports:
|
||||||
- 80:8080
|
- 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