diff --git a/.gitignore b/.gitignore index f4d432a..b934526 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ # Dependency directories (remove the comment below to include it) # vendor/ +hello \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c3626c5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM golang:1.18 as builder + +ENV GO111MODULE=on \ + GOPROXY=https://goproxy.io + +COPY . /app +WORKDIR /app + +RUN go get && go build -ldflags="-s -w" -installsuffix cgo -o hello + +FROM alpine:latest + +ENV TZ=Asia/Shanghai \ + LANG=C.UTF-8 \ + APP_DIR=/app + +COPY --from=builder /app/hello ${APP_DIR}/hello + +WORKDIR ${APP_DIR} + +RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime \ + && echo ${TZ} > /etc/timezone \ + && chmod +x hello + +# EXPOSE 5678 + +CMD ["./hello"] \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..4a2c9ba --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module myschools.me/suguo/hello + +go 1.20 diff --git a/main.go b/main.go new file mode 100644 index 0000000..a120def --- /dev/null +++ b/main.go @@ -0,0 +1,13 @@ +package main + +import ( + "fmt" + "time" +) + +func main() { + for { + fmt.Println(time.Now().Format("2006-01-02 15:04:05"), "hello world.") + time.Sleep(time.Minute) + } +}