Skip to content

Commit

Permalink
Merge branch 'master' into wasm-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
d4l3k committed Sep 29, 2018
2 parents 8a2176f + 259dd6f commit 974e334
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 7 deletions.
51 changes: 48 additions & 3 deletions playground/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,51 @@
FROM scratch
COPY . /
FROM golang:alpine as base

RUN apk add binutils git subversion mercurial
RUN strip /usr/local/go/bin/go
RUN rm /usr/local/go/bin/gofmt
RUN rm -r /usr/local/go/src/cmd
#RUN rm -r /usr/local/go/src/vendor
RUN rm -r /usr/local/go/api
RUN rm -r /usr/local/go/lib
RUN rm -r /usr/local/go/misc
RUN rm -r /usr/local/go/test
RUN rm -r /usr/share
RUN find /usr/local/go/src -name "testdata" -exec rm -r {} +
RUN find /usr/lib/python2.7 -name "*.pyo" -exec rm -r {} +
RUN find /usr/lib/python2.7 -name "*.pyc" -exec rm -r {} +
RUN rm -r /usr/local/go/pkg/linux_amd64
RUN strip /usr/local/go/pkg/tool/linux_amd64/*

WORKDIR /go/src/app
COPY . .

RUN CGO_ENABLED=0 go get ./server
RUN CGO_ENABLED=0 go build -ldflags "-s -w" -o playground ./server
RUN rm -r /go/src/github.com /go/src/golang.org /go/bin
RUN rm -r /root

EXPOSE 8080
CMD ["/playground"]
CMD ["/go/src/app/playground"]

#WORKDIR /go/src/app
#COPY . .
#
#FROM scratch
#ENV LD_LIBRARY_PATH /lib/:/usr/lib/
#
#COPY --from=base /go/src/app/ /
#
#COPY --from=base /usr/local/go/bin/go /bin/
#COPY --from=base /usr/local/go/src /usr/local/go/
#
#COPY --from=base /lib/*.so* /lib/
#COPY --from=base /usr/lib/*.so* /usr/lib/
#
#COPY --from=base /usr/bin/git /bin/
#COPY --from=base /usr/bin/svn /bin/
#COPY --from=base /usr/bin/hg /bin/
#
#COPY --from=base /tmp/ /tmp/

#EXPOSE 8080
#CMD ["/playground"]
3 changes: 2 additions & 1 deletion playground/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
build: wasm_exec.js
yarn install
go install -v ..
@rm -r bundles
mkdir -p bundles
go-pry -generate="bundles/main.go" -i="fmt,log,math" -e='log.Println("Hello world!")'
GOOS=js GOARCH=wasm go build -v -ldflags "-s -w" -o bundles/main.wasm bundles/main.go
go-pry -generate="bundles/stdlib.go" -i="$(shell tr '\n' ',' < packages.txt)" -e='log.Println("Hello world!")'
GOOS=js GOARCH=wasm go build -v -ldflags "-s -w" -o bundles/stdlib.wasm bundles/stdlib.go
CGO_ENABLED=0 go build -ldflags "-s -w" -o playground ./server

.PHONY: run
run: build
CGO_ENABLED=0 go build -ldflags "-s -w" -o playground ./server
./playground

wasm_exec.js: $(shell go env GOROOT)/misc/wasm/wasm_exec.js
Expand Down
4 changes: 2 additions & 2 deletions playground/now.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"node_modules",
"wasm_exec.js",
"bundles",
"playground",
"Dockerfile"
"Dockerfile",
"server"
],
"public": true
}
Expand Down
4 changes: 3 additions & 1 deletion playground/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"strings"

"github.com/d4l3k/go-pry/generate"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -123,5 +124,6 @@ func run() error {
router.NotFoundHandler = http.FileServer(http.Dir("."))

log.Printf("Listening %s...", *bind)
return http.ListenAndServe(*bind, router)
r := handlers.CombinedLoggingHandler(os.Stderr, router)
return http.ListenAndServe(*bind, r)
}

0 comments on commit 974e334

Please sign in to comment.