Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- the code in finance is just some dummy code from the watcher repo
- 1. build your docker image
- docker build -t mywatcher:latest .
- 2. start compose
- docker-compose up -d
- ############
- Dockerfile
- ###########
- filename:
- Dockerfile
- #########
- # get the official golang image from docker hub
- FROM golang:1.9
- # maintainer is deprecated and new one is label
- LABEL maintainer="Can Yucel [can.yucel@gmail.com](mailto:can.yucel@gmail.com)"
- # why are you installing those?
- RUN apt-get update && apt-get install -y --no-install-recommends \
- g++ \
- gcc \
- libc6-dev \
- make \
- pkg-config \
- bison \
- curl
- # in case you want to specify the version of watcher go with the old approach, but this should be fine
- RUN go get github.com/canthefason/go-watcher
- RUN go install github.com/canthefason/go-watcher/cmd/watcher
- # set the workdir (same as cd to /go/src/)
- # if it does not exist it gets created
- WORKDIR /go/src
- # empty start, you can override this in your compose file
- CMD ["/bin/bash"]
- ###########
- docker-compose file
- #############
- filename:
- docker-compose.yml
- #############
- version: "3"
- services:
- db:
- image: postgres
- environment:
- POSTGRES_DB: dev
- POSTGRES_USER: postgres
- POSTGRES_PASSWORD: postgres
- ports:
- - 5432:5432
- app:
- image: mywatcher:latest
- command: watcher -run finance
- ports:
- - "80:8080"
- volumes:
- - .:/go/src/
- depends_on:
- - db
- #########
- dummy code
- ########
- filename:
- finance/main.go
- ###########
- package main
- import (
- "fmt"
- "net/http"
- )
- func main() {
- http.ListenAndServe(":7000",
- http.HandlerFunc(
- func(w http.ResponseWriter, r *http.Request) {
- fmt.Fprintln(w, "watcher is running now")
- },
- ),
- )
- }
Add Comment
Please, Sign In to add comment