Dev-Container, README und erste Demo

main
Teena Steger 2026-09-11 13:35:19 +02:00
commit 00b988bf63
6 changed files with 169 additions and 0 deletions

View File

@ -0,0 +1,4 @@
POSTGRES_USER=devuser
POSTGRES_PASSWORD=devpass
POSTGRES_DB=devdb
POSTGRES_HOSTNAME=localhost

View File

@ -0,0 +1,11 @@
FROM mcr.microsoft.com/devcontainers/go:1.27-trixie
# PostgreSQL-Client installieren
RUN apt-get update && apt-get install -y postgresql-client \
&& rm -rf /var/lib/apt/lists/*
# Node.js 24 (LTS) installieren – ohne Yarn-Repo
RUN curl -fsSL https://deb.nodesource.com/setup_24.x | sed '/yarnpkg/d' | bash - \
&& apt-get update \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*

View File

@ -0,0 +1,32 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/go-postgres
{
"name": "Go & PostgreSQL",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Configure tool-specific properties.
"customizations": {
"vscode": {
"settings": {
"extensions.autoCheckUpdates": false,
"extensions.autoUpdate": false
},
"extensions": [
"ms-vscode.live-server",
"42Crunch.vscode-openapi",
"ms-ossdata.vscode-pgsql"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
5432
],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "go version"
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

View File

@ -0,0 +1,27 @@
volumes:
postgres-data:
services:
app:
build:
context: .
dockerfile: Dockerfile
env_file:
- .env
volumes:
- ../..:/workspaces:cached
# Overrides default command so things don't shut down after the process ends.
command: sleep infinity
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:db
db:
image: postgres:17
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
env_file:
- .env

85
README.md 100644
View File

@ -0,0 +1,85 @@
# Entwicklungsumgebung mit VS Code, Docker und Dev Containers
Diese Anleitung beschreibt die Schritte zur Installation von Visual Studio Code, Docker und der Dev-Container-Erweiterung.
---
## 1. Visual Studio Code installieren
**Download:** [https://code.visualstudio.com/](https://code.visualstudio.com/)
**Schritte:**
1. Webseite öffnen.
2. Betriebssystem auswählen.
3. Installationsdatei herunterladen.
4. Installation ausführen.
5. VS Code starten.
---
## 2. Docker installieren
**Download:** [https://www.docker.com/products/docker-desktop](https://www.docker.com/products/docker-desktop)
**Schritte:**
1. Webseite öffnen.
2. Betriebssystem auswählen.
3. Docker Desktop herunterladen.
4. Installation ausführen.
5. Docker starten.
6. Überprüfen in Terminal oder Kommandozeile mit:
```bash
docker --version
```
---
## 3. Dev-Container-Erweiterung installieren
**Schritte:**
1. VS Code öffnen.
2. Erweiterungsansicht (_Extensions_) öffnen (`Strg+Shift+X`).
3. Nach **"Dev Containers"** suchen.
4. Erweiterung von Microsoft installieren.
---
<!-- ## 4. Funktionstest
**Beispielprojekt öffnen:**
1. VS Code starten.
2. Befehlspalette öffnen (`Strg+Shift+P`).
3. Befehl eingeben:
```
Dev Containers: Clone Repository in Container Volume
```
4. Beispiel-Repository auswählen.
5. Projekt wird im Container geöffnet. -->
## 4. Dev-Container starten
**Entwicklungsumgebung in Dev-Container öffnen:**
1. Repository aus Gitty lokal klonen, z. B. über Terminal oder Git-Client.
```bash
git clone https://gitty.informatik.th-mannheim.de/WEB-IB-WS2627/development-ib.git
```
2. VS Code starten.
3. Den geklonten Projektordner über „Datei → Ordner öffnen…“ auswählen.
4. Befehlspalette öffnen (`Strg+Shift+P`).
5. Folgenden Befehl eingeben:
```
Dev Containers: Open Folder in Container...
```
6. Die Container-Umgebung wird automatisch erkannt und gestartet.
7. Das Projekt öffnet sich im Container und ist einsatzbereit.
---
## Hinweise
- Docker muss aktiv sein, bevor VS Code mit Containern arbeitet.
- Bei Problemen: VS Code und Docker neu starten.
- Weitere Informationen:
- [VS Code Dokumentation](https://code.visualstudio.com/docs)
- [Docker Dokumentation](https://docs.docker.com/)
- [Dev Containers](https://containers.dev/)

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Willkommen zu WEB</title>
</head>
<body>
Hallo Web-Kurs!
</body>
</html>