diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cacf31c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +staging.bat +staging.sh +uploads +.idea +.env +tmp +log +/public/output.css \ No newline at end of file diff --git a/.env b/.env index 4441a74..c44cab9 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -SERVER_HOST=localhost +SERVER_HOST=0.0.0.0 SERVER_PORT=8000 DOMAIN=filekeeper.fossy.my.id @@ -7,7 +7,7 @@ CORS_PROTO=https CORS_LIST=filekeeper.fossy.my.id:443,fossy.my.id:443 CORS_METHODS=POST,GET -DB_HOST=127.0.0.1 +DB_HOST=192.168.1.5 DB_PORT=3306 DB_USERNAME=root DB_PASSWORD=test123 diff --git a/.gitignore b/.gitignore index c613e59..dfe0a32 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /uploads /public/output.css /log +/.idea *_templ.txt *_templ.go \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bf20708 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM node:current-alpine3.19 AS tailwind + +WORKDIR /src +COPY ./public/input.css ./public/ +COPY tailwind.config.js . +COPY ./view ./view + +RUN npm install -g tailwindcss +RUN npx tailwindcss -i ./public/input.css -o ./public/output.css + +FROM golang:1.22.2-alpine3.19 AS go_builder + +WORKDIR /src +COPY . . +COPY --from=tailwind /src/public/output.css ./public/ + +RUN go install github.com/a-h/templ/cmd/templ@$(go list -m -f '{{ .Version }}' github.com/a-h/templ) +RUN templ generate +RUN go build -o ./tmp/main + +FROM scratch + +WORKDIR /src + +COPY --from=go_builder /src /src + +ENTRYPOINT ["./tmp/main"] diff --git a/utils/utils.go b/utils/utils.go index dd2ad9d..90213ae 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -109,9 +109,11 @@ func Getenv(key string) string { return val } - err := godotenv.Load(".env") - if err != nil { - log.Error("Error loading .env file: %s", err) + if os.Getenv("HOSTNAME") == "" { + err := godotenv.Load(".env") + if err != nil { + log.Error("Error loading .env file: %s", err) + } } val := os.Getenv(key)