diff --git a/Makefile b/Makefile index 6490bd73..4db20a02 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,6 @@ alldeps: dev: docker-compose -p athensdev up -d mongo docker-compose -p athensdev up -d redis - ./scripts/create_default_config.sh .PHONY: down down: diff --git a/cmd/olympus/Dockerfile b/cmd/olympus/Dockerfile index d4ba344c..7ad74667 100644 --- a/cmd/olympus/Dockerfile +++ b/cmd/olympus/Dockerfile @@ -17,8 +17,7 @@ WORKDIR $GOPATH/src/github.com/gomods/athens ADD . . RUN cd cmd/olympus && buffalo build -s -o /bin/app -RUN scripts/create_default_config.sh -COPY config.toml /bin/config.toml +COPY config.dev.toml /config/config.toml FROM alpine RUN apk add --no-cache bash @@ -27,7 +26,7 @@ RUN apk add --no-cache ca-certificates WORKDIR /bin/ COPY --from=builder /bin/app . -COPY --from=builder /bin/config.toml . +COPY --from=builder /config/config.toml . # Comment out to run the binary in "production" mode: # ENV GO_ENV=production @@ -39,4 +38,4 @@ EXPOSE 3000 # Comment out to run the migrations before running the binary: # CMD /bin/app migrate; /bin/app -CMD exec /bin/app -config_file=config.toml +CMD exec /bin/app -config_file=/config/config.toml diff --git a/cmd/proxy/Dockerfile b/cmd/proxy/Dockerfile index 2e1f971a..9eeeb338 100644 --- a/cmd/proxy/Dockerfile +++ b/cmd/proxy/Dockerfile @@ -8,10 +8,7 @@ WORKDIR $GOPATH/src/github.com/gomods/athens COPY . . -RUN apk update && \ - apk add --no-cache bash && \ - GO111MODULE=on CGO_ENABLED=0 go build -mod=vendor -o /bin/athens-proxy ./cmd/proxy && \ - ./scripts/create_default_config.sh +RUN GO111MODULE=on CGO_ENABLED=0 go build -mod=vendor -o /bin/athens-proxy ./cmd/proxy FROM alpine @@ -19,8 +16,6 @@ ENV GO111MODULE=on COPY --from=builder /bin/athens-proxy /bin/athens-proxy COPY --from=builder /go/src/github.com/gomods/athens/config.dev.toml /config/config.toml -COPY --from=builder /go/src/github.com/gomods/athens/cmd/proxy/locales /go/src/github.com/gomods/athens/cmd/proxy/locales -COPY --from=builder /go/src/github.com/gomods/athens/cmd/proxy/assets /go/src/github.com/gomods/athens/cmd/proxy/assets COPY --from=builder /usr/local/go/bin/go /bin/go RUN apk update && \ diff --git a/cmd/proxy/actions/app.go b/cmd/proxy/actions/app.go index 31df6eaf..b1d76053 100644 --- a/cmd/proxy/actions/app.go +++ b/cmd/proxy/actions/app.go @@ -6,10 +6,8 @@ import ( "github.com/gobuffalo/buffalo" "github.com/gobuffalo/buffalo/middleware" "github.com/gobuffalo/buffalo/middleware/csrf" - "github.com/gobuffalo/buffalo/middleware/i18n" "github.com/gobuffalo/buffalo/middleware/ssl" "github.com/gobuffalo/buffalo/render" - "github.com/gobuffalo/packr" "github.com/gomods/athens/pkg/config" "github.com/gomods/athens/pkg/log" mw "github.com/gomods/athens/pkg/middleware" @@ -23,23 +21,10 @@ import ( // Service is the name of the service that we want to tag our processes with const Service = "proxy" -// T is the translator to use -var T *i18n.Translator - -func init() { - proxy = render.New(render.Options{ - // HTML layout to be used for all HTML requests: - HTMLLayout: "application.html", - JavaScriptLayout: "application.js", - - // Box containing all of the templates: - TemplatesBox: packr.NewBox("../templates/proxy"), - AssetsBox: assetsBox, - - // Add template helpers here: - Helpers: render.Helpers{}, - }) -} +var proxy = render.New(render.Options{ + // Add template helpers here: + Helpers: render.Helpers{}, +}) // App is where all routes and middleware for buffalo // should be defined. This is the nerve center of your @@ -115,11 +100,6 @@ func App(conf *config.Config) (*buffalo.App, error) { csrfMiddleware := csrf.New app.Use(csrfMiddleware) } - // Setup and use translations: - if T, err = i18n.New(packr.NewBox("../locales"), "en-US"); err != nil { - app.Stop(err) - } - app.Use(T.Middleware()) if !conf.Proxy.FilterOff { mf := module.NewFilter(conf.FilterFile) @@ -141,9 +121,5 @@ func App(conf *config.Config) (*buffalo.App, error) { return nil, err } - // serve files from the public directory: - // has to be last - app.ServeFiles("/", assetsBox) - return app, nil } diff --git a/cmd/proxy/actions/home.go b/cmd/proxy/actions/home.go index ed5949d2..f03ddb5d 100644 --- a/cmd/proxy/actions/home.go +++ b/cmd/proxy/actions/home.go @@ -5,5 +5,5 @@ import ( ) func proxyHomeHandler(c buffalo.Context) error { - return c.Render(200, proxy.HTML("index.html")) + return c.Render(200, proxy.JSON("Welcome to The Athen Proxy")) } diff --git a/cmd/proxy/actions/render.go b/cmd/proxy/actions/render.go deleted file mode 100644 index b1a73578..00000000 --- a/cmd/proxy/actions/render.go +++ /dev/null @@ -1,9 +0,0 @@ -package actions - -import ( - "github.com/gobuffalo/buffalo/render" - "github.com/gobuffalo/packr" -) - -var proxy *render.Engine -var assetsBox = packr.NewBox("../public") diff --git a/cmd/proxy/locales/all.en-us.yaml b/cmd/proxy/locales/all.en-us.yaml deleted file mode 100644 index 6514e210..00000000 --- a/cmd/proxy/locales/all.en-us.yaml +++ /dev/null @@ -1,3 +0,0 @@ -# For more information on using i18n see: https://github.com/nicksnyder/go-i18n -- id: welcome_greeting - translation: "Welcome to Buffalo (EN)" diff --git a/cmd/proxy/templates/_flash.html b/cmd/proxy/templates/_flash.html deleted file mode 100644 index 6e63b192..00000000 --- a/cmd/proxy/templates/_flash.html +++ /dev/null @@ -1,14 +0,0 @@ -<%= if (len(flash) > 0) { %> -
-
- <%= for (k, messages) in flash { %> - <%= for (msg) in messages { %> - - <% } %> - <% } %> -
-
- <% } %> \ No newline at end of file diff --git a/cmd/proxy/templates/goget.html b/cmd/proxy/templates/goget.html deleted file mode 100644 index 07c75639..00000000 --- a/cmd/proxy/templates/goget.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/cmd/proxy/templates/proxy/_flash.html b/cmd/proxy/templates/proxy/_flash.html deleted file mode 100644 index 6e63b192..00000000 --- a/cmd/proxy/templates/proxy/_flash.html +++ /dev/null @@ -1,14 +0,0 @@ -<%= if (len(flash) > 0) { %> -
-
- <%= for (k, messages) in flash { %> - <%= for (msg) in messages { %> - - <% } %> - <% } %> -
-
- <% } %> \ No newline at end of file diff --git a/cmd/proxy/templates/proxy/application.html b/cmd/proxy/templates/proxy/application.html deleted file mode 100644 index 1581b1c5..00000000 --- a/cmd/proxy/templates/proxy/application.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - Athens Go Module Proxy - <%= stylesheetTag("application.css") %> - <%= if (authenticity_token) { %> - - - <% } %> - "> - - -
- - - - <%= partial("flash.html") %> - <%= yield %> -
- - <%= javascriptTag("application.js") %> - - diff --git a/cmd/proxy/templates/proxy/index.html b/cmd/proxy/templates/proxy/index.html deleted file mode 100644 index 62e9a5f2..00000000 --- a/cmd/proxy/templates/proxy/index.html +++ /dev/null @@ -1,5 +0,0 @@ -
-
-

Welcome to the Athens proxy

-
-
diff --git a/init.ps1 b/init.ps1 index 5b4d8ac6..56c9c66c 100644 --- a/init.ps1 +++ b/init.ps1 @@ -99,7 +99,6 @@ if ($alldeps.IsPresent) { if ($dev.IsPresent) { & docker-compose -p athensdev up -d mongo & docker-compose -p athensdev up -d redis - execScript "create_default_config.ps1" } if ($test.IsPresent) { diff --git a/scripts/create_default_config.sh b/scripts/create_default_config.sh deleted file mode 100755 index 1fd8b188..00000000 --- a/scripts/create_default_config.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" - -if [ ! -e "${SCRIPTS_DIR}/../config.toml" ] ; then - cp "${SCRIPTS_DIR}/../config.dev.toml" "${SCRIPTS_DIR}/../config.toml" -fi