finalizing docker file

pull/24/head
akhilrex 4 years ago
parent 566ede9a74
commit 2a25cc9d0e

@ -16,29 +16,23 @@ RUN go build -o ./app ./main.go
FROM alpine:latest FROM alpine:latest
ENV UID=998
ENV GID=100
ENV CONFIG=/config ENV CONFIG=/config
ENV DATA=/assets 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 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 WORKDIR /api
COPY --from=builder /api/app . COPY --from=builder /api/app .
COPY client ./client 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 EXPOSE 8080
VOLUME ["/config", "/assets"]
ENTRYPOINT ["./app"] ENTRYPOINT ["./app"]

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"os" "os"
"path" "path"
"log"
"gorm.io/driver/sqlite" "gorm.io/driver/sqlite"
@ -18,6 +19,7 @@ func Init() (*gorm.DB, error) {
// github.com/mattn/go-sqlite3 // github.com/mattn/go-sqlite3
configPath := os.Getenv("CONFIG") configPath := os.Getenv("CONFIG")
dbPath := path.Join(configPath, "podgrab.db") dbPath := path.Join(configPath, "podgrab.db")
log.Println(dbPath)
db, err := gorm.Open(sqlite.Open(dbPath), &gorm.Config{}) db, err := gorm.Open(sqlite.Open(dbPath), &gorm.Config{})
if err != nil { if err != nil {
fmt.Println("db err: ", err) fmt.Println("db err: ", err)

@ -23,9 +23,9 @@ func main() {
db.DB, err = db.Init() db.DB, err = db.Init()
if err != nil { if err != nil {
fmt.Println("statuse: ", err) fmt.Println("statuse: ", err)
}else{
db.Migrate()
} }
db.Migrate()
r := gin.Default() r := gin.Default()
dataPath := os.Getenv("DATA") dataPath := os.Getenv("DATA")
//r.Static("/assets", "./assets") //r.Static("/assets", "./assets")

Loading…
Cancel
Save