diff --git a/.vscode/launch.json b/.vscode/launch.json index 8c6ce98a..c621b0a3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -23,7 +23,7 @@ "HBOX_LOG_LEVEL": "debug", "HBOX_DEBUG_ENABLED": "true", "HBOX_STORAGE_DATA": "${workspaceRoot}/backend/.data", - "HBOX_STORAGE_SQLITE_URL": "${workspaceRoot}/backend/.data/homebox.db?_fk=1" + "HBOX_STORAGE_SQLITE_URL": "${workspaceRoot}/backend/.data/homebox.db?_fk=1&_time_format=sqlite" }, "console": "integratedTerminal", }, diff --git a/Dockerfile b/Dockerfile index 7bdb046c..c702dd35 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,7 +61,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ FROM --platform=$TARGETPLATFORM alpine:latest ENV HBOX_MODE=production ENV HBOX_STORAGE_DATA=/data/ -ENV HBOX_STORAGE_SQLITE_URL=/data/homebox.db?_pragma=busy_timeout=2000&_pragma=journal_mode=WAL&_fk=1 +ENV HBOX_STORAGE_SQLITE_URL=/data/homebox.db?_pragma=busy_timeout=2000&_pragma=journal_mode=WAL&_fk=1&_time_format=sqlite # Install necessary runtime dependencies RUN apk --no-cache add ca-certificates wget diff --git a/Dockerfile.rootless b/Dockerfile.rootless index 91ac930e..59307a5d 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -43,7 +43,7 @@ FROM gcr.io/distroless/static:latest ENV HBOX_MODE=production ENV HBOX_STORAGE_DATA=/data/ -ENV HBOX_STORAGE_SQLITE_URL=/data/homebox.db?_fk=1 +ENV HBOX_STORAGE_SQLITE_URL=/data/homebox.db?_fk=1&_time_format=sqlite # Copy the binary and data directory, change ownership COPY --from=builder --chown=nonroot /go/bin/api /app diff --git a/Taskfile.yml b/Taskfile.yml index 7f8abbe6..23fd6a03 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -2,7 +2,7 @@ version: "3" env: HBOX_LOG_LEVEL: debug - HBOX_STORAGE_SQLITE_URL: .data/homebox.db?_pragma=busy_timeout=1000&_pragma=journal_mode=WAL&_fk=1 + HBOX_STORAGE_SQLITE_URL: .data/homebox.db?_pragma=busy_timeout=1000&_pragma=journal_mode=WAL&_fk=1&_time_format=sqlite HBOX_OPTIONS_ALLOW_REGISTRATION: true UNSAFE_DISABLE_PASSWORD_PROJECTION: "yes_i_am_sure" tasks: diff --git a/backend/app/tools/migrations/main.go b/backend/app/tools/migrations/main.go index f0bd2c6d..44818b3a 100644 --- a/backend/app/tools/migrations/main.go +++ b/backend/app/tools/migrations/main.go @@ -36,7 +36,7 @@ func main() { } // Generate migrations using Atlas support for MySQL (note the Ent dialect option passed above). - err = migrate.NamedDiff(ctx, "sqlite://.data/homebox.migration.db?_fk=1", os.Args[1], opts...) + err = migrate.NamedDiff(ctx, "sqlite://.data/homebox.migration.db?_fk=1&_time_format=sqlite", os.Args[1], opts...) if err != nil { log.Fatalf("failed generating migration file: %v", err) } diff --git a/backend/internal/core/services/main_test.go b/backend/internal/core/services/main_test.go index f2e35bb4..96b0b935 100644 --- a/backend/internal/core/services/main_test.go +++ b/backend/internal/core/services/main_test.go @@ -50,7 +50,7 @@ func bootstrap() { } func MainNoExit(m *testing.M) int { - client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1&_time_format=sqlite") if err != nil { log.Fatalf("failed opening connection to sqlite: %v", err) } diff --git a/backend/internal/data/repo/main_test.go b/backend/internal/data/repo/main_test.go index a633d63c..04221120 100644 --- a/backend/internal/data/repo/main_test.go +++ b/backend/internal/data/repo/main_test.go @@ -40,7 +40,7 @@ func bootstrap() { } func MainNoExit(m *testing.M) int { - client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1&_time_format=sqlite") if err != nil { log.Fatalf("failed opening connection to sqlite: %v", err) } diff --git a/backend/internal/sys/config/conf_database.go b/backend/internal/sys/config/conf_database.go index 2c6a7610..b6d1fbed 100644 --- a/backend/internal/sys/config/conf_database.go +++ b/backend/internal/sys/config/conf_database.go @@ -7,5 +7,5 @@ const ( type Storage struct { // Data is the path to the root directory Data string `yaml:"data" conf:"default:./.data"` - SqliteURL string `yaml:"sqlite-url" conf:"default:./.data/homebox.db?_pragma=busy_timeout=999&_pragma=journal_mode=WAL&_fk=1"` + SqliteURL string `yaml:"sqlite-url" conf:"default:./.data/homebox.db?_pragma=busy_timeout=999&_pragma=journal_mode=WAL&_fk=1&_time_format=sqlite"` } diff --git a/docs/en/configure-homebox.md b/docs/en/configure-homebox.md index 16a395e9..c2d2db69 100644 --- a/docs/en/configure-homebox.md +++ b/docs/en/configure-homebox.md @@ -2,29 +2,30 @@ ## Env Variables & Configuration -| Variable | Default | Description | -| ------------------------------------ | ---------------------- | ---------------------------------------------------------------------------------- | -| HBOX_MODE | `production` | application mode used for runtime behavior can be one of: `development`, `production` | -| HBOX_WEB_PORT | 7745 | port to run the web server on, if you're using docker do not change this | -| HBOX_WEB_HOST | | host to run the web server on, if you're using docker do not change this | -| HBOX_OPTIONS_ALLOW_REGISTRATION | true | allow users to register themselves | -| HBOX_OPTIONS_AUTO_INCREMENT_ASSET_ID | true | auto-increments the asset_id field for new items | -| HBOX_OPTIONS_CURRENCY_CONFIG | | json configuration file containing additional currencie | -| HBOX_WEB_MAX_FILE_UPLOAD | 10 | maximum file upload size supported in MB | -| HBOX_WEB_READ_TIMEOUT | 10s | Read timeout of HTTP sever | -| HBOX_WEB_WRITE_TIMEOUT | 10s | Write timeout of HTTP server | -| HBOX_WEB_IDLE_TIMEOUT | 30s | Idle timeout of HTTP server | -| HBOX_STORAGE_DATA | /data/ | path to the data directory, do not change this if you're using docker | -| HBOX_STORAGE_SQLITE_URL | /data/homebox.db?_fk=1 | sqlite database url, if you're using docker do not change this | -| HBOX_LOG_LEVEL | `info` | log level to use, can be one of `trace`, `debug`, `info`, `warn`, `error`, `critical` | -| HBOX_LOG_FORMAT | `text` | log format to use, can be one of: `text`, `json` | -| HBOX_MAILER_HOST | | email host to use, if not set no email provider will be used | -| HBOX_MAILER_PORT | 587 | email port to use | -| HBOX_MAILER_USERNAME | | email user to use | -| HBOX_MAILER_PASSWORD | | email password to use | -| HBOX_MAILER_FROM | | email from address to use | -| HBOX_SWAGGER_HOST | 7745 | swagger host to use, if not set swagger will be disabled | -| HBOX_SWAGGER_SCHEMA | `http` | swagger schema to use, can be one of: `http`, `https` | +| Variable | Default | Description | +|--------------------------------------|--------------------------------------------|----------------------------------------------------------------------------------------| +| HBOX_MODE | `production` | application mode used for runtime behavior can be one of: `development`, `production` | +| HBOX_WEB_PORT | 7745 | port to run the web server on, if you're using docker do not change this | +| HBOX_WEB_HOST | | host to run the web server on, if you're using docker do not change this | +| HBOX_OPTIONS_ALLOW_REGISTRATION | true | allow users to register themselves | +| HBOX_OPTIONS_AUTO_INCREMENT_ASSET_ID | true | auto-increments the asset_id field for new items | +| HBOX_OPTIONS_CURRENCY_CONFIG | | json configuration file containing additional currencie | +| HBOX_WEB_MAX_FILE_UPLOAD | 10 | maximum file upload size supported in MB | +| HBOX_WEB_READ_TIMEOUT | 10s | Read timeout of HTTP sever | +| HBOX_WEB_WRITE_TIMEOUT | 10s | Write timeout of HTTP server | +| HBOX_WEB_IDLE_TIMEOUT | 30s | Idle timeout of HTTP server | +| HBOX_STORAGE_DATA | /data/ | path to the data directory, do not change this if you're using docker | +| HBOX_STORAGE_SQLITE_URL | /data/homebox.db?_fk=1&_time_format=sqlite | sqlite database url, if you're using docker do not change this | +| HBOX_LOG_LEVEL | `info` | log level to use, can be one of `trace`, `debug`, `info`, `warn`, `error`, `critical` | +| HBOX_LOG_FORMAT | `text` | log format to use, can be one of: `text`, `json` | +| HBOX_MAILER_HOST | | email host to use, if not set no email provider will be used | +| HBOX_MAILER_PORT | 587 | email port to use | +| HBOX_MAILER_USERNAME | | email user to use | +| HBOX_MAILER_PASSWORD | | email password to use | +| HBOX_MAILER_FROM | | email from address to use | +| HBOX_SWAGGER_HOST | 7745 | swagger host to use, if not set swagger will be disabled | +| HBOX_SWAGGER_SCHEMA | `http` | swagger schema to use, can be one of: `http`, `https` | + ::: tip "CLI Arguments" If you're deploying without docker you can use command line arguments to configure the application. Run `homebox --help` for more information. @@ -38,7 +39,7 @@ OPTIONS --web-host/$HBOX_WEB_HOST --web-max-file-upload/$HBOX_WEB_MAX_FILE_UPLOAD (default: 10) --storage-data/$HBOX_STORAGE_DATA (default: ./.data) ---storage-sqlite-url/$HBOX_STORAGE_SQLITE_URL (default: ./.data/homebox.db?_fk=1) +--storage-sqlite-url/$HBOX_STORAGE_SQLITE_URL (default: ./.data/homebox.db?_fk=1&_time_format=sqlite) --log-level/$HBOX_LOG_LEVEL (default: info) --log-format/$HBOX_LOG_FORMAT (default: text) --mailer-host/$HBOX_MAILER_HOST