Commit b342307d authored by ale's avatar ale

Initial commit

parents
Pipeline #979 passed with stages
in 53 seconds
image: docker:latest
stages:
- build
- docker_build
- release
services:
- docker:dind
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
RELEASE_TAG: $CI_REGISTRY_IMAGE:latest
GIT_SUBMODULE_STRATEGY: recursive
build:
stage: build
image: "ai/build:stretch"
script:
- env DEBIAN_FRONTEND=noninteractive apt-get -qy install make golang-go
- make
artifacts:
paths:
- build/
docker_build:
stage: docker_build
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.git.autistici.org
- docker build --build-arg ci_token=$CI_JOB_TOKEN --pull -t $IMAGE_TAG .
- docker push $IMAGE_TAG
dependencies:
- build
release:
stage: release
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.git.autistici.org
- docker pull $IMAGE_TAG
- docker tag $IMAGE_TAG $RELEASE_TAG
- docker push $RELEASE_TAG
only:
- master
FROM scratch
ADD build/okserver /
CMD ["/okserver"]
all: build/okserver
build/okserver: okserver.go
-mkdir -p build
go build -o $@ -tags netgo -a -ldflags -w $^
package main
import (
"io"
"log"
"net/http"
"os"
)
func main() {
// Get the address to bind on from the environment.
addr := os.Getenv("ADDR")
if addr == "" {
addr = ":3100"
}
// Create a very simple HTTP server with two endpoints: one
// that just replies "OK", and one that dumps the incoming
// request back to the client.
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/echo":
w.Header().Set("Content-Type", "text/plain")
r.Write(w)
case "/", "/health":
io.WriteString(w, "OK")
default:
http.NotFound(w, r)
}
})
if err := http.ListenAndServe(addr, nil); err != nil && err != http.ErrServerClosed {
log.Fatal(err)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment