diff --git a/Makefile b/Makefile index a864b41..8ebd04b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,13 @@ SHELL := /bin/bash +ifneq (,$(wildcard .env)) + include .env + export +endif + +LDFLAGS := \ + -X 'main.DB_URI=$(DB_URI)' + tidy: go mod tidy @@ -16,7 +24,7 @@ clean: @rm -f ./build/pm_bash.sh build: tidy - @go build -o ./bin/pm ./cmd/pm + @go build -ldflags "$(LDFLAGS)" -o ./bin/pm ./cmd/pm @go build -o ./bin/tui ./cmd/tui @go build -o ./bin/web ./cmd/web @echo "Build completed successfully. Binaries are located in the ./bin directory." @@ -36,7 +44,7 @@ docker-run: docker-push: @docker push telikz/lazypm:latest -os-build: build completions +os-build: completions build @cp ./bin/pm ./build/pm @cp ./bin/pm_bash.sh ./build/pm_bash.sh @docker build -t telikz/lazyos ./build diff --git a/build/Dockerfile b/build/Dockerfile index 795657e..8cfc7fa 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,6 +1,14 @@ FROM lscr.io/linuxserver/webtop:latest -RUN apk add --no-cache exo gcompat libc6-compat bash bash-completion alacritty +RUN apk add --no-cache \ + ca-certificates \ + exo \ + gcompat \ + libc6-compat \ + bash \ + bash-completion \ + alacritty && \ + update-ca-certificates COPY pm /usr/local/bin/pm COPY pm_bash.sh /etc/bash_completion.d/pm diff --git a/cmd/pm/init.go b/cmd/pm/init.go index bf637bb..dd456c8 100644 --- a/cmd/pm/init.go +++ b/cmd/pm/init.go @@ -22,6 +22,10 @@ func init() { models.BaseConfig = models.BaseConfig.LoadFromEnv() + if DB_URI != "" { + models.BaseConfig = models.BaseConfig.WithDbUri(DB_URI) + } + task.RegisterInterface("tui", tui.New()) task.RegisterInterface("web", web.New()) task.RegisterInterface("repl", repl.New()) diff --git a/cmd/pm/main.go b/cmd/pm/main.go index 4b74d3a..d6bd53c 100644 --- a/cmd/pm/main.go +++ b/cmd/pm/main.go @@ -11,6 +11,7 @@ import ( var App *app.App var appCleanup func() var RootCmd = issues.RootCmd +var DB_URI string func main() { ctx := context.Background() diff --git a/internal/commands/survey/submit.go b/internal/commands/survey/submit.go index bcdd77a..74d5b1b 100644 --- a/internal/commands/survey/submit.go +++ b/internal/commands/survey/submit.go @@ -22,6 +22,10 @@ var SubmitCmd = &cobra.Command{ return nil } + if !cmd.Flags().Changed("dev") { + fmt.Println("DBUri", app.Config.DbUri) + } + db, err := storage.NewMongoStorageInteractive(cmd.Context(), app.Config.DbUri) if err != nil { return fmt.Errorf("failed to connect to database: %w", err) @@ -37,3 +41,7 @@ var SubmitCmd = &cobra.Command{ return nil }, } + +func init() { + SubmitCmd.Flags().Bool("dev", false, "Show DB connection details for development purposes") +}