From ddb93077045ccf30002b26428cb9b38cab3076f0 Mon Sep 17 00:00:00 2001 From: I_AM_TINE Date: Wed, 25 Jan 2023 11:07:32 +0700 Subject: [PATCH] INIT --- .gitattributes | 2 ++ Dockerfile | 19 +++++++++++++++++++ README.md | 2 ++ go.mod | 3 +++ go.sum | 0 main.go | 18 ++++++++++++++++++ static/index.html | 12 ++++++++++++ 7 files changed, 56 insertions(+) create mode 100644 .gitattributes create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 go.mod create mode 100644 go.sum create mode 100644 main.go create mode 100644 static/index.html diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bc1f989 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM golang:alpine as builder + +WORKDIR /app + +COPY . . + +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build + +FROM alpine + +WORKDIR /app + +COPY ./static ./static + +COPY --from=builder /app/serviceapifrontend . + +EXPOSE 4000 + +ENTRYPOINT [ "/app/serviceapifrontend" ] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..f4cacea --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# server + diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..31bc9f1 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/ThisTine/simple-http-server + +go 1.17 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e69de29 diff --git a/main.go b/main.go new file mode 100644 index 0000000..f69ce27 --- /dev/null +++ b/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "log" + "net/http" +) + +func main() { + fs := http.FileServer(http.Dir("./static")) + http.Handle("/", fs) + fmt.Print("Listening on 4000") + err := http.ListenAndServe(":4000", nil) + if err != nil { + log.Fatal(err) + } + +} diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..88dafdf --- /dev/null +++ b/static/index.html @@ -0,0 +1,12 @@ + + + + + + + Default + + +

Default page

+ + \ No newline at end of file