File size: 1,904 Bytes
d10a61a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# 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"]