File size: 1,371 Bytes
a59ab77
eb371f4
ec1f352
a59ab77
 
 
 
eb371f4
662cf6b
a59ab77
 
 
 
987ef9f
 
 
 
0f22f9c
 
 
 
662cf6b
36b43cd
1b8729a
662cf6b
a59ab77
 
 
7684b00
36b43cd
 
 
5f37610
 
 
a59ab77
5297d52
ec1f352
a59ab77
f03fd7f
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
# Base image
FROM python:3.11-slim-bullseye AS final

# Use bash as default shell
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Install dependencies
RUN apt-get update && apt-get install -y curl bash git && rm -rf /var/lib/apt/lists/*

# Set environment variables for NVM
ENV NVM_DIR="/home/user/.nvm"
ENV PATH="${NVM_DIR}/versions/node/$(ls ${NVM_DIR}/versions/node)/bin:$PATH"

# Create NVM directory and install NVM
RUN mkdir -p $NVM_DIR && \
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# Persist NVM configuration
RUN echo 'export NVM_DIR="$HOME/.nvm"' >> /etc/profile.d/nvm.sh && \
    echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"' >> /etc/profile.d/nvm.sh && \
    echo '[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"' >> /etc/profile.d/nvm.sh

# Install Node.js using NVM
RUN bash -c "source $NVM_DIR/nvm.sh && nvm install --lts && nvm use --lts && node -v && npm -v"

# Set working directory
WORKDIR /app
COPY . /app

# Ensure Node.js dependencies (including dotenv) are installed
RUN bash -c "source $NVM_DIR/nvm.sh && npm install"

# Install Python dependencies (including Uvicorn)
RUN pip install --no-cache-dir --upgrade pip && pip install uvicorn fastapi

# Expose ports
EXPOSE 7860

# Run both Node.js & Python servers
CMD ["/bin/bash", "-c", "source $NVM_DIR/nvm.sh && node server.js"]