TerminalDocker / Dockerfile
clone3's picture
Update Dockerfile
3e238cf verified
raw
history blame
892 Bytes
# Use Node.js 18 base image
FROM node:18
# Set environment variables for user and password
ENV USER=myuser
ENV PASSWORD=mypassword
# Set the working directory inside the container
WORKDIR /app
# Create a non-root user to run the application
RUN useradd --create-home --shell /bin/bash appuser
# Clone the repository
RUN git clone https://github.com/ChrisCindy/node-web-console.git .
# Change ownership of the directory to the non-root user
RUN chown -R appuser:appuser /app
# Switch to the non-root user
USER appuser
# Install dependencies
RUN npm install
# Copy entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/
# Make the script executable
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Expose the port the app runs on
EXPOSE 3000
# Run the entrypoint script and start the web server in production mode
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["npm", "run", "prod"]