json-cho's picture
initial commit
d10a61a
# Base image with Node.js 20.13.1 and Python
FROM node:20.13.1 AS builder
ENV HOME=/home/node \
PATH=/home/node/.local/bin:$PATH
WORKDIR $HOME/app
# Install Nginx
RUN apt-get update && apt-get install -y nginx
# Remove the default Nginx config
RUN rm /etc/nginx/sites-enabled/default
# Copy your custom Nginx configuration file into the container
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Install pnpm globally
RUN corepack enable && corepack prepare [email protected] --activate
# Install dependencies
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
# Copy the rest of the app and build
COPY --chown=node . $HOME/app
RUN pnpm build
# Install Python dependencies
FROM python:3.10 AS python
ENV HOME=/home/node \
PATH=/home/node/.local/bin:$PATH
WORKDIR $HOME/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# Final container with both Node.js and Python
FROM node:20.13.1
ENV HOME=/home/node \
PATH=/home/node/.local/bin:$PATH
WORKDIR $HOME/app
RUN apt-get update && apt-get install -y \
supervisor \
nginx \
python3.10 \
python3-pip \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
COPY requirements.txt ./
RUN pip install --no-cache-dir --break-system-packages -r requirements.txt
# Install pnpm globally
RUN corepack enable && corepack prepare [email protected] --activate
# Remove the default Nginx config
RUN rm /etc/nginx/sites-enabled/default
# Copy your custom Nginx configuration file into the container
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy supervisor configuration
COPY --chown=node supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Copy built Next.js app from the builder stage and Python dependencies
COPY --chown=node --from=builder $HOME/app .
COPY --chown=node --from=python $HOME/app .
# Expose the port the app runs on
EXPOSE 7860 3000
USER node
CMD ["python3", "app.py"]