From 2a25cc9d0ec7847a453fc39e4a79078ad9bfd650 Mon Sep 17 00:00:00 2001 From: akhilrex Date: Thu, 8 Oct 2020 12:36:43 +0530 Subject: [PATCH] finalizing docker file --- Dockerfile | 26 ++++++++++---------------- db/db.go | 2 ++ main.go | 4 ++-- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 744c353..bae2192 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,29 +16,23 @@ RUN go build -o ./app ./main.go FROM alpine:latest -ENV UID=998 -ENV GID=100 ENV CONFIG=/config ENV DATA=/assets - +ENV UID=998 +ENV PID=100 +VOLUME ["/config", "/assets"] RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/* +RUN mkdir -p /config; \ + mkdir -p /assets; \ + mkdir -p /api + +RUN chmod 777 /config; \ + chmod 777 /assets -RUN mkdir -p /api WORKDIR /api COPY --from=builder /api/app . COPY client ./client -RUN mkdir /config; \ - mkdir /assets - -# RUN addgroup -g ${GID} poduser &&\ -# adduser -l -u ${UID} -g poduser poduser &&\ -RUN chown --changes --silent --no-dereference --recursive \ - ${UID}:${GID} \ - /assets \ - /config - -USER poduser EXPOSE 8080 -VOLUME ["/config", "/assets"] + ENTRYPOINT ["./app"] \ No newline at end of file diff --git a/db/db.go b/db/db.go index a80b600..99c588b 100644 --- a/db/db.go +++ b/db/db.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "path" + "log" "gorm.io/driver/sqlite" @@ -18,6 +19,7 @@ func Init() (*gorm.DB, error) { // github.com/mattn/go-sqlite3 configPath := os.Getenv("CONFIG") dbPath := path.Join(configPath, "podgrab.db") + log.Println(dbPath) db, err := gorm.Open(sqlite.Open(dbPath), &gorm.Config{}) if err != nil { fmt.Println("db err: ", err) diff --git a/main.go b/main.go index 631b34a..075225c 100644 --- a/main.go +++ b/main.go @@ -23,9 +23,9 @@ func main() { db.DB, err = db.Init() if err != nil { fmt.Println("statuse: ", err) + }else{ + db.Migrate() } - db.Migrate() - r := gin.Default() dataPath := os.Getenv("DATA") //r.Static("/assets", "./assets")