From bf5c2efa994cb634d351a4164577712bae80909a Mon Sep 17 00:00:00 2001 From: rajakumar05032000 Date: Sun, 31 Mar 2024 15:19:29 +0530 Subject: [PATCH 1/2] Fix - optimized UI dockerfile and removed unnecessary index.html file --- app.dockerfile | 37 ++++++++++++++++++------------------- ui/package.json | 2 ++ ui/static/index.html | 13 ------------- ui/svelte.config.js | 3 ++- 4 files changed, 22 insertions(+), 33 deletions(-) delete mode 100644 ui/static/index.html diff --git a/app.dockerfile b/app.dockerfile index 67a99764..6f7bfb68 100644 --- a/app.dockerfile +++ b/app.dockerfile @@ -1,29 +1,28 @@ -FROM debian:12 +# Pulling stage 1 image, keep alias as layer1 +FROM node:latest as layer1 -# setting up build variable +# Setting necessary arguments ARG VITE_API_BASE_URL ENV VITE_API_BASE_URL=${VITE_API_BASE_URL} -# setting up os env -USER root +# Copy UI source code +copy ui /home/nonroot/client + +# Change Work directory WORKDIR /home/nonroot/client -RUN groupadd -r nonroot && useradd -r -g nonroot -d /home/nonroot/client -s /bin/bash nonroot -# install node js -RUN apt-get update && apt-get upgrade -RUN apt-get install -y build-essential software-properties-common curl sudo wget git -RUN curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - -RUN apt-get install nodejs +# Building APP bundle +RUN npm run build -# copying devika app client only -COPY ui /home/nonroot/client/ui -COPY src /home/nonroot/client/src -COPY config.toml /home/nonroot/client/ +# Pulling stage 2 image, to significantly reduce image size +FROM gcr.io/distroless/nodejs20-debian11 -RUN cd ui && npm install && npm install -g npm && npm install -g bun -RUN chown -R nonroot:nonroot /home/nonroot/client +# Copy build files from layer 1 +COPY --from=layer1 /home/nonroot/client/build /app +COPY --from=layer1 /home/nonroot/client/package.json /app -USER nonroot -WORKDIR /home/nonroot/client/ui +# Change Work directory +WORKDIR /app -ENTRYPOINT [ "npx", "bun", "run", "dev", "--", "--host" ] \ No newline at end of file +# RUN APP +CMD ["index.js"] \ No newline at end of file diff --git a/ui/package.json b/ui/package.json index 7171132f..0fbd3ae1 100644 --- a/ui/package.json +++ b/ui/package.json @@ -20,6 +20,8 @@ }, "type": "module", "dependencies": { + "@sveltejs/adapter-node": "^5.0.1", + "@sveltejs/adapter-static": "^3.0.1", "clsx": "^2.1.0", "xterm": "^5.3.0", "xterm-addon-fit": "^0.8.0" diff --git a/ui/static/index.html b/ui/static/index.html deleted file mode 100644 index 2e43b702..00000000 --- a/ui/static/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - Devika AI - - - - -
- - \ No newline at end of file diff --git a/ui/svelte.config.js b/ui/svelte.config.js index 4df404aa..5e4d0abc 100644 --- a/ui/svelte.config.js +++ b/ui/svelte.config.js @@ -1,5 +1,6 @@ +import adapter from "@sveltejs/adapter-node"; import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; -import adapter from "@sveltejs/adapter-auto"; + /** @type {import('@sveltejs/kit').Config} */ const config = { From 4c0512685e7a94ec39d6fa883cd0d4e0510dea40 Mon Sep 17 00:00:00 2001 From: rajakumar05032000 Date: Sun, 31 Mar 2024 15:45:10 +0530 Subject: [PATCH 2/2] Fix - Added npm install --- app.dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/app.dockerfile b/app.dockerfile index 6f7bfb68..8b5817ac 100644 --- a/app.dockerfile +++ b/app.dockerfile @@ -11,6 +11,7 @@ copy ui /home/nonroot/client # Change Work directory WORKDIR /home/nonroot/client +RUN npm install # Building APP bundle RUN npm run build