Added dockerfile and dockerignore for backend.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
# Base image
|
||||
FROM node:22
|
||||
|
||||
# Metadata
|
||||
LABEL maintainer="kshitijka"
|
||||
LABEL version=1.1.0
|
||||
LABEL description="Crop Compass is a centralized management dashboard designed for farmers, enabling them to efficiently oversee their farms while leveraging advanced AI technology for disease identification and more."
|
||||
|
||||
# Update and upgrade
|
||||
RUN apt update && apt upgrade -y && \
|
||||
apt clean all && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create non-root user
|
||||
RUN useradd -s /bin/bash nonroot
|
||||
|
||||
# Create working directory
|
||||
RUN mkdir -p /app
|
||||
RUN chown -R nonroot:nonroot /app
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
|
||||
# Generate a random hex token and write it to .env
|
||||
RUN echo "REFRESH_TOKEN_SECRET=$(openssl rand -hex 32)" >> /app/.env
|
||||
RUN npm install
|
||||
|
||||
# Switch user
|
||||
USER nonroot
|
||||
|
||||
# Expose backend port
|
||||
EXPOSE 8000
|
||||
|
||||
# Run backend
|
||||
CMD ["node", "index.js"]
|
||||
Reference in New Issue
Block a user