diff --git a/cmd/photoprism/photoprism.go b/cmd/photoprism/photoprism.go index 870502012..48e35c2f1 100644 --- a/cmd/photoprism/photoprism.go +++ b/cmd/photoprism/photoprism.go @@ -6,6 +6,7 @@ import ( "github.com/photoprism/photoprism/internal/photoprism" "github.com/photoprism/photoprism/internal/server" "github.com/urfave/cli" + "log" "os" ) @@ -78,7 +79,13 @@ func main() { conf.ServerMode = context.String("server-mode") } - conf.CreateDirectories() + if conf.ServerPort < 1 { + log.Fatal("Server port must be a positive integer") + } + + if err := conf.CreateDirectories(); err != nil { + log.Fatal(err) + } conf.MigrateDb() @@ -112,7 +119,9 @@ func main() { Action: func(context *cli.Context) error { conf := photoprism.NewConfig(context) - conf.CreateDirectories() + if err := conf.CreateDirectories(); err != nil { + log.Fatal(err) + } conf.MigrateDb() @@ -137,7 +146,9 @@ func main() { Action: func(context *cli.Context) error { conf := photoprism.NewConfig(context) - conf.CreateDirectories() + if err := conf.CreateDirectories(); err != nil { + log.Fatal(err) + } conf.MigrateDb() @@ -160,7 +171,9 @@ func main() { Action: func(context *cli.Context) error { conf := photoprism.NewConfig(context) - conf.CreateDirectories() + if err := conf.CreateDirectories(); err != nil { + log.Fatal(err) + } fmt.Printf("Converting RAW images in %s to JPEG...\n", conf.OriginalsPath) @@ -193,7 +206,9 @@ func main() { Action: func(context *cli.Context) error { conf := photoprism.NewConfig(context) - conf.CreateDirectories() + if err := conf.CreateDirectories(); err != nil { + log.Fatal(err) + } fmt.Printf("Creating thumbnails in %s...\n", conf.ThumbnailsPath) @@ -242,7 +257,9 @@ func main() { Action: func(context *cli.Context) error { conf := photoprism.NewConfig(context) - conf.CreateDirectories() + if err := conf.CreateDirectories(); err != nil { + log.Fatal(err) + } before := context.String("before") after := context.String("after") diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 4e96e7c0c..04a7f628a 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,12 +1,22 @@ version: '3.3' +# Example docker-compose config file for production use +# Usage: docker-compose -f docker-compose.prod.yml up + services: photoprism: - image: photoprism/photoprism + image: photoprism/photoprism # Uses pre-built image from docker hub: https://hub.docker.com/r/photoprism/photoprism/ ports: - 80:80 volumes: - - photoprism-photos:/var/photoprism/photos + - ~/Photos:/var/photoprism/photos # Change ~/Photos to whatever directory you want to use on your local computer + - photoprism-thumbnails:/var/photoprism/thumbnails + environment: + PHOTOPRISM_ASSETS_PATH: /var/photoprism + PHOTOPRISM_THUMBNAILS_PATH: /var/photoprism/thumbnails + PHOTOPRISM_IMPORT_PATH: /var/photoprism/photos/Import # ~/Photos/Import on your local computer + PHOTOPRISM_EXPORT_PATH: /var/photoprism/photos/Export # ~/Photos/Export on your local computer + PHOTOPRISM_ORIGINALS_PATH: /var/photoprism/photos/Originals # ~/Photos/Originals on your local computer database: image: mysql:latest @@ -20,7 +30,7 @@ services: MYSQL_DATABASE: photoprism volumes: - photoprism-photos: + photoprism-thumbnails: driver: local photoprism-database: driver: local \ No newline at end of file diff --git a/internal/photoprism/config.go b/internal/photoprism/config.go index 128fb38ed..589d9954f 100644 --- a/internal/photoprism/config.go +++ b/internal/photoprism/config.go @@ -142,11 +142,24 @@ func (c *Config) SetValuesFromCliContext(context *cli.Context) error { return nil } -func (c *Config) CreateDirectories() { - os.MkdirAll(path.Dir(c.OriginalsPath), os.ModePerm) - os.MkdirAll(path.Dir(c.ThumbnailsPath), os.ModePerm) - os.MkdirAll(path.Dir(c.ImportPath), os.ModePerm) - os.MkdirAll(path.Dir(c.ExportPath), os.ModePerm) +func (c *Config) CreateDirectories() error { + if err := os.MkdirAll(path.Dir(c.OriginalsPath), os.ModePerm); err != nil { + return err + } + + if err := os.MkdirAll(path.Dir(c.ThumbnailsPath), os.ModePerm); err != nil { + return err + } + + if err := os.MkdirAll(path.Dir(c.ImportPath), os.ModePerm); err != nil { + return err + } + + if err := os.MkdirAll(path.Dir(c.ExportPath), os.ModePerm); err != nil { + return err + } + + return nil } func (c *Config) ConnectToDatabase() error {