inject mongodb uri inside the binary and os
This commit is contained in:
12
Makefile
12
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user