Backend: Upgrade & improve Dockerfiles #263

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-03-23 20:29:31 +01:00
parent 3aa465c779
commit a1706a5922
16 changed files with 114 additions and 103 deletions

View file

@ -1,4 +1,4 @@
FROM photoprism/development:20200203 FROM photoprism/development:20200323
# Set up project directory # Set up project directory
WORKDIR "/go/src/github.com/photoprism/photoprism" WORKDIR "/go/src/github.com/photoprism/photoprism"

View file

@ -84,12 +84,12 @@ RUN npm install --unsafe-perm=true --allow-root -g npm testcafe chromedriver
RUN npm config set cache ~/.cache/npm RUN npm config set cache ~/.cache/npm
# Install Go # Install Go
ENV GOLANG_VERSION 1.13.7 ENV GOLANG_VERSION 1.14.1
RUN set -eux; \ RUN set -eux; \
\ \
url="https://golang.org/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz"; \ url="https://golang.org/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz"; \
wget -O go.tgz "$url"; \ wget -O go.tgz "$url"; \
echo "b3dd4bd781a0271b33168e627f7f43886b4c5d1c794a4015abf34e99c6526ca3 *go.tgz" | sha256sum -c -; \ echo "2f49eb17ce8b48c680cdb166ffd7389702c0dec6effa090c324804a5cac8a7f8 *go.tgz" | sha256sum -c -; \
tar -C /usr/local -xzf go.tgz; \ tar -C /usr/local -xzf go.tgz; \
rm go.tgz; \ rm go.tgz; \
export PATH="/usr/local/go/bin:$PATH"; \ export PATH="/usr/local/go/bin:$PATH"; \

View file

@ -69,12 +69,12 @@ RUN npm install --unsafe-perm=true --allow-root -g npm
RUN npm config set cache ~/.cache/npm RUN npm config set cache ~/.cache/npm
# Install Go # Install Go
ENV GOLANG_VERSION 1.13.7 ENV GOLANG_VERSION 1.14.1
RUN set -eux; \ RUN set -eux; \
\ \
url="https://golang.org/dl/go${GOLANG_VERSION}.linux-arm64.tar.gz"; \ url="https://golang.org/dl/go${GOLANG_VERSION}.linux-arm64.tar.gz"; \
wget -O go.tgz "$url"; \ wget -O go.tgz "$url"; \
echo "8717de6c662ada01b7bf318f5025c046b57f8c10cd39a88268bdc171cc7e4eab *go.tgz" | sha256sum -c -; \ echo "5d8f2c202f35481617e24e63cca30c6afb1ec2585006c4a6ecf16c5f4928ab3c *go.tgz" | sha256sum -c -; \
tar -C /usr/local -xzf go.tgz; \ tar -C /usr/local -xzf go.tgz; \
rm go.tgz; \ rm go.tgz; \
export PATH="/usr/local/go/bin:$PATH"; \ export PATH="/usr/local/go/bin:$PATH"; \
@ -132,30 +132,36 @@ COPY --from=build /usr/lib/libtensorflow_framework.so /usr/lib/libtensorflow_fra
RUN ldconfig RUN ldconfig
# Create and configure photoprism user WORKDIR /photoprism
RUN useradd -ms /bin/bash photoprism
USER photoprism
WORKDIR /home/photoprism
ENV PATH /home/photoprism/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV TF_CPP_MIN_LOG_LEVEL 2 ENV TF_CPP_MIN_LOG_LEVEL 2
ENV PHOTOPRISM_CONFIG_FILE /home/photoprism/.config/photoprism/photoprism.yml
# Copy assets to /home/photoprism ENV PATH /photoprism/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
COPY --chown=photoprism --from=build /root/.local/bin/photoprism /home/photoprism/.local/bin/photoprism
COPY --chown=photoprism --from=build /root/.local/share/photoprism /home/photoprism/.local/share/photoprism ENV PHOTOPRISM_CONFIG_FILE /photoprism/config/photoprism.yml
COPY --chown=photoprism --from=build /root/.config/photoprism /home/photoprism/.config/photoprism ENV PHOTOPRISM_IMPORT_PATH /photoprism/import
ENV PHOTOPRISM_EXPORT_PATH /photoprism/export
ENV PHOTOPRISM_ORIGINALS_PATH /photoprism/originals
ENV PHOTOPRISM_DATABASE_PATH /photoprism/database
ENV PHOTOPRISM_CACHE_PATH /photoprism/cache
ENV PHOTOPRISM_ASSETS_PATH /photoprism/assets
ENV PHOTOPRISM_RESOURCES_PATH /photoprism/assets/resources
ENV PHOTOPRISM_LOG_FILENAME /photoprism/photoprism.log
ENV PHOTOPRISM_PID_FILENAME /photoprism/photoprism.pid
# Copy files to /photoprism
COPY --from=build /root/.local/bin/photoprism /photoprism/bin/photoprism
COPY --from=build /root/.local/share/photoprism /photoprism/assets
COPY --from=build /root/.config/photoprism /photoprism/config
# Create directories # Create directories
RUN mkdir -p /home/photoprism/.cache/photoprism \ RUN mkdir -p /photoprism/cache \
/home/photoprism/Pictures/Originals \ /photoprism/database \
/home/photoprism/Pictures/Import \ /photoprism/originals \
/home/photoprism/Pictures/Export /photoprism/import \
/photoprism/export
# Fix permissions RUN chmod -R 777 /photoprism
USER root
RUN chown -R photoprism:photoprism /home/photoprism
USER photoprism
# Show photoprism version # Show photoprism version
RUN photoprism -v RUN photoprism -v

View file

@ -20,22 +20,20 @@ services:
PHOTOPRISM_DESCRIPTION: "Personal Photo Management powered by Go and Google TensorFlow. Free and open-source." PHOTOPRISM_DESCRIPTION: "Personal Photo Management powered by Go and Google TensorFlow. Free and open-source."
PHOTOPRISM_AUTHOR: "Anonymous" PHOTOPRISM_AUTHOR: "Anonymous"
PHOTOPRISM_TWITTER: "@browseyourlife" PHOTOPRISM_TWITTER: "@browseyourlife"
PHOTOPRISM_IMPORT_PATH: "/home/photoprism/Pictures/Import"
PHOTOPRISM_EXPORT_PATH: "/home/photoprism/Pictures/Export"
PHOTOPRISM_ORIGINALS_PATH: "/home/photoprism/Pictures/Originals"
PHOTOPRISM_UPLOAD_NSFW: "true" PHOTOPRISM_UPLOAD_NSFW: "true"
PHOTOPRISM_HIDE_NSFW: "false" PHOTOPRISM_HIDE_NSFW: "false"
PHOTOPRISM_EXPERIMENTAL: "false" PHOTOPRISM_EXPERIMENTAL: "false"
PHOTOPRISM_DEBUG: "false" PHOTOPRISM_DEBUG: "false"
PHOTOPRISM_READONLY: "false" PHOTOPRISM_READONLY: "false"
PHOTOPRISM_PUBLIC: "false" PHOTOPRISM_PUBLIC: "false"
PHOTOPRISM_ADMIN_PASSWORD: "photoprism" PHOTOPRISM_ADMIN_PASSWORD: "photoprism" # Plain text or bcrypt hash (escape "$" with "$$")
PHOTOPRISM_WEBDAV_PASSWORD: "photoprism" # Plain text only (username "photoprism")
volumes: volumes:
- "~/Pictures/Originals:/home/photoprism/Pictures/Originals" # [local path]:[container path] - "~/Pictures/Originals:/photoprism/originals" # [local path]:[container path]
- "~/Pictures/Import:/home/photoprism/Pictures/Import" # [local path]:[container path] (optional) - "~/Pictures/Import:/photoprism/import" # [local path]:[container path] (optional)
- "~/Pictures/Export:/home/photoprism/Pictures/Export" # [local path]:[container path] (optional) - "~/Pictures/Export:/photoprism/export" # [local path]:[container path] (optional)
- "photoprism-cache:/home/photoprism/.cache/photoprism" # keep thumbnail cache - "photoprism-cache:/photoprism/cache" # keep thumbnail cache
- "photoprism-database:/home/photoprism/.local/share/photoprism/resources/database" # keep database files - "photoprism-database:/photoprism/database" # keep database files
volumes: # keep this volumes: # keep this
photoprism-cache: photoprism-cache:

View file

@ -1,4 +1,4 @@
FROM photoprism/development:20200203 as build FROM photoprism/development:20200323 as build
# Set up project directory # Set up project directory
WORKDIR "/go/src/github.com/photoprism/photoprism" WORKDIR "/go/src/github.com/photoprism/photoprism"
@ -48,30 +48,36 @@ RUN sh -c "echo 'deb http://download.opensuse.org/repositories/graphics:/darktab
apt-get clean && \ apt-get clean && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
# Create and configure photoprism user WORKDIR /photoprism
RUN useradd -ms /bin/bash photoprism
USER photoprism
WORKDIR /home/photoprism
ENV PATH /home/photoprism/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV TF_CPP_MIN_LOG_LEVEL 2 ENV TF_CPP_MIN_LOG_LEVEL 2
ENV PHOTOPRISM_CONFIG_FILE /home/photoprism/.config/photoprism/photoprism.yml
# Copy assets to /home/photoprism ENV PATH /photoprism/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
COPY --chown=photoprism --from=build /root/.local/bin/photoprism /home/photoprism/.local/bin/photoprism
COPY --chown=photoprism --from=build /root/.local/share/photoprism /home/photoprism/.local/share/photoprism ENV PHOTOPRISM_CONFIG_FILE /photoprism/config/photoprism.yml
COPY --chown=photoprism --from=build /root/.config/photoprism /home/photoprism/.config/photoprism ENV PHOTOPRISM_IMPORT_PATH /photoprism/import
ENV PHOTOPRISM_EXPORT_PATH /photoprism/export
ENV PHOTOPRISM_ORIGINALS_PATH /photoprism/originals
ENV PHOTOPRISM_DATABASE_PATH /photoprism/database
ENV PHOTOPRISM_CACHE_PATH /photoprism/cache
ENV PHOTOPRISM_ASSETS_PATH /photoprism/assets
ENV PHOTOPRISM_RESOURCES_PATH /photoprism/assets/resources
ENV PHOTOPRISM_LOG_FILENAME /photoprism/photoprism.log
ENV PHOTOPRISM_PID_FILENAME /photoprism/photoprism.pid
# Copy files to /photoprism
COPY --from=build /root/.local/bin/photoprism /photoprism/bin/photoprism
COPY --from=build /root/.local/share/photoprism /photoprism/assets
COPY --from=build /root/.config/photoprism /photoprism/config
# Create directories # Create directories
RUN mkdir -p /home/photoprism/.cache/photoprism \ RUN mkdir -p /photoprism/cache \
/home/photoprism/Pictures/Originals \ /photoprism/database \
/home/photoprism/Pictures/Import \ /photoprism/originals \
/home/photoprism/Pictures/Export /photoprism/import \
/photoprism/export
# Fix permissions RUN chmod -R 777 /photoprism
USER root
RUN chown -R photoprism:photoprism /home/photoprism
USER photoprism
# Show photoprism version # Show photoprism version
RUN photoprism -v RUN photoprism -v

View file

@ -18,9 +18,6 @@ services:
PHOTOPRISM_DESCRIPTION: "Personal Photo Management powered by Go and Google TensorFlow. Free and open-source." PHOTOPRISM_DESCRIPTION: "Personal Photo Management powered by Go and Google TensorFlow. Free and open-source."
PHOTOPRISM_AUTHOR: "Anonymous" PHOTOPRISM_AUTHOR: "Anonymous"
PHOTOPRISM_TWITTER: "@browseyourlife" PHOTOPRISM_TWITTER: "@browseyourlife"
PHOTOPRISM_IMPORT_PATH: "/home/photoprism/Pictures/Import"
PHOTOPRISM_EXPORT_PATH: "/home/photoprism/Pictures/Export"
PHOTOPRISM_ORIGINALS_PATH: "/home/photoprism/Pictures/Originals"
PHOTOPRISM_UPLOAD_NSFW: "true" PHOTOPRISM_UPLOAD_NSFW: "true"
PHOTOPRISM_HIDE_NSFW: "false" PHOTOPRISM_HIDE_NSFW: "false"
PHOTOPRISM_EXPERIMENTAL: "false" PHOTOPRISM_EXPERIMENTAL: "false"
@ -28,12 +25,13 @@ services:
PHOTOPRISM_READONLY: "false" PHOTOPRISM_READONLY: "false"
PHOTOPRISM_PUBLIC: "false" PHOTOPRISM_PUBLIC: "false"
PHOTOPRISM_ADMIN_PASSWORD: "photoprism" # Plain text or bcrypt hash (escape "$" with "$$") PHOTOPRISM_ADMIN_PASSWORD: "photoprism" # Plain text or bcrypt hash (escape "$" with "$$")
PHOTOPRISM_WEBDAV_PASSWORD: "photoprism" # Plain text only (username "photoprism")
volumes: volumes:
- "~/Pictures/Originals:/home/photoprism/Pictures/Originals" # [local path]:[container path] - "~/Pictures/Originals:/photoprism/originals" # [local path]:[container path]
- "~/Pictures/Import:/home/photoprism/Pictures/Import" # [local path]:[container path] (optional) - "~/Pictures/Import:/photoprism/import" # [local path]:[container path] (optional)
- "~/Pictures/Export:/home/photoprism/Pictures/Export" # [local path]:[container path] (optional) - "~/Pictures/Export:/photoprism/export" # [local path]:[container path] (optional)
- "photoprism-cache:/home/photoprism/.cache/photoprism" # keep thumbnail cache - "photoprism-cache:/photoprism/cache" # keep thumbnail cache
- "photoprism-database:/home/photoprism/.local/share/photoprism/resources/database" # keep database files - "photoprism-database:/photoprism/database" # keep database files
volumes: # keep this volumes: # keep this
photoprism-cache: photoprism-cache:

View file

@ -1881,7 +1881,8 @@
}, },
"minimist": { "minimist": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "" "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
} }
} }
}, },
@ -10901,7 +10902,8 @@
}, },
"minimist": { "minimist": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "" "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
}, },
"postcss": { "postcss": {
"version": "7.0.21", "version": "7.0.21",
@ -11907,7 +11909,8 @@
}, },
"minimist": { "minimist": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "" "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
} }
} }
}, },
@ -12624,7 +12627,8 @@
}, },
"minimist": { "minimist": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "" "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
}, },
"parse-json": { "parse-json": {
"version": "2.2.0", "version": "2.2.0",
@ -12925,7 +12929,8 @@
}, },
"minimist": { "minimist": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "" "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
}, },
"string-width": { "string-width": {
"version": "3.1.0", "version": "3.1.0",

2
go.sum
View file

@ -375,8 +375,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2eP
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa h1:F+8P+gmewFQYRk6JoLQLwjBCTu3mcIURZfNkVweuRKA=
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200219183655-46282727080f h1:dB42wwhNuwPvh8f+5zZWNcU+F2Xs/B9wXXwvUCOH7r8= golang.org/x/net v0.0.0-20200219183655-46282727080f h1:dB42wwhNuwPvh8f+5zZWNcU+F2Xs/B9wXXwvUCOH7r8=
golang.org/x/net v0.0.0-20200219183655-46282727080f/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200219183655-46282727080f/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=

View file

@ -41,18 +41,6 @@ func configAction(ctx *cli.Context) error {
fmt.Printf("config-file %s\n", conf.ConfigFile()) fmt.Printf("config-file %s\n", conf.ConfigFile())
fmt.Printf("config-path %s\n", conf.ConfigPath()) fmt.Printf("config-path %s\n", conf.ConfigPath())
fmt.Printf("database-driver %s\n", conf.DatabaseDriver())
fmt.Printf("database-dsn %s\n", conf.DatabaseDsn())
fmt.Printf("sql-host %s\n", conf.SqlServerHost())
fmt.Printf("sql-port %d\n", conf.SqlServerPort())
fmt.Printf("sql-password %s\n", conf.SqlServerPassword())
fmt.Printf("sql-path %s\n", conf.SqlServerPath())
fmt.Printf("http-host %s\n", conf.HttpServerHost())
fmt.Printf("http-port %d\n", conf.HttpServerPort())
fmt.Printf("http-mode %s\n", conf.HttpServerMode())
fmt.Printf("assets-path %s\n", conf.AssetsPath()) fmt.Printf("assets-path %s\n", conf.AssetsPath())
fmt.Printf("originals-path %s\n", conf.OriginalsPath()) fmt.Printf("originals-path %s\n", conf.OriginalsPath())
fmt.Printf("import-path %s\n", conf.ImportPath()) fmt.Printf("import-path %s\n", conf.ImportPath())
@ -68,6 +56,18 @@ func configAction(ctx *cli.Context) error {
fmt.Printf("static-path %s\n", conf.HttpStaticPath()) fmt.Printf("static-path %s\n", conf.HttpStaticPath())
fmt.Printf("static-build-path %s\n", conf.HttpStaticBuildPath()) fmt.Printf("static-build-path %s\n", conf.HttpStaticBuildPath())
fmt.Printf("database-path %s\n", conf.DatabasePath())
fmt.Printf("database-driver %s\n", conf.DatabaseDriver())
fmt.Printf("database-dsn %s\n", conf.DatabaseDsn())
fmt.Printf("sql-host %s\n", conf.SqlServerHost())
fmt.Printf("sql-port %d\n", conf.SqlServerPort())
fmt.Printf("sql-password %s\n", conf.SqlServerPassword())
fmt.Printf("http-host %s\n", conf.HttpServerHost())
fmt.Printf("http-port %d\n", conf.HttpServerPort())
fmt.Printf("http-mode %s\n", conf.HttpServerMode())
fmt.Printf("sips-bin %s\n", conf.SipsBin()) fmt.Printf("sips-bin %s\n", conf.SipsBin())
fmt.Printf("darktable-bin %s\n", conf.DarktableBin()) fmt.Printf("darktable-bin %s\n", conf.DarktableBin())
fmt.Printf("exiftool-bin %s\n", conf.ExifToolBin()) fmt.Printf("exiftool-bin %s\n", conf.ExifToolBin())

View file

@ -48,11 +48,11 @@ func startAction(ctx *cli.Context) error {
if ctx.IsSet("config") { if ctx.IsSet("config") {
fmt.Printf("NAME VALUE\n") fmt.Printf("NAME VALUE\n")
fmt.Printf("detach-server %t\n", conf.DetachServer()) fmt.Printf("detach-server %t\n", conf.DetachServer())
fmt.Printf("database-path %s\n", conf.DatabasePath())
fmt.Printf("sql-host %s\n", conf.SqlServerHost()) fmt.Printf("sql-host %s\n", conf.SqlServerHost())
fmt.Printf("sql-port %d\n", conf.SqlServerPort()) fmt.Printf("sql-port %d\n", conf.SqlServerPort())
fmt.Printf("sql-password %s\n", conf.SqlServerPassword()) fmt.Printf("sql-password %s\n", conf.SqlServerPassword())
fmt.Printf("sql-path %s\n", conf.SqlServerPath())
fmt.Printf("http-host %s\n", conf.HttpServerHost()) fmt.Printf("http-host %s\n", conf.HttpServerHost())
fmt.Printf("http-port %d\n", conf.HttpServerPort()) fmt.Printf("http-port %d\n", conf.HttpServerPort())

View file

@ -123,7 +123,7 @@ func TestConfig_SqlServerPath(t *testing.T) {
ctx := CliTestContext() ctx := CliTestContext()
c := NewConfig(ctx) c := NewConfig(ctx)
path := c.SqlServerPath() path := c.DatabasePath()
assert.Equal(t, "/go/src/github.com/photoprism/photoprism/assets/resources/database", path) assert.Equal(t, "/go/src/github.com/photoprism/photoprism/assets/resources/database", path)
} }

View file

@ -114,7 +114,7 @@ func (c *Config) connectToDatabase(ctx context.Context) error {
if isTiDB { if isTiDB {
log.Infof("starting database server at %s:%d\n", c.SqlServerHost(), c.SqlServerPort()) log.Infof("starting database server at %s:%d\n", c.SqlServerHost(), c.SqlServerPort())
go tidb.Start(ctx, c.SqlServerPath(), c.SqlServerPort(), c.SqlServerHost(), c.Debug()) go tidb.Start(ctx, c.DatabasePath(), c.SqlServerPort(), c.SqlServerHost(), c.Debug())
} }
for i := 1; i <= 12; i++ { for i := 1; i <= 12; i++ {

View file

@ -61,8 +61,8 @@ func (c *Config) CreateDirectories() error {
return createError(c.ResourcesPath(), err) return createError(c.ResourcesPath(), err)
} }
if err := os.MkdirAll(c.SqlServerPath(), os.ModePerm); err != nil { if err := os.MkdirAll(c.DatabasePath(), os.ModePerm); err != nil {
return createError(c.SqlServerPath(), err) return createError(c.DatabasePath(), err)
} }
if err := os.MkdirAll(c.TensorFlowModelPath(), os.ModePerm); err != nil { if err := os.MkdirAll(c.TensorFlowModelPath(), os.ModePerm); err != nil {

View file

@ -144,6 +144,11 @@ var GlobalFlags = []cli.Flag{
Value: "~/.local/share/photoprism", Value: "~/.local/share/photoprism",
EnvVar: "PHOTOPRISM_ASSETS_PATH", EnvVar: "PHOTOPRISM_ASSETS_PATH",
}, },
cli.StringFlag{
Name: "database-path",
Usage: "built-in database server storage path",
EnvVar: "PHOTOPRISM_DATABASE_PATH",
},
cli.StringFlag{ cli.StringFlag{
Name: "database-driver", Name: "database-driver",
Usage: "database `DRIVER` (internal or mysql)", Usage: "database `DRIVER` (internal or mysql)",
@ -205,11 +210,6 @@ var GlobalFlags = []cli.Flag{
Usage: "built-in SQL server host", Usage: "built-in SQL server host",
EnvVar: "PHOTOPRISM_SQL_HOST", EnvVar: "PHOTOPRISM_SQL_HOST",
}, },
cli.StringFlag{
Name: "sql-path",
Usage: "built-in SQL server storage path",
EnvVar: "PHOTOPRISM_SQL_PATH",
},
cli.StringFlag{ cli.StringFlag{
Name: "sql-password", Name: "sql-password",
Usage: "built-in SQL server password", Usage: "built-in SQL server password",

View file

@ -47,22 +47,22 @@ type Params struct {
LogLevel string `yaml:"log-level" flag:"log-level"` LogLevel string `yaml:"log-level" flag:"log-level"`
ConfigFile string ConfigFile string
ConfigPath string `yaml:"config-path" flag:"config-path"` ConfigPath string `yaml:"config-path" flag:"config-path"`
AssetsPath string `yaml:"assets-path" flag:"assets-path"`
ResourcesPath string `yaml:"resources-path" flag:"resources-path"`
CachePath string `yaml:"cache-path" flag:"cache-path"` CachePath string `yaml:"cache-path" flag:"cache-path"`
OriginalsPath string `yaml:"originals-path" flag:"originals-path"` OriginalsPath string `yaml:"originals-path" flag:"originals-path"`
ImportPath string `yaml:"import-path" flag:"import-path"` ImportPath string `yaml:"import-path" flag:"import-path"`
ExportPath string `yaml:"export-path" flag:"export-path"` ExportPath string `yaml:"export-path" flag:"export-path"`
AssetsPath string `yaml:"assets-path" flag:"assets-path"`
ResourcesPath string `yaml:"resources-path" flag:"resources-path"`
DatabasePath string `yaml:"database-path" flag:"database-path"`
DatabaseDriver string `yaml:"database-driver" flag:"database-driver"`
DatabaseDsn string `yaml:"database-dsn" flag:"database-dsn"`
SqlServerHost string `yaml:"sql-host" flag:"sql-host"` SqlServerHost string `yaml:"sql-host" flag:"sql-host"`
SqlServerPort uint `yaml:"sql-port" flag:"sql-port"` SqlServerPort uint `yaml:"sql-port" flag:"sql-port"`
SqlServerPath string `yaml:"sql-path" flag:"sql-path"`
SqlServerPassword string `yaml:"sql-password" flag:"sql-password"` SqlServerPassword string `yaml:"sql-password" flag:"sql-password"`
HttpServerHost string `yaml:"http-host" flag:"http-host"` HttpServerHost string `yaml:"http-host" flag:"http-host"`
HttpServerPort int `yaml:"http-port" flag:"http-port"` HttpServerPort int `yaml:"http-port" flag:"http-port"`
HttpServerMode string `yaml:"http-mode" flag:"http-mode"` HttpServerMode string `yaml:"http-mode" flag:"http-mode"`
HttpServerPassword string `yaml:"http-password" flag:"http-password"` HttpServerPassword string `yaml:"http-password" flag:"http-password"`
DatabaseDriver string `yaml:"database-driver" flag:"database-driver"`
DatabaseDsn string `yaml:"database-dsn" flag:"database-dsn"`
SipsBin string `yaml:"sips-bin" flag:"sips-bin"` SipsBin string `yaml:"sips-bin" flag:"sips-bin"`
DarktableBin string `yaml:"darktable-bin" flag:"darktable-bin"` DarktableBin string `yaml:"darktable-bin" flag:"darktable-bin"`
ExifToolBin string `yaml:"exiftool-bin" flag:"exiftool-bin"` ExifToolBin string `yaml:"exiftool-bin" flag:"exiftool-bin"`
@ -114,7 +114,7 @@ func (c *Params) expandFilenames() {
c.OriginalsPath = fs.Abs(c.OriginalsPath) c.OriginalsPath = fs.Abs(c.OriginalsPath)
c.ImportPath = fs.Abs(c.ImportPath) c.ImportPath = fs.Abs(c.ImportPath)
c.ExportPath = fs.Abs(c.ExportPath) c.ExportPath = fs.Abs(c.ExportPath)
c.SqlServerPath = fs.Abs(c.SqlServerPath) c.DatabasePath = fs.Abs(c.DatabasePath)
c.PIDFilename = fs.Abs(c.PIDFilename) c.PIDFilename = fs.Abs(c.PIDFilename)
c.LogFilename = fs.Abs(c.LogFilename) c.LogFilename = fs.Abs(c.LogFilename)
} }

View file

@ -2,6 +2,15 @@ package config
import "github.com/photoprism/photoprism/pkg/fs" import "github.com/photoprism/photoprism/pkg/fs"
// DatabasePath returns the database storage path for TiDB.
func (c *Config) DatabasePath() string {
if c.config.DatabasePath == "" {
return c.ResourcesPath() + "/database"
}
return fs.Abs(c.config.DatabasePath)
}
// DetachServer returns true if server should detach from console (daemon mode). // DetachServer returns true if server should detach from console (daemon mode).
func (c *Config) DetachServer() bool { func (c *Config) DetachServer() bool {
return c.config.DetachServer return c.config.DetachServer
@ -81,15 +90,6 @@ func (c *Config) SqlServerPort() uint {
return c.config.SqlServerPort return c.config.SqlServerPort
} }
// SqlServerPath returns the database storage path for TiDB.
func (c *Config) SqlServerPath() string {
if c.config.SqlServerPath == "" {
return c.ResourcesPath() + "/database"
}
return fs.Abs(c.config.SqlServerPath)
}
// SqlServerPassword returns the password for the built-in database server. // SqlServerPassword returns the password for the built-in database server.
func (c *Config) SqlServerPassword() string { func (c *Config) SqlServerPassword() string {
return c.config.SqlServerPassword return c.config.SqlServerPassword