inject mongodb uri inside the binary and os
This commit is contained in:
12
Makefile
12
Makefile
@@ -1,5 +1,13 @@
|
|||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
|
|
||||||
|
ifneq (,$(wildcard .env))
|
||||||
|
include .env
|
||||||
|
export
|
||||||
|
endif
|
||||||
|
|
||||||
|
LDFLAGS := \
|
||||||
|
-X 'main.DB_URI=$(DB_URI)'
|
||||||
|
|
||||||
tidy:
|
tidy:
|
||||||
go mod tidy
|
go mod tidy
|
||||||
|
|
||||||
@@ -16,7 +24,7 @@ clean:
|
|||||||
@rm -f ./build/pm_bash.sh
|
@rm -f ./build/pm_bash.sh
|
||||||
|
|
||||||
build: tidy
|
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/tui ./cmd/tui
|
||||||
@go build -o ./bin/web ./cmd/web
|
@go build -o ./bin/web ./cmd/web
|
||||||
@echo "Build completed successfully. Binaries are located in the ./bin directory."
|
@echo "Build completed successfully. Binaries are located in the ./bin directory."
|
||||||
@@ -36,7 +44,7 @@ docker-run:
|
|||||||
docker-push:
|
docker-push:
|
||||||
@docker push telikz/lazypm:latest
|
@docker push telikz/lazypm:latest
|
||||||
|
|
||||||
os-build: build completions
|
os-build: completions build
|
||||||
@cp ./bin/pm ./build/pm
|
@cp ./bin/pm ./build/pm
|
||||||
@cp ./bin/pm_bash.sh ./build/pm_bash.sh
|
@cp ./bin/pm_bash.sh ./build/pm_bash.sh
|
||||||
@docker build -t telikz/lazyos ./build
|
@docker build -t telikz/lazyos ./build
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
FROM lscr.io/linuxserver/webtop:latest
|
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 /usr/local/bin/pm
|
||||||
COPY pm_bash.sh /etc/bash_completion.d/pm
|
COPY pm_bash.sh /etc/bash_completion.d/pm
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ func init() {
|
|||||||
|
|
||||||
models.BaseConfig = models.BaseConfig.LoadFromEnv()
|
models.BaseConfig = models.BaseConfig.LoadFromEnv()
|
||||||
|
|
||||||
|
if DB_URI != "" {
|
||||||
|
models.BaseConfig = models.BaseConfig.WithDbUri(DB_URI)
|
||||||
|
}
|
||||||
|
|
||||||
task.RegisterInterface("tui", tui.New())
|
task.RegisterInterface("tui", tui.New())
|
||||||
task.RegisterInterface("web", web.New())
|
task.RegisterInterface("web", web.New())
|
||||||
task.RegisterInterface("repl", repl.New())
|
task.RegisterInterface("repl", repl.New())
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
var App *app.App
|
var App *app.App
|
||||||
var appCleanup func()
|
var appCleanup func()
|
||||||
var RootCmd = issues.RootCmd
|
var RootCmd = issues.RootCmd
|
||||||
|
var DB_URI string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ var SubmitCmd = &cobra.Command{
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !cmd.Flags().Changed("dev") {
|
||||||
|
fmt.Println("DBUri", app.Config.DbUri)
|
||||||
|
}
|
||||||
|
|
||||||
db, err := storage.NewMongoStorageInteractive(cmd.Context(), app.Config.DbUri)
|
db, err := storage.NewMongoStorageInteractive(cmd.Context(), app.Config.DbUri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to connect to database: %w", err)
|
return fmt.Errorf("failed to connect to database: %w", err)
|
||||||
@@ -37,3 +41,7 @@ var SubmitCmd = &cobra.Command{
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
SubmitCmd.Flags().Bool("dev", false, "Show DB connection details for development purposes")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user