try new tagging. Add ip of host to image

This commit is contained in:
Steven Polley 2018-08-01 22:20:54 -06:00
parent dd35038204
commit 51a36bd5b4
2 changed files with 22 additions and 5 deletions

View File

@ -14,8 +14,7 @@ pipeline:
- go build - go build
publish: publish:
image: plugins/docker image: plugins/docker
custom_dns: [ 8.8.8.8, 8.8.4.4 ]
repo: deadbeef.codes:5000/mandelmap repo: deadbeef.codes:5000/mandelmap
registry: deadbeef.codes:5000 registry: deadbeef.codes:5000
# auto_tag: true auto_tag: true
# auto_tag_suffix: linux-rpi3 auto_tag_suffix: ${DRONE_COMMIT}

View File

@ -8,6 +8,7 @@ import (
"log" "log"
"math" "math"
"math/cmplx" "math/cmplx"
"net"
"net/http" "net/http"
"runtime" "runtime"
"strconv" "strconv"
@ -15,6 +16,9 @@ import (
"sync" "sync"
"deadbeef.codes/steven/mandelmapper/palette" "deadbeef.codes/steven/mandelmapper/palette"
"golang.org/x/image/font"
"golang.org/x/image/font/basicfont"
"golang.org/x/image/math/fixed"
) )
const ( const (
@ -116,6 +120,9 @@ func renderTile(w http.ResponseWriter, r *http.Request) {
wg.Wait() wg.Wait()
ip := GetOutboundIP()
addLabel(img, 20, 30, fmt.Sprintf("%s", string(ip)))
//addLabel(img, 20, 30, fmt.Sprintf("%s/%s/%s.png", components[1], components[2], components[3])) //addLabel(img, 20, 30, fmt.Sprintf("%s/%s/%s.png", components[1], components[2], components[3]))
w.Header().Set("Content-Type", "image/png") w.Header().Set("Content-Type", "image/png")
png.Encode(w, img) png.Encode(w, img)
@ -195,7 +202,7 @@ func linearInterpolation(c1, c2, mu uint32) uint32 {
} }
//Adds a text label to an image //Adds a text label to an image
/*
func addLabel(img *image.RGBA, x, y int, label string) { func addLabel(img *image.RGBA, x, y int, label string) {
col := color.RGBA{255, 255, 255, 255} col := color.RGBA{255, 255, 255, 255}
point := fixed.Point26_6{fixed.Int26_6(x * 64), fixed.Int26_6(y * 64)} point := fixed.Point26_6{fixed.Int26_6(x * 64), fixed.Int26_6(y * 64)}
@ -208,4 +215,15 @@ func addLabel(img *image.RGBA, x, y int, label string) {
} }
d.DrawString(label) d.DrawString(label)
} }
*/
func GetOutboundIP() net.IP {
conn, err := net.Dial("udp", "8.8.8.8:80")
if err != nil {
log.Fatal(err)
}
defer conn.Close()
localAddr := conn.LocalAddr().(*net.UDPAddr)
return localAddr.IP
}