Deploying node.js app to CapRover

  1. Request an app token and app name from @kuba-orlik. Store them in a safe location, as if they leak, anyone can override your app!
  2. Ensure your app is a part of a git repository, commit all the latest changes.
  3. install the caprover CLI: npm install -g caprover
  4. Add a captain-definition file within the root of your project:
{
  "schemaVersion": 2,
  "templateId": "node/20"
}
  1. Commit that file to the repository

  2. Run the following command:

caprover deploy --caproverUrl=https://captain.cap.sealcode.org --appToken=<app_token> --appName=<app_name>

Replace <app_token> and <app_name> with the token and app name from step 1.

If your app requires a build step (it uses TypeScript, for example), use this captain-definition:

{
	"schemaVersion": 2,
	"dockerfileLines": [
		"FROM node:20-alpine",
		"RUN mkdir -p /usr/src/app",
		"WORKDIR /usr/src/app",
		"COPY ./ /usr/src/app",
		"RUN npm install && npm cache clean --force && npm run build",
		"ENV NODE_ENV production",
		"ENV PORT 80",
		"EXPOSE 80",
		"CMD [ \"npm\", \"start\" ]"
	]
}

If your app depends on playwright, you can use this image captain-definition:

{
	"schemaVersion": 2,
	"dockerfileLines": [
		"FROM node:18-bullseye-slim",
		"RUN apt-get update&& apt-get install -y --no-install-recommends libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libcairo2 libcups2 libdbus-1-3 libdrm2 libgbm1 libglib2.0-0 libnspr4 libnss3 libpango-1.0-0 libwayland-client0 libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 xvfb fonts-noto-color-emoji fonts-unifont libfontconfig1 libfreetype6 xfonts-cyrillic xfonts-scalable fonts-liberation fonts-ipafont-gothic fonts-wqy-zenhei fonts-tlwg-loma-otf fonts-freefont-ttf libcairo-gobject2 libdbus-glib-1-2 libgdk-pixbuf-2.0-0 libgtk-3-0 libharfbuzz0b libpangocairo-1.0-0 libx11-xcb1 libxcb-shm0 libxcursor1 libxi6 libxrender1 libxtst6 gstreamer1.0-libav gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good libegl1 libenchant-2-2 libepoxy0 libevdev2 libgles2 libglx0 libgstreamer-gl1.0-0 libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 libgudev-1.0-0 libharfbuzz-icu0 libhyphen0 libicu67 libjpeg62-turbo liblcms2-2 libmanette-0.2-0 libnotify4 libopengl0 libopenjp2-7 libopus0 libpng16-16 libproxy1v5 libsecret-1-0 libsoup2.4-1 libwayland-egl1 libwayland-server0 libwebp6 libwebpdemux2 libwoff1 libxml2 libxslt1.1 libatomic1 libevent-2.1-7",
		"RUN mkdir -p /usr/src/app",
		"WORKDIR /usr/src/app",
		"COPY ./ /usr/src/app",
		"RUN npm install && npm cache clean --force && npm run build && npx playwright install",
		"ENV NODE_ENV production",
		"ENV PORT 80",
		"EXPOSE 80",
		"CMD [ \"npm\", \"start\" ]"
	]
}