Add some tool for docker
This commit is contained in:
8
.dockerignore
Normal file
8
.dockerignore
Normal file
@ -0,0 +1,8 @@
|
||||
staging.bat
|
||||
staging.sh
|
||||
uploads
|
||||
.idea
|
||||
.env
|
||||
tmp
|
||||
log
|
||||
/public/output.css
|
4
.env
4
.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
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
||||
/uploads
|
||||
/public/output.css
|
||||
/log
|
||||
/.idea
|
||||
|
||||
*_templ.txt
|
||||
*_templ.go
|
27
Dockerfile
Normal file
27
Dockerfile
Normal file
@ -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"]
|
@ -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)
|
||||
|
Reference in New Issue
Block a user