diff --git a/Dockerfile b/Dockerfile index 721ae7c..89417e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,29 @@ # LTS version of Node.js FROM node:20.9.0-alpine +# Create a new user and group for running the application +RUN addgroup -S appgroup && adduser -S appuser -G appgroup + RUN mkdir -p /app WORKDIR /app COPY package*.json ./ -RUN npm install +# Change ownership of the app directory +RUN chown -R appuser:appgroup /app + +# Install npm dependencies as the non-root user +USER appuser + +# Clear npm cache and install dependencies +RUN npm cache clean --force && npm install -COPY . . +# Copy the rest of the application code +COPY --chown=appuser:appgroup . . RUN npm run build EXPOSE 3000 -# Start the app on port 4455 as recommended by ory CMD ["npm", "start", "--", "-p", "3000"]