1
0
Forka 0

Simple microservice

master
Ambrose Chua 2018-01-11 17:13:31 +08:00
parent 7064fb8823
commit 2dee4c3b6d
Firmato da: ambrose
ID Chiave GPG: B34FBE029276BA5D
6 ha cambiato i file con 65 aggiunte e 0 eliminazioni

7
.drone.yml Normal file
Vedi 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 esterno Normal file
Vedi File

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

16
Dockerfile Normal file
Vedi 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
Vedi 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.

Vedi File

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

18
text-server.go Normal file
Vedi 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)
}