Backend and model uri are now passed in Dockerfile since the frontend is build within the docker container and served using serve. May add commands to clean up folders later.
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
dist/
|
||||||
|
Dockerfile
|
||||||
|
node_modules/
|
||||||
|
package-lock.json
|
||||||
|
README.md
|
||||||
|
vercel.json
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
VITE_API_URL=http://localhost:8000
|
VITE_API_URL = http://localhost:8000
|
||||||
|
|||||||
+12
-4
@@ -1,6 +1,10 @@
|
|||||||
# Base image
|
# Base image
|
||||||
FROM node:22
|
FROM node:22
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
ENV MODEL_URI=<set_model_uri_here>
|
||||||
|
ENV BACKEND_URI=<set_backend_uri_here>
|
||||||
|
|
||||||
# Metadata
|
# Metadata
|
||||||
LABEL maintainer="kshitijka"
|
LABEL maintainer="kshitijka"
|
||||||
LABEL version=1.1.0
|
LABEL version=1.1.0
|
||||||
@@ -8,8 +12,7 @@ LABEL description="Crop Compass is a centralized management dashboard designed f
|
|||||||
|
|
||||||
# Update and upgrade
|
# Update and upgrade
|
||||||
RUN apt update && apt upgrade -y && \
|
RUN apt update && apt upgrade -y && \
|
||||||
apt clean all && \
|
apt clean all && rm -rf /var/lib/apt/lists/*
|
||||||
rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Create non-root user
|
# Create non-root user
|
||||||
RUN useradd -s /bin/bash nonroot
|
RUN useradd -s /bin/bash nonroot
|
||||||
@@ -18,7 +21,12 @@ RUN useradd -s /bin/bash nonroot
|
|||||||
RUN mkdir -p /app
|
RUN mkdir -p /app
|
||||||
RUN chown -R nonroot:nonroot /app
|
RUN chown -R nonroot:nonroot /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY dist/ .
|
COPY . .
|
||||||
|
RUN echo $BACKEND_URI > /app/.env
|
||||||
|
|
||||||
|
# Building frontend
|
||||||
|
RUN npm install
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
# Install server
|
# Install server
|
||||||
RUN npm install -g serve
|
RUN npm install -g serve
|
||||||
@@ -30,4 +38,4 @@ USER nonroot
|
|||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# Run frontend
|
# Run frontend
|
||||||
CMD ["serve", "-s", "/app"]
|
CMD ["serve", "-s", "/app/dist"]
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const Ai = () => {
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("image", selectedFile);
|
formData.append("image", selectedFile);
|
||||||
|
|
||||||
const response = await fetch("http://model:8081/predict", {
|
const response = await fetch("${MODEL_URI}/predict", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: formData,
|
body: formData,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user