diff --git a/ui/.ackrc b/.ackrc similarity index 92% rename from ui/.ackrc rename to .ackrc index ac2947fe..ec8b5d11 100644 --- a/ui/.ackrc +++ b/.ackrc @@ -7,6 +7,7 @@ --ignore-dir=coverage --ignore-dir=dist --ignore-dir=node_modules +--ignore-dir=static/ui --ignore-dir=tmp --ignore-dir=vendor --ignore-file=ext:svg diff --git a/Dockerfile b/Dockerfile index 7663b808..3faae117 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,18 @@ -FROM golang:1.22.0-alpine3.19 AS build -RUN apk add -U --no-cache make git npm +FROM node:18-alpine as build-ui +RUN apk add -U --no-cache make git +COPY ui /src +WORKDIR /src +RUN make + +FROM golang:1.22.0-alpine3.19 AS build-go +RUN apk add -U --no-cache make git COPY . /src/gptscript +COPY --from=build-ui /src/.output/public /src/gptscript/static/ui WORKDIR /src/gptscript - -RUN make all +RUN make build FROM alpine AS release -COPY --from=build /src/gptscript/bin /usr/local/bin/ +WORKDIR /src +COPY --from=build-go /src/gptscript/bin /usr/local/bin/ +COPY --from=build-go /src/gptscript/examples /src/examples ENTRYPOINT ["/usr/local/bin/gptscript"] diff --git a/Makefile b/Makefile index 72cea724..afd7fe96 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,10 @@ all: build-ui build build-ui: $(MAKE) -C ui + rm -rf static/ui + mkdir -p static/ui/_nuxt + touch static/ui/placeholder static/ui/_nuxt/_placeholder + cp -rp ui/.output/public/* static/ui/ build: CGO_ENABLED=0 go build -o bin/gptscript -tags "${GO_TAGS}" -ldflags "-s -w" . diff --git a/ui/Makefile b/ui/Makefile index 37fe81de..0035859d 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -1,9 +1,6 @@ build: clean npm install npm run generate - rm -rf ../static/ui/_nuxt - cp -rp .output/public/* ../static/ui/ - touch ../static/ui/_nuxt/_placeholder clean: npm run clean diff --git a/ui/nuxt.config.ts b/ui/nuxt.config.ts index c3b9357d..068ad4e6 100644 --- a/ui/nuxt.config.ts +++ b/ui/nuxt.config.ts @@ -4,6 +4,8 @@ import pkg from './package.json' dotenv.config() const port = 9091 +const isDev = process.env.NODE_ENV === 'development' +const api = process.env.NUXT_PUBLIC_API || (isDev ? 'http://localhost:9090/' : '/') // https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ @@ -35,7 +37,7 @@ export default defineNuxtConfig({ nitro: { sourceMap: true }, runtimeConfig: { public: { - api: (process.env.NUXT_PUBLIC_API || 'http://localhost:9090/').replace(/\/+$/,'')+'/', + api: api.replace(/\/+$/,'')+'/', }, }, sourcemap: true, diff --git a/ui/pages/index.vue b/ui/pages/index.vue index c3889ec1..e532ff2b 100644 --- a/ui/pages/index.vue +++ b/ui/pages/index.vue @@ -4,6 +4,6 @@ -