Development Containers (CAP): Unterschied zwischen den Versionen
Matt (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Matt (Diskussion | Beiträge) |
||
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
This article describes approaches for developing of SAP Cloud Application Programming Model (CAP) by utilizing development containers. | This article describes approaches for developing of SAP Cloud Application Programming Model (CAP) by utilizing development containers. | ||
There are two major container an | |||
== Docker Desktop == | == Docker Desktop == | ||
Zeile 9: | Zeile 11: | ||
It requires a local installation of Docker Desktop. | It requires a local installation of Docker Desktop. | ||
=== Configuration === | === Configuration of Development Repository === | ||
Create a subfolder .devcontainer with the following files | Create a subfolder .devcontainer with the following files | ||
.devcontainer | .devcontainer | ||
Zeile 50: | Zeile 52: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== VSCode Extensions === | |||
Install VSCode Extension "Dev Containers". | |||
When opening a repository directory in VSCode, a bubble message should appear providing the options to reopen the directory within the docker container or even to clone it in the docker container. | |||
The local VSCode installation then only acts as a client and a server part will be deployed and runs on the docker, to which the VSCode connects as a client. | |||
== WSL2 / Windows Subsystem for Linux == | == WSL2 / Windows Subsystem for Linux == | ||
For installation and management of WSL see [[Windows Subsystem For Linux (WSL)]] | For installation and management of WSL see [[Windows Subsystem For Linux (WSL)]] | ||
=== Developing on WSL with Node.js === | |||
The following approach for utilizing WSL as a container environment for developing node.js is based on the following article: https://learn.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-wsl | |||
Install curl: | |||
sudo apt-get install curl | |||
Install nvm, with: | |||
curl -o- <nowiki>https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh</nowiki> | bash | |||
Verify installation, enter: | |||
command -v nvm | |||
The response should be "nvm". If there is no response or an error, then restart the WSL. | |||
Install Node LTS: | |||
nvm install --lts | |||
List installed Node versions: | |||
nvm ls | |||
Check installed versions: | |||
node --version | |||
npm --version | |||
You can also use the which commant to see the path used for the default versions: | |||
which node | |||
which npm | |||
=== VSCode Extensions === | |||
Install VSCode Extension "Remote Development Extension Pack", which contains the following extensions: | |||
* Dev Containers | |||
* Remote - SSH | |||
* WSL | |||
* Remote - Tunnels | |||
The local VSCode installation then only acts as a client and a server part will be deployed and runs on the docker, to which the VSCode connects as a client. | |||
[[Kategorie:Development]] | [[Kategorie:Development]] | ||
[[Kategorie:SAP]] | [[Kategorie:SAP]] | ||
[[Kategorie:JavaScript]] | [[Kategorie:JavaScript]] |
Aktuelle Version vom 18. August 2024, 19:10 Uhr
This article describes approaches for developing of SAP Cloud Application Programming Model (CAP) by utilizing development containers.
There are two major container an
Docker Desktop
This following approach is based on:
- https://containers.dev/
- https://qmacro.org/blog/posts/2024/01/15/developing-cap-in-containers-three-ways/
It requires a local installation of Docker Desktop.
Configuration of Development Repository
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"
}
VSCode Extensions
Install VSCode Extension "Dev Containers".
When opening a repository directory in VSCode, a bubble message should appear providing the options to reopen the directory within the docker container or even to clone it in the docker container.
The local VSCode installation then only acts as a client and a server part will be deployed and runs on the docker, to which the VSCode connects as a client.
WSL2 / Windows Subsystem for Linux
For installation and management of WSL see Windows Subsystem For Linux (WSL)
Developing on WSL with Node.js
The following approach for utilizing WSL as a container environment for developing node.js is based on the following article: https://learn.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-wsl
Install curl:
sudo apt-get install curl
Install nvm, with:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
Verify installation, enter:
command -v nvm
The response should be "nvm". If there is no response or an error, then restart the WSL.
Install Node LTS:
nvm install --lts
List installed Node versions:
nvm ls
Check installed versions:
node --version npm --version
You can also use the which commant to see the path used for the default versions:
which node which npm
VSCode Extensions
Install VSCode Extension "Remote Development Extension Pack", which contains the following extensions:
- Dev Containers
- Remote - SSH
- WSL
- Remote - Tunnels
The local VSCode installation then only acts as a client and a server part will be deployed and runs on the docker, to which the VSCode connects as a client.