Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
noticons authored Jan 5, 2025
2 parents 57c65a3 + a9a45cc commit ee2d8b2
Show file tree
Hide file tree
Showing 28 changed files with 741 additions and 243 deletions.
11 changes: 9 additions & 2 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/bin/zsh -e

golint -set_exit_status ./...
go mod tidy -v
docker compose up -d mysql mariadb postgres

export SHIORI_TEST_PG_URL="postgres://shiori:shiori@localhost:5432/shiori?sslmode=disable"
export SHIORI_TEST_MYSQL_URL="shiori:shiori@(localhost:3306)/shiori"
export SHIORI_TEST_MARIADB_URL="shiori:shiori@(localhost:3307)/shiori"

make lint

make unittest GOTESTFMT_FLAGS="-hide all"
2 changes: 1 addition & 1 deletion .github/workflows/_gorelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
args: release --clean ${{ env.flags }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # 4.4.3
- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # 4.5.0
with:
name: dist
path: ./dist/*
21 changes: 18 additions & 3 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
image: postgres:13.18
env:
POSTGRES_PASSWORD: shiori
POSTGRES_USER: shiori
Expand All @@ -23,7 +23,7 @@ jobs:
ports:
- 5432:5432
mariadb:
image: mariadb:11
image: mariadb:10.5.27
env:
MYSQL_USER: shiori
MYSQL_PASSWORD: shiori
Expand All @@ -33,6 +33,20 @@ jobs:
--health-cmd="/usr/local/bin/healthcheck.sh --connect" --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 3306:3306
mysql:
image: mysql:8.0.40
env:
MYSQL_USER: shiori
MYSQL_PASSWORD: shiori
MYSQL_DATABASE: shiori
MYSQL_ROOT_PASSWORD: shiori
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
ports:
- 3307:3306

name: Go unit tests (ubuntu-latest)
steps:
Expand Down Expand Up @@ -60,12 +74,13 @@ jobs:
env:
SHIORI_TEST_PG_URL: "postgres://shiori:shiori@localhost:5432/shiori?sslmode=disable"
SHIORI_TEST_MYSQL_URL: "shiori:shiori@(localhost:3306)/shiori"
SHIORI_TEST_MARIADB_URL: "shiori:shiori@(localhost:3307)/shiori"
CGO_ENABLED: 1 # go test -race requires cgo

- run: go build -tags osusergo,netgo -ldflags="-s -w -X main.version=$(git describe --tags) -X main.date=$(date --iso-8601=seconds)"

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e # 5.1.1
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # 5.1.2
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Expand Down
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ help:
clean:
rm -rf dist

## Runs the legacy http API for local development
.PHONY: serve
serve:
SHIORI_DEVELOPMENT=$(SHIORI_DEVELOPMENT) SHIORI_DIR=$(SHIORI_DIR) go run main.go serve

## Runs server for local development
.PHONY: run-server
run-server:
Expand Down
32 changes: 27 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# Docker compose for development purposes only.
# Edit it to fit your current development needs.
version: "3"
services:
shiori:
image: ghcr.io/go-shiori/shiori
container_name: shiori
command:
- "server"
- "--log-level"
- "debug"
ports:
- "8080:8080" #set port number if it needs to be different
volumes:
- "./dev-data:/srv/shiori"
- ".:/src/shiori"
- "go-mod-cache:/go/pkg/mod"
restart: unless-stopped
depends_on:
- "postgres"
Expand All @@ -20,8 +24,16 @@ services:
SHIORI_DATABASE_URL: postgres://shiori:shiori@postgres/shiori?sslmode=disable
networks:
shiori:
#nginx:
# image: nginx:alpine
# ports:
# - "8081:8081"
# volumes:
# - "./testdata/nginx.conf:/etc/nginx/nginx.conf:ro"
# depends_on:
# - shiori
postgres:
image: postgres:15
image: postgres:13.18
environment:
POSTGRES_PASSWORD: shiori
POSTGRES_USER: shiori
Expand All @@ -30,7 +42,7 @@ services:
networks:
shiori:
mariadb:
image: mariadb:11
image: mariadb:10.5.27
environment:
MYSQL_ROOT_PASSWORD: toor
MYSQL_DATABASE: shiori
Expand All @@ -41,7 +53,17 @@ services:
networks:
shiori:

#mysql:
# image: mysql:8.0.40
# environment:
# MYSQL_ROOT_PASSWORD: toor
# MYSQL_DATABASE: shiori
# MYSQL_USER: shiori
# MYSQL_PASSWORD: shiori
# ports:
# - 3306

volumes:
go-mod-cache:
networks:
shiori:


47 changes: 37 additions & 10 deletions docs/Contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,10 @@

To run the current development server with the defaults you can run the following command:

```bash
make serve
```

If you want to run the refactored server, you can run the following command:

```bash
make run-server
```

> **ℹ️ Note:** For more information into what the _refactored server_ means, please check this issue: https://github.com/go-shiori/shiori/issues/640
## Updating the API documentation

> **ℹ️ Note:** This only applies for the Rest API documentation under the `internal/http` folder, **not** the one under `internal/webserver`.
Expand Down Expand Up @@ -65,14 +57,19 @@ In order to run the test suite, you need to have running a local instance of Mar
If you have docker, you can do this by running the following command with the compose file provided:

```bash
docker-compose up -d mariadb postgres
docker-compose up -d mariadb mysql postgres
```

After that, provide the `SHIORI_TEST_PG_URL` and `SHIORI_TEST_MYSQL_URL` environment variables with the connection string to the databases:
After that, provide the environment variables for the unitest to connect to the database engines:

- `SHIORI_TEST_MYSQL_URL` for MySQL
- `SHIORI_TEST_MARIADB_URL` for MariaDB
- `SHIORI_TEST_PG_URL` for PostgreSQL

```
SHIORI_TEST_PG_URL=postgres://shiori:[email protected]:5432/shiori?sslmode=disable
SHIORI_TEST_MYSQL_URL=shiori:shiori@tcp(127.0.0.1:3306)/shiori
SHIORI_TEST_MARIADB_URL=shiori:shiori@tcp(127.0.0.1:3307)/shiori
```

Finally, run the tests with the following command:
Expand All @@ -94,3 +91,33 @@ mkdocs serve
This will start a local server at `http://127.0.0.1:8000` where you can preview your changes in real-time.

Documentation for production is generated automatically on every release and published using github pages.

## Running the server with docker

To run the development server using Docker, you can use the provided `docker-compose.yaml` file which includes both PostgreSQL and MariaDB databases:

```bash
docker compose up shiori
```

This will start the Shiori server on port 8080 with hot-reload enabled. Any changes you make to the code will automatically rebuild and restart the server.

By default, it uses SQLite mounting the local `dev-data` folder in the source code path. To use MariaDB or PostgreSQL instead, uncomment the `SHIORI_DATABASE_URL` line for the appropriate engine in the `docker-compose.yaml` file.

## Running the server using an nginx reverse proxy and a custom webroot

To test Shiori behind an nginx reverse proxy with a custom webroot (e.g., `/shiori/`), you can use the provided nginx configuration:

1. First, ensure the `SHIORI_HTTP_ROOT_PATH` environment variable is uncommented in `docker-compose.yaml`:
```yaml
SHIORI_HTTP_ROOT_PATH: /shiori/
```
2. Then start both Shiori and nginx services:
```bash
docker compose up shiori nginx
```

This will start the shiori service along with nginx. You can access Shiori using [http://localhost:8081/shiori](http://localhost:8081/shiori).

The nginx configuration in `testdata/nginx.conf` handles all the necessary configuration.
10 changes: 9 additions & 1 deletion docs/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ spec:
- name: app
hostPath:
path: /path/to/data/dir
- name: tmp
emptyDir:
medium: Memory
containers:
- name: shiori
image: ghcr.io/go-shiori/shiori:latest
Expand All @@ -103,6 +106,8 @@ spec:
volumeMounts:
- mountPath: /srv/shiori
name: app
- mountPath: /tmp
name: tmp
env:
- name: SHIORI_DIR
value: /srv/shiori
Expand All @@ -112,7 +117,10 @@ spec:
Here we are using a local directory to persist Shiori's data. You will need
to replace `/path/to/data/dir` with the path to the directory where you want
to keep your data. Since we haven't configured a database in particular,
to keep your data. We are also mounting an `EmptyDir` volume for `/tmp` so
we can successfully generate ebooks.

Since we haven't configured a database in particular,
Shiori will use SQLite. I don't think Postgres or MySQL is worth it for
such an app, but that's up to you. If you decide to use SQLite, I strongly
suggest to keep `replicas` set to 1 since SQLite usually allows at most
Expand Down
Loading

0 comments on commit ee2d8b2

Please sign in to comment.