diff --git a/Makefile b/Makefile index e5edecb..6aee967 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,20 @@ -BUILD=ssaplayground.out -all: +NAME=ssaplayground +BUILD=$(NAME).out +IMAGE=$(NAME) +VERSION = $(shell git describe --always --tags) +all: clean go build -o $(BUILD) -mod vendor -start: - ./$(BUILD) -conf config/config.yaml + ./$(BUILD) -conf configs/config.yaml docker: - docker build -t ssaplayground:v0.1 -f docker/Dockerfile . -update: - docker run -itd -v ~/dev/ssaplayground/data:/app/public/buildbox -p 6789:6789 ssaplayground:v0.1 + docker build -t $(IMAGE):$(VERSION) -t $(IMAGE):latest -f docker/Dockerfile . +run: + docker ps -a | grep $(NAME) && ([ $$? -eq 0 ] && (docker stop $(NAME) && docker rm -f $(NAME))) || echo "no running container." + docker run -itd -v $(shell pwd)/data:/app/public/buildbox -p 6789:6789 --name $(NAME) ssaplayground:latest +tidy-docker: + docker ps -a | grep $(NAME) + [ $$? -eq 0 ] && docker stop $(NAME) && docker rm -f $(NAME) + docker images -f "dangling=true" -q | xargs docker rmi -f + docker image prune -f clean: rm -rf $(BUILD) .PHONY: all start docker update clean \ No newline at end of file diff --git a/README.md b/README.md index 1b31e07..0b5df1e 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,30 @@ A tool for exploring go ssa intermediate representation. ![](./public/assets/screen.png) +## Deployment + +There are two approaches to use the SSA Playground: native execution +or Docker-based deployment. + +To execute natively, you can just use: + +```bash +$ make +``` + +If you have Docker, then you can use: + +```bash +$ make docker # build the docker image +$ make run # run/update for latest image +``` + +Then access http://localhost:6789/gossa. + +## Contribution + +We would love to hear your feedback. Submit [an issue](https://github.com/changkun/ssaplayground/issues/new) to tell bugs or feature requests. + ## License GNU GPLv3 © [Changkun Ou](https://changkun.de) \ No newline at end of file diff --git a/configs/config.yaml b/configs/config.yaml new file mode 100644 index 0000000..342225e --- /dev/null +++ b/configs/config.yaml @@ -0,0 +1,4 @@ +--- +addr: localhost:6789 +mode: debug +static: public \ No newline at end of file diff --git a/config/config.yaml b/configs/docker.yaml similarity index 72% rename from config/config.yaml rename to configs/docker.yaml index 31738c1..448d324 100644 --- a/config/config.yaml +++ b/configs/docker.yaml @@ -1,4 +1,4 @@ --- addr: 0.0.0.0:6789 -mode: debug +mode: release static: public \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 74beb4c..3ae8c91 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,2 +1,7 @@ -FROM alpine:latest - +FROM golang:1.14-alpine +WORKDIR /app +ADD . /app +RUN go get -u golang.org/x/tools/cmd/goimports && go mod tidy +RUN go build -o ssaplayground.service -mod vendor +EXPOSE 6789 +ENTRYPOINT [ "/app/ssaplayground.service", "-conf=/app/configs/docker.yaml"] diff --git a/public/assets/screen.png b/public/assets/screen.png index 66adec4..d1e629b 100644 Binary files a/public/assets/screen.png and b/public/assets/screen.png differ diff --git a/public/buildbox/.gitkeep b/public/buildbox/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/public/buildbox/index.html b/public/buildbox/index.html index e69de29..6a52441 100644 --- a/public/buildbox/index.html +++ b/public/buildbox/index.html @@ -0,0 +1 @@ + \ No newline at end of file