Complete Node.js container implementation with multi-version support
- Add Dockerfile with AlmaLinux 9 base, Nginx reverse proxy, and PM2 - Support Node.js versions 18, 20, 22 with automated installation - Implement memory-optimized configuration (256MB minimum, 512MB recommended) - Add Memcached session storage for development environments - Create comprehensive documentation (README, USER-GUIDE, MEMORY-GUIDE, CLAUDE.md) - Include example applications (simple website and REST API) - Add Gitea CI/CD pipeline for automated multi-version builds - Provide local development script with helper utilities - Implement health monitoring, log rotation, and backup systems 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
41
Dockerfile
Normal file
41
Dockerfile
Normal file
@@ -0,0 +1,41 @@
|
||||
FROM almalinux/9-base
|
||||
ARG NODEVER=20
|
||||
|
||||
# Install repos, update, install only needed packages, clean up in one layer
|
||||
RUN dnf install -y \
|
||||
https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
|
||||
dnf update -y && \
|
||||
dnf install -y wget procps cronie iproute nginx openssl curl && \
|
||||
dnf clean all && \
|
||||
rm -rf /var/cache/dnf /usr/share/doc /usr/share/man /usr/share/locale/* \
|
||||
/var/cache/yum /tmp/* /var/tmp/*
|
||||
|
||||
# Copy scripts into the image and set permissions
|
||||
COPY ./scripts/ /scripts/
|
||||
RUN chmod +x /scripts/*
|
||||
|
||||
# Generate self-signed cert, create needed dirs, install Node.js, clean up
|
||||
RUN openssl req -newkey rsa:2048 -nodes -keyout /etc/pki/tls/private/localhost.key -x509 -days 3650 -subj "/CN=localhost" -out /etc/pki/tls/certs/localhost.crt && \
|
||||
mkdir -p /var/log/nodejs && \
|
||||
/scripts/install-node$NODEVER.sh && \
|
||||
rm -rf /tmp/*
|
||||
|
||||
# Install PM2 globally for process management with minimal footprint
|
||||
RUN npm install -g pm2@latest --production && \
|
||||
npm cache clean --force && \
|
||||
rm -rf /tmp/*
|
||||
|
||||
# Copy configs and web files
|
||||
COPY ./configs/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY ./configs/default.conf /etc/nginx/conf.d/default.conf
|
||||
COPY ./configs/index.js /var/www/html/
|
||||
COPY ./configs/package.json /var/www/html/
|
||||
COPY ./configs/ecosystem.config.js /var/www/html/
|
||||
|
||||
# Set up cron job for log rotation
|
||||
RUN echo "15 */12 * * * root /scripts/log-rotate.sh" >> /etc/crontab
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
|
||||
CMD curl -f http://localhost:3000/ping || exit 1
|
||||
|
||||
ENTRYPOINT [ "/scripts/entrypoint.sh" ]
|
Reference in New Issue
Block a user