chibisafe_netstorage_middleman : restore Dockerfile

This commit is contained in:
minoplhy 2024-04-10 01:00:48 +07:00
parent 898e621610
commit fab89c56e5
Signed by: minoplhy
GPG Key ID: 41D406044E2434BF
2 changed files with 12 additions and 5 deletions

11
Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM golang:latest
WORKDIR /app
COPY . .
RUN go mod download
EXPOSE 4040
CMD ["go", "run", "main.go"]

View File

@ -92,19 +92,15 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
func main() { func main() {
Chibisafe_basepath := os.Getenv("CHIBISAFE_BASEPATH") Chibisafe_basepath := os.Getenv("CHIBISAFE_BASEPATH")
Host := os.Getenv("HOST")
if Chibisafe_basepath == "" { if Chibisafe_basepath == "" {
log.Fatal("CHIBISAFE_BASEPATH environment is not set!") log.Fatal("CHIBISAFE_BASEPATH environment is not set!")
} }
if Host == "" {
Host = "127.0.0.1:4000"
}
mux := http.NewServeMux() mux := http.NewServeMux()
mux.HandleFunc("/api/v1/upload", uploadHandler) mux.HandleFunc("/api/v1/upload", uploadHandler)
if err := http.ListenAndServe(Host, mux); err != nil { if err := http.ListenAndServe(":4040", mux); err != nil {
log.Fatal(err) log.Fatal(err)
} }
} }