Skip to content

Commit

Permalink
feat: update web-editor
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed May 20, 2020
1 parent a0668cc commit f0b2e64
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Dockerfile
*~
.git/
28 changes: 16 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
FROM znly/protoc:0.3.0
# deps
FROM moul/protoc-gen-gotemplate:latest as pgg

ENV GOPATH=/go \
PATH=/go/bin:${PATH}
# 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
COPY . /go/src/moul.io/protoc-gen-gotemplate
WORKDIR /go/src/moul.io/protoc-gen-gotemplate
RUN go install . ./cmd/web-editor

# 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 golang:1.14-alpine
COPY --from=pgg /usr/bin/protoc /usr/bin/
COPY --from=builder /go/bin/web-editor /go/bin/
COPY --from=pgg /protobuf /protobuf
EXPOSE 8080
ENTRYPOINT ["/go/bin/web-editor"]
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 go.mod

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

Loading

0 comments on commit f0b2e64

Please sign in to comment.