Browse Source

Simple microservice

tags/1.0.0
Ambrose Chua 2 years ago
parent
commit
2dee4c3b6d
Signed by: ambrose <ambrose@chua.family> GPG Key ID: B34FBE029276BA5D
6 changed files with 65 additions and 0 deletions
  1. +7
    -0
      .drone.yml
  2. +1
    -0
      .gitignore
  3. +16
    -0
      Dockerfile
  4. +21
    -0
      LICENSE
  5. +2
    -0
      README.md
  6. +18
    -0
      text-server.go

+ 7
- 0
.drone.yml View 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
- 0
.gitignore View File

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

+ 16
- 0
Dockerfile View 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
- 0
LICENSE View 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.

+ 2
- 0
README.md View File

@@ -1,2 +1,4 @@

# text-server

I'm a tiny Daniel.

+ 18
- 0
text-server.go View 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)
}

Loading…
Cancel
Save