Skip to content

Commit

Permalink
added a Dockerfile and Docker specific run instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
shawn hartsell committed Dec 22, 2016
1 parent ff67ae1 commit acdfbdc
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*/.vscode/*
*/bin/*
*/pkg/**/*
*/.env
*/.gitignore
*/vendor/pkg/**/*
Dockerfile
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.8

#install gb
RUN go get github.com/constabulary/gb/... && \
go install github.com/constabulary/gb

#build the project and start the server
COPY ./src /app/src
COPY ./vendor /app/vendor

WORKDIR /app
RUN gb build
ENV GIN_MODE=release
CMD ["bin/cowpoke"]

9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,18 @@ If you're using VSCode the following to your project settings.json to integrate

## Building and Running

__Local__
* ```gb build```
* ```bin/cowpoke```

__Via the included Dockerfile__

* ```docker build -t <your name>/go-cowpoke . ```
* the Dockerfile takes care of compiling the project and setting up GB
* ```docker run -ti --env-file ./.env -p 9000:9000 <your name>/go-cowpoke```
* starts the image on port 9000 using a local .env file for env vars
* env vars can also be passed in individual via ```-e```

## Dependencies

Dependencies should be added to __/vendor__ see [vendoring in Go](https://blog.gopheracademy.com/advent-2015/vendor-folder/)
Expand Down
5 changes: 4 additions & 1 deletion src/cowpoke/cowpoke.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"log"
"middleware/authentication"
"middleware/errors"
"os"
Expand Down Expand Up @@ -31,6 +32,8 @@ func main() {
routes.AddStackRoutes(api)
}

listenAddr := fmt.Sprintf(":%s", os.Getenv("HOST_PORT"))
log.Printf("service running on %s\n", listenAddr)
//start the server
r.Run(fmt.Sprintf(":%s", os.Getenv("HOST_PORT")))
r.Run(listenAddr)
}

0 comments on commit acdfbdc

Please sign in to comment.