Development Containers (CAP)

Aus MattWiki

This article describes approaches for developing of SAP Cloud Application Programming Model (CAP) by utilizing development containers.

Docker Desktop

This following approach is based on:

It requires a local installation of Docker Desktop.

Configuration

Create a subfolder .devcontainer with the following files

.devcontainer
|-- Dockerfile
`-- devcontainer.json

Contents of Dockerfile:

# syntax=docker/dockerfile:1

ARG VARIANT="20"
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}

# Install some generally useful tools
RUN apt-get update && apt-get -y install --no-install-recommends curl git sqlite3

# Install SAP CAP SDK globally
USER node
RUN npm install -g @sap/cds-dk
WORKDIR /home/node

Contents of devcontainer.json

{
  "name": "Portfolio Manager",
  "build": {
    "dockerfile": "Dockerfile",
    "args": { "VARIANT": "20" }
  },
  "customizations": {
    "vscode": {
      "extensions": [
        "sapse.vscode-cds",
        "dbaeumer.vscode-eslint",
        "humao.rest-client",
        "qwtel.sqlite-viewer",
        "mechatroner.rainbow-csv"
      ]
    }
  },
  "forwardPorts": [ 4004 ],
  "remoteUser": "node"
}

WSL2 / Windows Subsystem for Linux

For installation and management of WSL see Windows Subsystem For Linux (WSL)