Skip to content

Update container server Dockerfile to work with monorepo #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/node_modules/
**/.gitignore
**/README.md
**/.vscode/
**/Dockerfile
**/out/
63 changes: 31 additions & 32 deletions apps/sandbox-container/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
# Use an official Ubuntu as a base image
FROM ubuntu:20.04
###
# STAGE: BASE
###
FROM node:22 AS base

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

# Setup pnpm
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

# Use bash for the shell
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Update and install useful CLI utilities
RUN apt-get update && apt-get install -y \
curl \
RUN apt-get update && apt-get install -y curl ca-certificates \
git \
htop \
vim \
Expand All @@ -18,42 +24,35 @@ RUN apt-get update && apt-get install -y \
build-essential \
nmap \
sudo \
ca-certificates \
lsb-release \
nodejs \
npm \
python3 \
python3-pip \
python3-matplotlib \
python3-numpy \
python3-pandas \
&& apt-get clean

RUN pip3 install matplotlib numpy pandas

# Install Node.js and Corepack
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs \
&& corepack enable
###
# STAGE: PRUNE - Generate a partial monorepo for the sandbox-container app. The output will be placed into a directory named "out"
###
FROM base AS prune
WORKDIR /app
RUN pnpm install turbo --global
COPY . .
RUN turbo prune containers-starter

###
# STAGE: INSTALL & RUN
###
FROM base AS installer
WORKDIR /app

# ENV NODE_VERSION 22.14.0
COPY --from=prune /app/out/ .
RUN pnpm install --frozen-lockfile

# Download and install nvm
# RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | PROFILE="${BASH_ENV}" bash
# RUN echo node > .nvmrc
# RUN nvm install $NODE_VERSION
# RUN nvm use $NODE_VERSION

# Set working directory
WORKDIR /app
WORKDIR /app/apps/sandbox-container

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

COPY . ./

RUN npm i

# add node and npm to path so the commands are available
# ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
# ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH

# Default command (run your Node.js server here)
CMD ["npm", "run", "start:container"]
CMD ["pnpm", "run", "start:container"]
2 changes: 1 addition & 1 deletion apps/sandbox-container/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"check:types": "run-tsc",
"deploy": "wrangler deploy",
"dev": "concurrently \"tsx container/index.ts\" \"wrangler dev --var \"ENVIRONMENT:dev\"\"",
"build": "docker build .",
"build": "docker build -f Dockerfile ../../",
"start": "wrangler dev",
"start:container": "tsx container/index.ts",
"postinstall": "mkdir -p workdir",
Expand Down