1
0
Fork 0

Simple microservice

master
Ambrose Chua 2018-01-11 17:13:31 +08:00
父節點 7064fb8823
當前提交 2dee4c3b6d
簽署人: ambrose
GPG 金鑰 ID: B34FBE029276BA5D
共有 6 個檔案被更改,包括 65 行新增0 行删除

7
.drone.yml Normal file
查看文件

@ -0,0 +1,7 @@
pipeline:
docker:
image: plugins/docker
registry: registry.labs.0x.no
repo: registry.labs.0x.no/text-server
tags:
- latest

1
.gitignore vendored Normal file
查看文件

@ -0,0 +1 @@
text-server

16
Dockerfile Normal file
查看文件

@ -0,0 +1,16 @@
FROM golang:1.9-alpine as go
WORKDIR /go/src/text-server
COPY . .
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
RUN go build -ldflags '-extldflags "-static"' -o text-server
FROM scratch
EXPOSE 8080
COPY --from=go /go/src/text-server/text-server text-server
ENTRYPOINT ["/text-server"]

21
LICENSE Normal file
查看文件

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Ambrose Chua
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

查看文件

@ -1,2 +1,4 @@
# text-server
I'm a tiny Daniel.

18
text-server.go Normal file
查看文件

@ -0,0 +1,18 @@
package main
import (
"fmt"
"net/http"
"os"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "text/html; charset=utf-8")
fmt.Fprintf(w, "%s", os.Getenv("TEXT"))
}
func main() {
fmt.Println("Listening on port 8080...")
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}