Initial commit
parent
c8772790b2
commit
8b2e437ecb
|
@ -0,0 +1,15 @@
|
||||||
|
FROM golang:1.11-rc-alpine as build
|
||||||
|
|
||||||
|
RUN apk add --no-cache git=2.18.1-r0
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
COPY go.mod go.sum .env *.go ./
|
||||||
|
RUN go get -d -v ./...
|
||||||
|
RUN CGO_ENABLED=0 go build -ldflags "-s -w"
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
|
||||||
|
COPY --from=build /src/pictures /pictures
|
||||||
|
COPY --from=build /src/.env /.env
|
||||||
|
|
||||||
|
ENTRYPOINT ["/pictures"]
|
|
@ -0,0 +1,8 @@
|
||||||
|
module pictures
|
||||||
|
|
||||||
|
go 1.12
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/joho/godotenv v1.3.0
|
||||||
|
github.com/julienschmidt/httprouter v1.2.0
|
||||||
|
)
|
|
@ -0,0 +1,4 @@
|
||||||
|
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||||
|
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||||
|
github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g=
|
||||||
|
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
|
@ -0,0 +1,29 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/joho/godotenv"
|
||||||
|
"github.com/julienschmidt/httprouter"
|
||||||
|
)
|
||||||
|
|
||||||
|
var listen string
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Load .env
|
||||||
|
err := godotenv.Load()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Error loading .env file")
|
||||||
|
}
|
||||||
|
listen = os.Getenv("LISTEN")
|
||||||
|
|
||||||
|
// Routes
|
||||||
|
router := httprouter.New()
|
||||||
|
|
||||||
|
// Start server
|
||||||
|
log.Printf("starting server on %s", listen)
|
||||||
|
log.Fatal(http.ListenAndServe(listen, router))
|
||||||
|
}
|
Loading…
Reference in New Issue