Begin dockerfile and create 404.html if not exists
This commit is contained in:
parent
404224a155
commit
a54a54df3c
3 changed files with 19 additions and 1 deletions
11
dev/docker/images/production/Dockerfile
Normal file
11
dev/docker/images/production/Dockerfile
Normal file
|
@ -0,0 +1,11 @@
|
|||
FROM golang:alpine3.17 AS build
|
||||
WORKDIR /build
|
||||
COPY ./src ./src
|
||||
WORKDIR /build/src
|
||||
RUN ls
|
||||
RUN go get .
|
||||
RUN go build -o /build/static-hoster
|
||||
|
||||
FROM alpine:3.17 AS final
|
||||
COPY --from=build /build/static-hoster /bin/static-hoster
|
||||
CMD static-hoster
|
|
@ -28,7 +28,7 @@ func Load() (env *Environment) {
|
|||
defaultApiKey := "test123"
|
||||
env = new(Environment)
|
||||
env.RootDir = envReader("STATIC_HOSTER_HOME", fmt.Sprintf("%s/static-hoster/", os.Getenv("HOME")))
|
||||
env.StaticDir = envReader("STATIC_HOSTER_HOST_DIR", fmt.Sprintf("%s/hosted/", env.RootDir))
|
||||
env.StaticDir = envReader("STATIC_HOSTER_HOST_DIR", fmt.Sprintf("%shosted/", env.RootDir))
|
||||
env.Port = fmt.Sprintf(":%s", envReader("STATIC_HOSTER_PORT", "8080"))
|
||||
env.ApiKey = envReader("STATIC_HOSTER_API_KEY", defaultApiKey)
|
||||
env.BaseRoute = envReader("STATIC_HOSTER_BASE_ROUTE", "/home")
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"nikurasu.gay/static-hoster/envloader"
|
||||
"nikurasu.gay/static-hoster/router"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var env = envloader.Load()
|
||||
if _, err := os.Stat(fmt.Sprintf("%s404.html", env.StaticDir)); errors.Is(err, os.ErrNotExist) {
|
||||
os.Create(fmt.Sprintf("%s404.html", env.StaticDir))
|
||||
}
|
||||
r := router.Create(env)
|
||||
r.Run(env.Port)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue