mirror of
https://github.com/JuLi0n21/pwa-player.git
synced 2026-04-19 15:30:05 +00:00
updating dockerfiles and minor things
This commit is contained in:
@@ -7,13 +7,13 @@ RUN go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o main .
|
||||
|
||||
FROM gcr.io/distroless/base-debian11
|
||||
RUN CGO_ENABLED=1 GOOS=linux go build -o main .
|
||||
|
||||
FROM ubuntu:latest
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/main .
|
||||
COPY --from=builder /app/dev.env .
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ const (
|
||||
|
||||
func InitDB() {
|
||||
var err error
|
||||
db, err = sql.Open("sqlite3", "database.db")
|
||||
db, err = sql.Open("sqlite3", "data/database.db")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -2,16 +2,24 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
if ok := godotenv.Load("dev.env"); ok != nil {
|
||||
panic(".env not found")
|
||||
}
|
||||
if value := os.Getenv("ENV"); value == "prod" {
|
||||
if ok := godotenv.Load(".env"); ok != nil {
|
||||
panic(".env not found")
|
||||
}
|
||||
} else {
|
||||
fmt.Println("Not Produktion Enviorment fallback to dev.env")
|
||||
if ok := godotenv.Load("dev.env"); ok != nil {
|
||||
panic("dev.env not found")
|
||||
}
|
||||
|
||||
}
|
||||
InitDB()
|
||||
|
||||
err := run()
|
||||
|
||||
Reference in New Issue
Block a user