Skip to content

Commit

Permalink
Merge pull request #155 from moul/dev/moul/update-web-editor
Browse files Browse the repository at this point in the history
  • Loading branch information
moul authored May 20, 2020
2 parents a0668cc + 1c966f6 commit 57c04e0
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Dockerfile
*~
.git/
30 changes: 17 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
FROM znly/protoc:0.3.0
# builder
FROM golang:1.14-alpine as builder
RUN apk --no-cache add make git go rsync libc-dev
RUN go get -u golang.org/x/tools/cmd/goimports
RUN go get -u github.com/gobuffalo/packr/v2/packr2
COPY . /go/src/moul.io/protoc-gen-gotemplate
WORKDIR /go/src/moul.io/protoc-gen-gotemplate
RUN packr2
RUN go install -a -tags netgo -ldflags '-w -extldflags "-static"' . ./cmd/web-editor
RUN ls -la /go/bin

ENV GOPATH=/go \
PATH=/go/bin:${PATH}

# Install deps and common tools
RUN apk --update add make git go rsync libc-dev \
&& go get -u golang.org/x/tools/cmd/goimports

# Install protoc-gen-gotemplate
COPY . /go/src/moul.io/protoc-gen-gotemplate
WORKDIR /go/src/moul.io/protoc-gen-gotemplate
RUN git remote set-url origin https://github.com/moul/protoc-gen-gotemplate
RUN go install . ./cmd/web-editor
# runtime
FROM znly/protoc:0.3.0
COPY --from=builder /go/bin/web-editor /go/bin/
COPY --from=builder /go/bin/protoc-gen-gotemplate /go/bin/
ENV PATH=$PATH:/go/bin
EXPOSE 8080
ENTRYPOINT []
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GOPKG ?= moul.io/protoc-gen-gotemplate
DOCKER_IMAGE ?= moul/golang-repo-template
DOCKER_IMAGE ?= moul/protoc-gen-gotemplate
GOBINS ?= . ./cmd/web-editor
GOLIBS ?= .

Expand Down
5 changes: 4 additions & 1 deletion cmd/web-editor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"os/exec"
"path/filepath"

packr "github.com/gobuffalo/packr/v2"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
)
Expand Down Expand Up @@ -101,7 +102,9 @@ func returnError(w http.ResponseWriter, err error) {
func main() {
r := mux.NewRouter()

r.Handle("/", http.FileServer(http.Dir("static")))
box := packr.New("static", "./static")

r.Handle("/", http.FileServer(box))
r.HandleFunc("/generate", generate)
addr := fmt.Sprintf(":%s", os.Getenv("PORT"))
if addr == ":" {
Expand Down
2 changes: 1 addition & 1 deletion cmd/web-editor/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/styles/github.min.css">
<style>.ace_editor { height: 80%; }</style>
<style>.ace_editor { height: 80%; min-height: 500px; }</style>
</head>
<body ng-app="pggt">
<div class="container-fluid" ng-controller="PggtCtrl">
Expand Down
2 changes: 1 addition & 1 deletion go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

141 changes: 141 additions & 0 deletions go.sum

Large diffs are not rendered by default.

0 comments on commit 57c04e0

Please sign in to comment.