Skip to content

Commit c077a99

Browse files
committed
Update Dockerfile to work with monorepo
1 parent 48ca0f2 commit c077a99

File tree

3 files changed

+38
-32
lines changed

3 files changed

+38
-32
lines changed

.dockerignore

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

apps/sandbox-container/Dockerfile

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
# Use an official Ubuntu as a base image
2-
FROM ubuntu:20.04
1+
###
2+
# STAGE: BASE
3+
###
4+
FROM node:22 AS base
35

46
# Set non-interactive mode to avoid prompts during package installation
57
ARG DEBIAN_FRONTEND=noninteractive
68

9+
# Setup pnpm
10+
ENV PNPM_HOME="/pnpm"
11+
ENV PATH="$PNPM_HOME:$PATH"
12+
RUN corepack enable
13+
714
# Use bash for the shell
815
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
916

1017
# Update and install useful CLI utilities
11-
RUN apt-get update && apt-get install -y \
12-
curl \
18+
RUN apt-get update && apt-get install -y curl ca-certificates \
1319
git \
1420
htop \
1521
vim \
@@ -18,42 +24,36 @@ RUN apt-get update && apt-get install -y \
1824
build-essential \
1925
nmap \
2026
sudo \
21-
ca-certificates \
2227
lsb-release \
2328
nodejs \
24-
npm \
2529
python3 \
2630
python3-pip \
31+
python3-matplotlib \
32+
python3-numpy \
33+
python3-pandas \
2734
&& apt-get clean
2835

29-
RUN pip3 install matplotlib numpy pandas
30-
31-
# Install Node.js and Corepack
32-
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
33-
&& apt-get install -y nodejs \
34-
&& corepack enable
36+
###
37+
# STAGE: PRUNE - Generate a partial monorepo for the sandbox-container app. The output will be placed into a directory named "out"
38+
###
39+
FROM base AS prune
40+
WORKDIR /app
41+
RUN pnpm install turbo --global
42+
COPY . .
43+
RUN turbo prune containers-starter
44+
45+
###
46+
# STAGE: INSTALL & RUN
47+
###
48+
FROM base AS installer
49+
WORKDIR /app
3550

36-
# ENV NODE_VERSION 22.14.0
51+
COPY --from=prune /app/out/ .
52+
RUN pnpm install --frozen-lockfile
3753

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
43-
44-
# Set working directory
45-
WORKDIR /app
54+
WORKDIR /app/apps/sandbox-container
4655

4756
# Expose the port your Node.js server will run on
4857
EXPOSE 8080
4958

50-
COPY . ./
51-
52-
RUN npm i
53-
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
57-
58-
# Default command (run your Node.js server here)
59-
CMD ["npm", "run", "start:container"]
59+
CMD ["pnpm", "run", "start:container"]

apps/sandbox-container/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"check:types": "run-tsc",
88
"deploy": "wrangler deploy",
99
"dev": "concurrently \"tsx container/index.ts\" \"wrangler dev --var \"ENVIRONMENT:dev\"\"",
10-
"build": "docker build .",
10+
"build": "docker build -f Dockerfile ../../",
1111
"start": "wrangler dev",
1212
"start:container": "tsx container/index.ts",
1313
"postinstall": "mkdir -p workdir",

0 commit comments

Comments
 (0)