diff --git a/Dockerfile b/Dockerfile index d3d3095a7..47ad223ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,14 +16,25 @@ COPY ./go.sum ./ RUN go install -buildvcs=false -ldflags "-X main.build=${VERSION}" ./cmd/... RUN go install -buildvcs=false -ldflags "-X main.build=${VERSION}" ./tools/... +FROM node:alpine AS ui-builder +WORKDIR /app +COPY ./ui ./ +RUN npm install +RUN npm run build + FROM alpine:latest RUN apk add --no-cache libstdc++ gcompat libgomp RUN apk add --update busybox>1.3.1-r0 RUN apk add --update openssl>3.1.4-r1 - - +RUN apk add --update nodejs npm +RUN apk add --update apache2-utils +RUN apk add --update libwebp=1.3.2-r0 +RUN apk add --update openssl>3.1.4-r1 RUN apk add curl + COPY --from=base ./service/api ./api COPY --from=base ./service/bin/* ./ COPY --from=base ./service/pkg/credentials ./pkg/credentials -COPY --from=base ./service/resolvers_settings.* ./ \ No newline at end of file +COPY --from=base ./service/resolvers_settings.* ./ +COPY --from=ui-builder ./app/dist ./ui/dist + diff --git a/internal/api/server.go b/internal/api/server.go index 96b7de338..3d5130059 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -58,9 +58,36 @@ func (s *Server) Health(_ context.Context, _ HealthRequestObject) (HealthRespons // RegisterStatic add method to the mux that are not documented in the API. func RegisterStatic(mux *chi.Mux) { - mux.Get("/", documentation) + mux.Get("/docs", documentation) mux.Get("/static/docs/api/api.yaml", swagger) mux.Get("/favicon.ico", favicon) + fs := http.FileServer(http.Dir("./ui/dist/")) + mux.Get("/schemas", func(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, "/", http.StatusFound) + }) + mux.Route("/credentials", func(r chi.Router) { + r.Get("/*", func(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, "/", http.StatusFound) + }) + }) + mux.Route("/connections", func(r chi.Router) { + r.Get("/*", func(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, "/", http.StatusFound) + }) + }) + mux.Route("/issuer-state", func(r chi.Router) { + r.Get("/*", func(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, "/", http.StatusFound) + }) + }) + mux.Route("/identities", func(r chi.Router) { + r.Get("/*", func(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, "/", http.StatusFound) + }) + }) + mux.Handle("/*", http.StripPrefix("/", fs)) + mux.Handle("/assets/*", fs) + mux.Handle("/images/*", fs) } func documentation(w http.ResponseWriter, _ *http.Request) { diff --git a/ui/src/adapters/env.ts b/ui/src/adapters/env.ts index 58837f989..bedf7cb40 100644 --- a/ui/src/adapters/env.ts +++ b/ui/src/adapters/env.ts @@ -35,7 +35,6 @@ export const envParser = getStrictParser()( .transform( ({ VITE_API_PASSWORD, - VITE_API_URL, VITE_API_USERNAME, VITE_BUILD_TAG, VITE_IPFS_GATEWAY_URL, @@ -46,7 +45,7 @@ export const envParser = getStrictParser()( }): Env => ({ api: { password: VITE_API_PASSWORD, - url: VITE_API_URL, + url: "/", username: VITE_API_USERNAME, }, buildTag: VITE_BUILD_TAG,