1- # Use an official Ubuntu as a base image
2- FROM ubuntu:20.04
3-
1+ FROM ubuntu:20.04 AS base
42# Set non-interactive mode to avoid prompts during package installation
53ARG DEBIAN_FRONTEND=noninteractive
64
7- # Use bash for the shell
8- SHELL ["/bin/bash" , "-o" , "pipefail" , "-c" ]
9-
10- # Update and install useful CLI utilities
11- RUN apt-get update && apt-get install -y \
12- curl \
13- git \
14- htop \
15- vim \
16- wget \
17- net-tools \
18- build-essential \
19- nmap \
20- sudo \
21- ca-certificates \
22- lsb-release \
23- nodejs \
24- npm \
25- python3 \
26- python3-pip \
27- && apt-get clean
28-
29- RUN pip3 install matplotlib numpy pandas
30-
31- # Install Node.js and Corepack
5+ # STAGE: Generate a partial monorepo for a target package. The output will be placed into a directory named "out"
6+ FROM base AS prune
7+ RUN apt-get update && apt-get install -y npm build-essential
328RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
33- && apt-get install -y nodejs \
34- && corepack enable
9+ && apt-get install -y nodejs
3510
36- # ENV NODE_VERSION 22.14.0
11+ WORKDIR /app
12+ RUN npm install turbo --global
13+ COPY . .
14+ RUN turbo prune containers-starter --docker
3715
38- # Download and install nvm
39- # RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | PROFILE="${BASH_ENV}" bash
40- # RUN echo node > .nvmrc
41- # RUN nvm install $NODE_VERSION
42- # RUN nvm use $NODE_VERSION
16+ # STAGE: Install Production dependencies
17+ FROM base AS installer-production
4318
44- # Set working directory
4519WORKDIR /app
20+ # /out/json contains the package.json file that is used to install packages related to sandbox-container
21+ COPY --from=prune /app/out/json/ .
4622
47- # Expose the port your Node.js server will run on
48- EXPOSE 8080
23+ RUN npm install --only=production
4924
50- COPY . ./
25+ # STAGE: Runner
26+ FROM base AS runner
27+ WORKDIR /app
5128
52- RUN npm i
29+ COPY --from=installer-production /app/node_modules /app/node_modules
30+ COPY --from=prune /app/out/json/ .
31+ COPY --from=prune /app/out/full .
5332
54- # add node and npm to path so the commands are available
55- # ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
56- # ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
33+ WORKDIR /app/apps/sandbox-container
5734
58- # Default command (run your Node.js server here)
59- CMD ["npm" , "run" , "start:container" ]
35+ CMD ["npm" , "run" , "start" ]
0 commit comments