Browse Source

docker fu

sungo 8 months ago
parent
commit
efc4e4fbc6
2 changed files with 60 additions and 0 deletions
  1. 26 0
      Dockerfile
  2. 34 0
      runner.sh

+ 26 - 0
Dockerfile

@@ -0,0 +1,26 @@
+FROM golang:1.11.1-alpine AS build
+ENV CGO_ENABLED 0
+
+RUN apk add --no-cache --update make git perl-utils dep
+RUN apk add --no-cache ca-certificates
+
+ENV PATH "/go/bin:${PATH}"
+
+RUN ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
+
+RUN go get -u github.com/alecthomas/gometalinter && gometalinter --install
+
+ARG CACHE_BUSTER="wat"
+RUN mkdir -p /go/src/git.sungo.wtf/sungo/sbs-http
+
+COPY . /go/src/git.sungo.wtf/sungo/sbs-http
+WORKDIR /go/src/git.sungo.wtf/sungo/sbs-http
+
+RUN make
+
+FROM alpine
+
+COPY --from=build /go/src/git.sungo.wtf/sungo/sbs-http/runner.sh /bin/sbshttp.sh
+COPY --from=build /go/src/git.sungo.wtf/sungo/sbs-http/sbshttp /bin/sbshttp
+
+CMD [ "/bin/sbshttp.sh" ]

+ 34 - 0
runner.sh

@@ -0,0 +1,34 @@
+#!/bin/sh
+
+: ${SBS_URL:="localhost:30003"}
+: ${SBS_LISTEN:=":8000"}
+: ${SBS_CLIENT_REFRESH:=200}
+: ${SBS_RECEIVER_LAT:=0}
+: ${SBS_RECEIVER_LON:=0}
+: ${SBS_AIRCRAFT_TIMEOUT:=60}
+: ${SBS_EXPIRY_CHECK_TIME:=1}
+: ${SBS_INSECURE_CORS:=1}
+: ${SBS_RECONNECT_TIME:=1}
+
+if test $SBS_INSECURE_CORS -gt 0; then 
+	exec sbshttp \
+		-sbs-url ${SBS_URL} \
+		-listen ${SBS_LISTEN} \
+		-lat ${SBS_RECEIVER_LAT} \
+		-lon ${SBS_RECEIVER_LON} \
+		-client-refresh ${SBS_CLIENT_REFRESH} \
+		-aircraft-timeout ${SBS_AIRCRAFT_TIMEOUT} \
+		-expiry-check ${SBS_EXPIRY_CHECK_TIME} \
+		-sbs-reconnect ${SBS_RECONNECT_TIME}
+else
+	exec sbshttp \
+		-sbs-url ${SBS_URL} \
+		-listen ${SBS_LISTEN} \
+		-lat ${SBS_RECEIVER_LAT} \
+		-lon ${SBS_RECEIVER_LON} \
+		-client-refresh ${SBS_CLIENT_REFRESH} \
+		-aircraft-timeout ${SBS_AIRCRAFT_TIMEOUT} \
+		-expiry-check ${SBS_EXPIRY_CHECK_TIME} \
+		-sbs-reconnect ${SBS_RECONNECT_TIME} \
+		-disable-insecure-cors
+fi