Update `Set up development environment` in README.md. (#995)
This commit is contained in:
parent
7559a609aa
commit
0345bc1481
|
@ -5,7 +5,7 @@ cache/
|
||||||
/api/media_cache/
|
/api/media_cache/
|
||||||
/photos_path
|
/photos_path
|
||||||
photoview.db
|
photoview.db
|
||||||
photoview.db-journal
|
photoview.db-*
|
||||||
|
|
||||||
.env
|
.env
|
||||||
testing.env
|
testing.env
|
||||||
|
|
14
Dockerfile
14
Dockerfile
|
@ -37,7 +37,7 @@ ARG TARGETPLATFORM
|
||||||
# See for details: https://github.com/hadolint/hadolint/wiki/DL4006
|
# See for details: https://github.com/hadolint/hadolint/wiki/DL4006
|
||||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
|
|
||||||
COPY scripts/apt /app/scripts/apt
|
COPY scripts /app/scripts
|
||||||
COPY api /app/api
|
COPY api /app/api
|
||||||
WORKDIR /app/api
|
WORKDIR /app/api
|
||||||
|
|
||||||
|
@ -46,9 +46,9 @@ ENV PATH="${GOPATH}/bin:${PATH}"
|
||||||
ENV CGO_ENABLED=1
|
ENV CGO_ENABLED=1
|
||||||
|
|
||||||
# Download dependencies
|
# Download dependencies
|
||||||
RUN chmod +x /app/scripts/apt/*.sh \
|
RUN chmod +x /app/scripts/*.sh \
|
||||||
&& source /app/scripts/apt/set_compiler_env.sh \
|
&& source /app/scripts/set_compiler_env.sh \
|
||||||
&& /app/scripts/apt/install_build_dependencies.sh \
|
&& /app/scripts/install_build_dependencies.sh \
|
||||||
&& go env \
|
&& go env \
|
||||||
&& go mod download \
|
&& go mod download \
|
||||||
# Patch go-face
|
# Patch go-face
|
||||||
|
@ -67,14 +67,14 @@ ARG TARGETPLATFORM
|
||||||
# See for details: https://github.com/hadolint/hadolint/wiki/DL4006
|
# See for details: https://github.com/hadolint/hadolint/wiki/DL4006
|
||||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
|
|
||||||
COPY scripts/apt/install_runtime_dependencies.sh /app/scripts/apt/
|
COPY scripts/install_runtime_dependencies.sh /app/scripts/
|
||||||
|
|
||||||
# Create a user to run Photoview server
|
# Create a user to run Photoview server
|
||||||
RUN groupadd -g 999 photoview \
|
RUN groupadd -g 999 photoview \
|
||||||
&& useradd -r -u 999 -g photoview -m photoview \
|
&& useradd -r -u 999 -g photoview -m photoview \
|
||||||
# Required dependencies
|
# Required dependencies
|
||||||
&& chmod +x /app/scripts/apt/*.sh \
|
&& chmod +x /app/scripts/*.sh \
|
||||||
&& /app/scripts/apt/install_runtime_dependencies.sh
|
&& /app/scripts/install_runtime_dependencies.sh
|
||||||
|
|
||||||
WORKDIR /home/photoview
|
WORKDIR /home/photoview
|
||||||
COPY api/data /app/data
|
COPY api/data /app/data
|
||||||
|
|
106
README.md
106
README.md
|
@ -171,43 +171,93 @@ Remember, every contribution counts. Let's make this project better together!
|
||||||
|
|
||||||
## Set up development environment
|
## Set up development environment
|
||||||
|
|
||||||
### Local setup
|
### Developing dependencies
|
||||||
|
|
||||||
1. Install a local mysql server, and make a new database
|
- API
|
||||||
2. Rename `/api/example.env` to `.env` and update the `MYSQL_URL` field
|
- Required packages:
|
||||||
3. Rename `/ui/example.env` to `.env`
|
- `golang` >= 1.22
|
||||||
|
- `g++`
|
||||||
|
- `libc-dev`
|
||||||
|
- `libheif` >= 1.15.1
|
||||||
|
- [go-face Requirements](https://github.com/Kagami/go-face#requirements)
|
||||||
|
- `dlib`
|
||||||
|
- `libjpeg`
|
||||||
|
- `libblas`
|
||||||
|
- `libcblas`, recommended using `libatlas-base`
|
||||||
|
- `liblapack`
|
||||||
|
- Optional tools during developing:
|
||||||
|
- [`reflex`](https://github.com/cespare/reflex): a source code monitoring tool, which automatically rebuilds and restarts the server, running from the code in development.
|
||||||
|
- `sqlite`: the SQLite DBMS, useful to interact with Photoview's SQLite DB directly if you use it in your development environment.
|
||||||
|
- UI
|
||||||
|
- Required packages:
|
||||||
|
- `node` = 18
|
||||||
|
|
||||||
### Start API server
|
In Debian/Ubuntu, install dependencies:
|
||||||
|
|
||||||
Make sure [golang](https://golang.org/) is installed.
|
|
||||||
|
|
||||||
Some C libraries are needed to compile the API, see [go-face requirements](https://github.com/Kagami/go-face#requirements) for more details.
|
|
||||||
They can be installed as shown below:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# Ubuntu
|
$ sudo apt update # Update the package list
|
||||||
sudo add-apt-repository ppa:strukturag/libheif
|
$ sudo apt install golang g++ libc-dev libheif-dev libdlib-dev libjpeg-dev libblas-dev libatlas-base-dev liblapack-dev # For API requirement
|
||||||
sudo add-apt-repository ppa:strukturag/libde265
|
$ sudo apt install reflex sqlite3 # For API optional tools
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install libdlib-dev libblas-dev libatlas-base-dev liblapack-dev libjpeg-turbo8-dev libheif-dev
|
|
||||||
# Debian
|
|
||||||
sudo apt-get install libdlib-dev libblas-dev libatlas-base-dev liblapack-dev libjpeg62-turbo-dev libheif-dev
|
|
||||||
# macOS
|
|
||||||
brew install dlib libheif
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In macOS, install dependencies:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ brew update # Update the package list
|
||||||
|
$ brew install golang gcc libheif dlib jpeg # For API
|
||||||
|
$ brew install reflex sqlite3 # For API optional tools
|
||||||
|
```
|
||||||
|
|
||||||
|
Please follow the package manager guidance if you don't use `apt` or `homebrew`.
|
||||||
|
|
||||||
|
For `node`, recommend to use [nvm](https://github.com/nvm-sh/nvm). Follow [Installing and Updating](https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating) to install `nvm` locally, then:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ nvm install 18
|
||||||
|
$ nvm use 18
|
||||||
|
```
|
||||||
|
|
||||||
|
You can install `node` with other package manager if you like.
|
||||||
|
|
||||||
|
### Local setup
|
||||||
|
|
||||||
|
1. Rename `/api/example.env` to `.env`
|
||||||
|
- Update `PHOTOVIEW_SQLITE_PATH` if you don't want to put sqlite file under `/api`
|
||||||
|
- To set a different DBMS driver
|
||||||
|
- Comment the SQLite path variable
|
||||||
|
- Update `PHOTOVIEW_DATABASE_DRIVER` with your driver
|
||||||
|
- Uncomment the corresponding connection string variable for the new driver
|
||||||
|
- Optional: modify other variables if needed according to the inline comments
|
||||||
|
2. Rename `/ui/example.env` to `.env`
|
||||||
|
|
||||||
|
### Start API server
|
||||||
|
|
||||||
Then run the following commands:
|
Then run the following commands:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd ./api
|
# Optional: Set the compiler environment in Debian/Ubuntu
|
||||||
go install
|
$ source ./scripts/set_compiler_env.sh
|
||||||
go run server.go
|
# Set the compiler environment with `homebrew`
|
||||||
|
$ export CPLUS_INCLUDE_PATH="$(brew --prefix)/opt/jpeg/include:$(brew --prefix)/opt/dlib/include"
|
||||||
|
$ export LD_LIBRARY_PATH="$(brew --prefix)/opt/jpeg/lib:$(brew --prefix)/opt/dlib/lib"
|
||||||
|
$ export LIBRARY_PATH="$(brew --prefix)/opt/jpeg/lib:$(brew --prefix)/opt/dlib/lib"
|
||||||
|
# Start API server
|
||||||
|
$ cd ./api
|
||||||
|
$ go run .
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you want to recompile the server automatically when code changes:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Start API server
|
||||||
|
$ cd ./api
|
||||||
|
$ reflex -g '*.go' -s -- go run .
|
||||||
|
```
|
||||||
|
|
||||||
|
The graphql playground can now be accessed at [localhost:4001](http://localhost:4001).
|
||||||
|
|
||||||
### Start UI server
|
### Start UI server
|
||||||
|
|
||||||
Make sure [node](https://nodejs.org/en/) is installed.
|
|
||||||
In a new terminal window run the following commands:
|
In a new terminal window run the following commands:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -216,8 +266,14 @@ npm install
|
||||||
npm start
|
npm start
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you want to recompile the server automatically when code changes:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ cd ./ui
|
||||||
|
$ npm mon
|
||||||
|
```
|
||||||
|
|
||||||
The site can now be accessed at [localhost:1234](http://localhost:1234).
|
The site can now be accessed at [localhost:1234](http://localhost:1234).
|
||||||
And the graphql playground at [localhost:4001](http://localhost:4001)
|
|
||||||
|
|
||||||
## Sponsors
|
## Sponsors
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
# Copy this file to .env
|
# Copy this file to .env
|
||||||
|
|
||||||
PHOTOVIEW_DATABASE_DRIVER=mysql
|
PHOTOVIEW_DATABASE_DRIVER=sqlite
|
||||||
PHOTOVIEW_MYSQL_URL=user:password@tcp(localhost)/dbname
|
|
||||||
|
# Specifies the filepath for the sqlite database, if PHOTOVIEW_DATABASE_DRIVER is set to 'sqlite'
|
||||||
|
PHOTOVIEW_SQLITE_PATH=photoview.db
|
||||||
|
|
||||||
|
# Specifies the connection string for the mysql database, if PHOTOVIEW_DATABASE_DRIVER is set to 'mysql'
|
||||||
|
# PHOTOVIEW_MYSQL_URL=user:password@tcp(localhost)/dbname
|
||||||
|
|
||||||
# Specifies the connection string for the postgres database, if PHOTOVIEW_DATABASE_DRIVER is set to 'postgres'
|
# Specifies the connection string for the postgres database, if PHOTOVIEW_DATABASE_DRIVER is set to 'postgres'
|
||||||
# See https://www.postgresql.org/docs/current/libpq-ssl.html for possible ssl modes
|
# See https://www.postgresql.org/docs/current/libpq-ssl.html for possible ssl modes
|
||||||
# PHOTOVIEW_POSTGRES_URL=postgres://user:password@host:port/dbname?sslmode=(disable|allow|...)
|
# PHOTOVIEW_POSTGRES_URL=postgres://user:password@host:port/dbname?sslmode=(disable|allow|...)
|
||||||
|
|
||||||
# Specifies the filepath for the sqlite database, if PHOTOVIEW_DATABASE_DRIVER is set to 'sqlite'
|
|
||||||
# PHOTOVIEW_SQLITE_PATH=photoview.db
|
|
||||||
|
|
||||||
PHOTOVIEW_LISTEN_IP=localhost
|
PHOTOVIEW_LISTEN_IP=localhost
|
||||||
PHOTOVIEW_LISTEN_PORT=4001
|
PHOTOVIEW_LISTEN_PORT=4001
|
||||||
|
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
brew update
|
|
||||||
brew install libheif dlib jpeg
|
|
|
@ -1,4 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
brew update
|
|
||||||
brew install exiftool ffmpeg darktable
|
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
export CPLUS_INCLUDE_PATH="$(brew --prefix)/opt/jpeg/include:$(brew --prefix)/opt/dlib/include"
|
|
||||||
export LD_LIBRARY_PATH="$(brew --prefix)/opt/jpeg/lib:$(brew --prefix)/opt/dlib/lib"
|
|
||||||
export LIBRARY_PATH="$(brew --prefix)/opt/jpeg/lib:$(brew --prefix)/opt/dlib/lib"
|
|
Loading…
Reference in New Issue