From 2ed724279143dbf193daa289e8be885c49bf0f9e Mon Sep 17 00:00:00 2001 From: Josh Dolitsky Date: Sun, 2 Dec 2018 04:44:02 -0600 Subject: [PATCH] Local dev fixes --- .gitignore | 3 +++ Dockerfile | 31 +++++++++++++++-------- Godeps/Godeps.json | 2 +- README.md | 18 +++++++++++--- conf/app.conf | 2 +- controllers/chartmuseum.go | 3 ++- docker-compose.yaml | 51 +++++++++++++------------------------- main.go | 2 +- routers/router.go | 2 +- tests/default_test.go | 3 ++- 10 files changed, 63 insertions(+), 54 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e17d8e0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea/ +charts/ +ui diff --git a/Dockerfile b/Dockerfile index 78c9aaf..2ffbc85 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,7 @@ -FROM library/golang +# +# Stage 1 +# +FROM library/golang:1 as builder # Godep for vendoring RUN go get github.com/tools/godep @@ -6,16 +9,24 @@ RUN go get github.com/tools/godep # Recompile the standard library without CGO RUN CGO_ENABLED=0 go install -a std -ENV APP_DIR $GOPATH/src/quickstart +ENV APP_DIR $GOPATH/src/github.com/chartmuseum/ui RUN mkdir -p $APP_DIR - -# Set the entrypoint -ENTRYPOINT (cd $APP_DIR && ./quickstart) ADD . $APP_DIR # Compile the binary and statically link -RUN cd $APP_DIR && CGO_ENABLED=0 godep go build -ldflags '-d -w -s' - -EXPOSE 8080 - - +RUN cd $APP_DIR && \ + CGO_ENABLED=0 godep go build -ldflags '-w -s' -o /chartmuseum-ui && \ + cp -r views/ /views && \ + cp -r static/ /static + +# +# Stage 2 +# +FROM alpine:3.8 +RUN apk add --no-cache curl cifs-utils ca-certificates \ + && adduser -D -u 1000 chartmuseum +COPY --from=builder /chartmuseum-ui /chartmuseum-ui +COPY --from=builder /views /views +COPY --from=builder /static /static +USER 1000 +ENTRYPOINT ["/chartmuseum-ui"] diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index e288a17..fe9396c 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,5 +1,5 @@ { - "ImportPath": "quickstart", + "ImportPath": "ui", "GoVersion": "go1.11", "GodepVersion": "v80", "Deps": [ diff --git a/README.md b/README.md index 8a370e1..ca298bd 100644 --- a/README.md +++ b/README.md @@ -12,16 +12,26 @@ ChartMuseumUI was written in Go (Golang) with the help of Beego Framework. ## Getting Started -These instructions will get you with your very own private charts repository. You can run this on your localmachine, on cloud and basically on every machine that have docker and docker-compose installed. +These instructions will get you started with your very own private chart repository and UI. ### Usage -ChartMuseumUI using [ChartMuseum](https://github.com/helm/chartmuseum) as a backend so the best way would be to use docker-compose. +ChartMuseumUI uses [ChartMuseum](https://github.com/helm/chartmuseum) as a backend. +To get started quickly, you can build and run the app using docker-compose. + +Clone this repo and run the following: -For example, the following docker-compose file is defining ChartMuseum with Amazon S3 as a storage and exposing ChartMuseumUI on port 80 ``` -version: '2.0' +docker-compose up +``` +This will start ChartMuseumUI at [http://localhost:3000](http://localhost:3000) +and ChartMuseum at [http://localhost:8080](http://localhost:8080). +Check out the source of [docker-compose.yaml](./docker-compose.yaml) and modify for your purposes. + +Here is an example docker-compose file defining ChartMuseum with Amazon S3 as a storage and exposing ChartMuseumUI on port 80: +``` +version: '2.0' services: ui: image: idobry/chartmuseumui:latest diff --git a/conf/app.conf b/conf/app.conf index dc65246..9bfe52e 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -1,3 +1,3 @@ -appname = quickstart +appname = ui httpport = 8080 runmode = dev diff --git a/controllers/chartmuseum.go b/controllers/chartmuseum.go index 34b6166..d47672a 100644 --- a/controllers/chartmuseum.go +++ b/controllers/chartmuseum.go @@ -3,7 +3,8 @@ package controllers import ( "os" "os/exec" - "quickstart/models" + + "github.com/chartmuseum/ui/models" "github.com/astaxie/beego/httplib" "github.com/astaxie/beego/logs" diff --git a/docker-compose.yaml b/docker-compose.yaml index 7ef2de8..813a5c8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,37 +1,20 @@ -version: '3.4' - +version: '2.0' services: - ui: - image: idobry/chartmuseumui:0.0.4 - environment: - CHART_MUSESUM_URL: "http://chartmuseum:8080" - AUTHENTICATION: "true" - DB_HOST: postgres - DB_USER: user - DB_PASSWORD: user - DB_NAME: db - ports: - - 9090:8080 - - chartmuseum: - image: chartmuseum/chartmuseum:latest - volumes: - - ~/.aws:/root/.aws:ro - restart: always - environment: + ui: + build: ./ + #image: idobry/chartmuseumui:latest + environment: + CHART_MUSESUM_URL: http://chartmuseum:8080 + ports: + - 3000:8080 + chartmuseum: + image: chartmuseum/chartmuseum:v0.7.1 + ports: + - 8080:8080 + volumes: + - ./charts:/charts + environment: PORT: 8080 DEBUG: 1 - STORAGE: "amazon" - STORAGE_AMAZON_BUCKET: "imisight-chartmuseum" - STORAGE_AMAZON_PREFIX: "" - STORAGE_AMAZON_REGION: "eu-west-1" - ports: - - 8080:8080 - - postgres: - image: postgres - restart: always - environment: - POSTGRES_PASSWORD: user - POSTGRES_USER: user - POSTGRES_DB: db \ No newline at end of file + STORAGE: local + STORAGE_LOCAL_ROOTDIR: /charts diff --git a/main.go b/main.go index 29685f2..a22d72e 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,7 @@ package main import ( - _ "quickstart/routers" + _ "github.com/chartmuseum/ui/routers" "github.com/astaxie/beego" ) diff --git a/routers/router.go b/routers/router.go index 3ea0ce2..210b93e 100644 --- a/routers/router.go +++ b/routers/router.go @@ -1,7 +1,7 @@ package routers import ( - "quickstart/controllers" + "github.com/chartmuseum/ui/controllers" "github.com/astaxie/beego" ) diff --git a/tests/default_test.go b/tests/default_test.go index 7aa7f88..e3547af 100644 --- a/tests/default_test.go +++ b/tests/default_test.go @@ -6,7 +6,8 @@ import ( "testing" "runtime" "path/filepath" - _ "quickstart/routers" + + _ "github.com/chartmuseum/ui/routers" "github.com/astaxie/beego" . "github.com/smartystreets/goconvey/convey"