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:
K
2025-07-23 01:31:18 +05:30
parent 8ee1f1183c
commit 0c205270ee
4 changed files with 20 additions and 6 deletions
+12 -4
View File
@@ -1,6 +1,10 @@
# Base image
FROM node:22
# Environment variables
ENV MODEL_URI=<set_model_uri_here>
ENV BACKEND_URI=<set_backend_uri_here>
# Metadata
LABEL maintainer="kshitijka"
LABEL version=1.1.0
@@ -8,8 +12,7 @@ LABEL description="Crop Compass is a centralized management dashboard designed f
# Update and upgrade
RUN apt update && apt upgrade -y && \
apt clean all && \
rm -rf /var/lib/apt/lists/*
apt clean all && rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -s /bin/bash nonroot
@@ -18,7 +21,12 @@ RUN useradd -s /bin/bash nonroot
RUN mkdir -p /app
RUN chown -R nonroot:nonroot /app
WORKDIR /app
COPY dist/ .
COPY . .
RUN echo $BACKEND_URI > /app/.env
# Building frontend
RUN npm install
RUN npm run build
# Install server
RUN npm install -g serve
@@ -30,4 +38,4 @@ USER nonroot
EXPOSE 3000
# Run frontend
CMD ["serve", "-s", "/app"]
CMD ["serve", "-s", "/app/dist"]