Documentation
Container Stack

Migrating to Container Stack

Container Stack is a fully-managed platform as a service that provides container hosting for web applications.

Before you Start

You will need:

  • a container development environment (e.g. Docker Engine, Podman Desktop, Colima, etc.)
  • a TechPass account
  • a SHIP GitLab account
  • a SEED-enabled device for access to CStack resources

Remember to sign up for and onboard to Container Stack (more details here (opens in a new tab)).

Steps

Containerisation

Preparing a container image from a NextJS application template is easy.

# Dockerfile
FROM --platform=linux/amd64 node:20-alpine as builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npx next build
 
FROM --platform=linux/amd64 node:20-alpine as runner
WORKDIR /app
COPY --from=builder --chown=node:node /app/package*.json ./
RUN npm install --omit=dev
COPY --from=builder --chown=node:node /app/.next ./.next
USER node
EXPOSE 3000
CMD ["npm", "run", "start"]

Testing Containers Locally

# docker-compose.yaml
version: "3.8"
services:
  next:
    build: .
    environment:
      NEXTAUTH_SECRET: 1a
      ROOT_USERNAME: root@example.com
      ROOT_PASSWORD: hunter2
    ports:
      - "3000:3000"

Adding Container Stack manifests

More information about Container Stack and its workflow can be found here (opens in a new tab).