Skip to content

Commit 8f4b60c

Browse files
committed
test monorepo dockerfile
1 parent 7383b5c commit 8f4b60c

File tree

2 files changed

+27
-46
lines changed

2 files changed

+27
-46
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
**/node_modules/
2+
**/.gitignore
3+
**/README.md
4+
**/.vscode/
5+
**/Dockerfile

apps/sandbox-container/Dockerfile

Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,35 @@
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
53
ARG 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
328
RUN 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
4519
WORKDIR /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

Comments
 (0)