Browse Source

Adds support for serving static files and updates dockerfile

master
Noah Pederson 3 years ago
parent
commit
ce3c439702
  1. 9
      Dockerfile
  2. 7
      cmd/main.go
  3. 0
      static/.gitkeep

9
Dockerfile

@ -1,7 +1,10 @@
FROM scratch
FROM ubuntu
EXPOSE 8000
COPY plafws /
RUN mkdir /app
CMD [ "/plafws"]
COPY plafws /app/plafws
CMD [ "/app/plafws"]

7
cmd/main.go

@ -13,13 +13,8 @@ import (
func main() {
// POSTGRES_USER := os.Getenv("POSTGRES_USER")
// POSTGRES_PASSWORD := os.Getenv("POSTGRES_PASSWORD")
// POSTGRES_ADDR := os.Getenv("POSTGRES_ADDR")
POSTGRES_URI := os.Getenv("POSTGRES_URI")
// connStr := fmt.Sprintf("host=%s user=%s password='%s' dbname=packetlostandfound sslmode=disable", POSTGRES_ADDR, POSTGRES_USER, POSTGRES_PASSWORD)
db, err := sql.Open("postgres", POSTGRES_URI)
if err != nil {
panic(err)
@ -34,6 +29,8 @@ func main() {
contact.BindEndpoints(r, contactService)
})
r.Handle("/*", http.FileServer(http.Dir("./static/")))
//Finally bind everything to the root endpoint
http.Handle("/", r)
log.Fatal(http.ListenAndServe(":8000", nil))

0
static/.gitkeep

Loading…
Cancel
Save