added devcontainer with all tools for frontent (deno, nextjs) and backend (dart, go)

This commit is contained in:
2024-12-31 11:37:30 +00:00
parent b568907b65
commit e3a2b09ef4
24 changed files with 288 additions and 116 deletions
+64
View File
@@ -0,0 +1,64 @@
# Verwende das TypeScript-Node-Image als Basis
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-20 AS base
ARG DART_VERSION=3.6.0-1
ARG GO_VERSION=1.21.0
# Definiere den Benutzername als Argument (Standard: vscode)
ARG USERNAME=vscode
ARG USER_UID=1001
ARG USER_GID=1001
# Installiere Dart
RUN apt-get update && apt-get install -y wget gnupg \
&& wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /usr/share/keyrings/dart.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/dart.gpg] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main" > /etc/apt/sources.list.d/dart_stable.list \
&& apt-get update && apt-get install -y dart=${DART_VERSION}
# Erstelle den Benutzer dynamisch, falls er nicht existiert
RUN if ! getent group $USER_GID > /dev/null; then groupadd --gid $USER_GID $USERNAME; fi \
&& if ! id -u $USERNAME > /dev/null 2>&1; then useradd --uid $USER_UID --gid $USER_GID -m $USERNAME; fi \
&& echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
# Installiere Go
RUN wget https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz \
&& tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz \
&& rm go${GO_VERSION}.linux-amd64.tar.gz \
&& echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile
# Installiere Fish-Shell und Oh My Fish (OMF)
RUN apt-get update && apt-get install -y fish git curl \
&& curl -L https://get.oh-my.fish | fish
# Setze Fish als Standardshell
RUN chsh -s /usr/bin/fish ${USERNAME} || echo "User ${USERNAME} not found; skipping chsh"
# Installiere das bobthefish Theme und Plugins
RUN fish -c "omf install bobthefish" \
&& fish -c "omf install bang-bang pj z"
# Optional: Konfiguration von bobthefish
RUN echo "set -g theme_nerd_fonts yes" >> ~/.config/fish/config.fish \
&& echo "set -g theme_display_git_untracked_files no" >> ~/.config/fish/config.fish
# Installiere Deno
ENV DENO_INSTALL=/deno
RUN mkdir -p /deno \
&& curl -fsSL https://deno.land/x/install/install.sh | sh \
&& chown -R vscode /deno
ENV PATH=${DENO_INSTALL}/bin:/usr/local/go/bin:${PATH} \
DENO_DIR=${DENO_INSTALL}/.cache/deno
RUN groupadd -r docker && usermod -aG docker $USERNAME
# Definiere den Arbeitsbereich
WORKDIR /workspace
# Zusätzliche Pakete installieren
RUN apt-get update && apt-get install -y protobuf-compiler
# Ports für React und Dart Services
EXPOSE 3000 8080 4000
+36
View File
@@ -0,0 +1,36 @@
{
"name": "ws24-kp-avril",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
"USERNAME": "vscode",
"USER_UID": "1001",
"USER_GID": "1001"
}
},
"settings": {
"terminal.integrated.defaultProfile.linux": "fish"
},
"extensions": [
"ms-azuretools.vscode-docker",
"ms-vscode.vscode-typescript-next",
"dart-code.dart-code",
"golang.go",
"denoland.vscode-deno"
],
"features": {
//"docker-in-docker": "latest",
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
},
"runArgs": ["--add-host=host.docker.internal:host-gateway"],
"postCreateCommand": "./.devcontainer/setup.sh",
"remoteUser": "vscode",
"updateRemoteUserUID": true,
"mounts": [
"type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock",
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached"
//"source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached"
]
}
+34
View File
@@ -0,0 +1,34 @@
#!/bin/bash
# Frontend setup
if [ -d "frontend-react" ]; then
echo "Setting up frontend-react..."
cd frontend-react
#npm install
deno install --allow-scripts
cd ..
else
echo "frontend-react directory not found, skipping..."
fi
# Dart backend setup
if [ -d "backend_dart" ]; then
echo "Setting up backend_dart..."
cd backend_dart
dart pub get
cd ..
else
echo "backend_dart directory not found, skipping..."
fi
# Go backend setup
if [ -d "backend-go" ]; then
echo "Setting up backend-go..."
cd backend-go
go mod tidy
cd ..
else
echo "backend-go directory not found, skipping..."
fi
#chmod 600 /home/vscode/.ssh/* # && git config --global user.name 'Jean Avril' && git config --global user.email 'jean@jeanavril.com'