No longer generating refresh token while building the container. Also switching to nonroot user before copying files and installing dependencies.

This commit is contained in:
K
2025-07-23 17:24:13 +05:30
parent e7ae4c93b1
commit 2957930be4
+11 -7
View File
@@ -14,18 +14,22 @@ RUN apt update && apt upgrade -y && \
RUN useradd -s /bin/bash nonroot
# Create working directory
RUN mkdir -p /app
RUN chown -R nonroot:nonroot /app
RUN mkdir -p /app /home/nonroot
RUN chown -R nonroot:nonroot /app /home/nonroot
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
# Copy contents
COPY . .
# Generate a random hex token and write it to .env
#RUN echo "REFRESH_TOKEN_SECRET = $(openssl rand -hex 32)" >> /app/.env
# Install dependencies
RUN npm install
# Expose backend port
EXPOSE 8000