Last active
March 14, 2023 23:40
-
-
Save euank/2d5a7bc74dc56f502c30 to your computer and use it in GitHub Desktop.
Revisions
-
euank revised this gist
Aug 13, 2015 . 1 changed file with 0 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +0,0 @@ -
euank created this gist
Aug 13, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ FROM golang:1.4 COPY entrypoint.sh /entrypoint.sh COPY main.go main.go RUN go build -o main main.go RUN chmod +x /entrypoint.sh EXPOSE 8080 ENTRYPOINT ["/entrypoint.sh"] CMD ["./main"] This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ .PHONY: all clean all: go build -o main ./main.go docker build -t euank/play:2015-08-10 . clean: rm -f main This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ #!/bin/sh export HOST=$(curl --retry 5 --connect-timeout 3 -s 169.254.169.254/latest/meta-data/local-hostname) export LOCAL_IP=$(curl --retry 5 --connect-timeout 3 -s 169.254.169.254/latest/meta-data/local-ipv4) exec "$@" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ package main import ( "encoding/json" "log" "net/http" "os" ) func main() { log.Fatal(http.ListenAndServe(":8080", http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { resp.Header().Set("Content-Type", "application/json") body, err := json.Marshal(map[string]string{"hostname": os.Getenv("HOST"), "localIp": os.Getenv("LOCAL_IP")}) if err != nil { panic(err) } resp.Write(body) }))) } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ { "family": "test-hostenv-entrypoint", "containerDefinitions": [{ "name": "test", "image": "euank/play:2015-08-10", "memory": 50, "portMappings": [{ "containerPort": 8080, "hostPort": 8080 }] }] }