Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - optimized UI dockerfile and removed unnecessary index.html file & Reduce docker image size from 1.4 GB to 176MB #276

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 19 additions & 19 deletions app.dockerfile
@@ -1,29 +1,29 @@
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 -y
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
RUN npm install
# 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" ]
# RUN APP
CMD ["index.js"]
2 changes: 2 additions & 0 deletions ui/package.json
Expand Up @@ -20,6 +20,8 @@
},
"type": "module",
"dependencies": {
"@sveltejs/adapter-node": "^5.0.1",
"@sveltejs/adapter-static": "^3.0.1",
"socket.io-client": "^4.7.5",
"clsx": "^2.1.0",
"xterm": "^5.3.0",
Expand Down
13 changes: 0 additions & 13 deletions ui/static/index.html

This file was deleted.

3 changes: 2 additions & 1 deletion 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 = {
Expand Down