Skip to content

Commit

Permalink
Setting up to use POST data and query parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mtiller committed Aug 30, 2014
1 parent 0c642aa commit 94641c7
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 18 deletions.
32 changes: 27 additions & 5 deletions docker/gopath/src/xogeny/pubbook/Dockerfile
Expand Up @@ -2,13 +2,35 @@
# dependencies for building the book.

FROM mtiller/book-py
FROM golang:1.3

ADD . /go/src/xogeny/pubbook
WORKDIR /go/src/xogeny/pubbook
RUN apt-get install -y golang

# The rest of this we do as a user
RUN useradd builder

ADD . /opt/MBE/src/pubbook

RUN chown -R builder /opt/MBE

USER builder

# Create a directory for all the book related stuff
#RUN mkdir /opt/MBE/src
RUN mkdir /opt/MBE/bin
RUN mkdir /opt/MBE/pkg


ENV GOPATH /opt/MBE
ENV PATH $PATH:$GOPATH/bin

WORKDIR /opt/MBE/src/pubbook

RUN go get
RUN go install

WORKDIR /opt/MBE

EXPOSE 3000

RUN go get && go install
ENTRYPOINT ["/go/bin/pubbook"]
ENTRYPOINT ["./bin/pubbook"]
CMD []
3 changes: 1 addition & 2 deletions docker/gopath/src/xogeny/pubbook/Makefile
@@ -1,6 +1,5 @@
image:
-rm -rf _cache
tar zcf - . | docker build -t mtiller/book-hook -
tar zcf - Dockerfile pubbook.go | docker build -t mtiller/book-hook -

run: image
docker run -P -t mtiller/book-hook
Expand Down
37 changes: 26 additions & 11 deletions docker/gopath/src/xogeny/pubbook/pubbook.go
Expand Up @@ -40,7 +40,7 @@ func git(dir string, args...string) error {
return nil;
}

func make(dir string, targets...string) error {
func runmake(dir string, targets...string) error {
ebuf := []byte{};
obuf := []byte{};

Expand All @@ -66,12 +66,23 @@ func make(dir string, targets...string) error {
return nil;
}

func (b Builder) Push(msg hs.HubMessage) {
url := "git@github.com:xogeny/ModelicaBook.git"
ref := "origin/master"
target1 := "dirhtml_cn"
target2 := "web_cn"
user := "xogeny"
func (b Builder) Push(msg hs.HubMessage, params map[string][]string) {
user := msg.Repository.Owner.Name;
url := msg.Repository.GitUrl;
ref := msg.After;
var targets []string = params["target"];
if (user=="") {
user = "xogeny";
url = "https://github.com/xogeny/ModelicaBook.git"
ref = "origin/master"
targets = []string{"dirhtml_cn", "web_cn"}
}
log.Printf("User: %s", user);
log.Printf("URL: %s", url);
log.Printf("Ref: %s", ref);
log.Printf("Targets: %v", targets);

// TODO: Get these from query parameters

dir := path.Join("_cache", user);

Expand All @@ -97,14 +108,18 @@ func (b Builder) Push(msg hs.HubMessage) {
if (!exists) {
// If it didn't already exist, we need to run some make targets
/* Run make */
make(dir, "specs");
err = runmake(dir, "specs");
if (err!=nil) { return; }
}

/* Run make */
make(dir, "results", target1, target2, bucket);
if err != nil { return; }

args := []string{"results"};
args = append(args, targets...);
args = append(args, bucket);
targets = append(targets, bucket);
err = runmake(dir, args...);
if (err != nil) { return; }

log.Printf("Make ran!");
}

Expand Down

0 comments on commit 94641c7

Please sign in to comment.