Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM ubuntu:24.04

# Umgebungsvariablen setzen
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Berlin

# System-Updates und grundlegende Tools installieren
RUN apt-get update && apt-get install -y \
curl \
wget \
git \
unzip \
software-properties-common \
apt-transport-https \
ca-certificates \
gnupg \
lsb-release \
vim \
nano \
tree \
htop \
sudo \
make \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Zeitzone konfigurieren
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Erstelle einen non-root Benutzer
ARG USERNAME=vscode
ARG USER_UID=1001
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

# Shared bin Verzeichnis erstellen und Rechte setzen
RUN mkdir -p /shared/bin && chown -R $USERNAME:$USERNAME /shared/bin

# Arbeitsverzeichnis setzen
WORKDIR /workspace/plexams.go

# Benutzer wechseln
USER $USERNAME

# # Delve Debugger installieren
# RUN /usr/local/go/bin/go install github.com/go-delve/delve/cmd/dlv@latest
# ENV PATH="/home/vscode/go/bin:$PATH"

# Set GOBIN to shared volume
ENV GOBIN=/shared/bin
ENV PATH="${PATH}:/shared/bin"

# Standard-Befehl
CMD ["/bin/bash"]
74 changes: 74 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"name": "plexams-go",
"build": {
"dockerfile": "Dockerfile"
},

"features": {
"ghcr.io/devcontainers/features/go:1": {
"version": "1.25.1"
}
},

"customizations": {
"vscode": {
"extensions": [
"golang.Go",
"eamodio.gitlens",
"gruntfuggly.todo-tree",
"oderwat.indent-rainbow",
"pkief.material-icon-theme"
],
"settings": {
"go.useLanguageServer": true,
"go.lintTool": "golangci-lint-v2",
"go.lintFlags": ["--path-mode=abs", "--fast-only"],
"go.formatTool": "custom",
"go.alternateTools": {
"customFormatter": "golangci-lint-v2"
},
"go.formatFlags": ["fmt", "--stdin"],
"go.testOnSave": true,
"editor.formatOnSave": true,
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.detectIndentation": true,
"editor.rulers": [80, 120],
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true
},
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.cwd": "${workspaceFolder}"
}
}
},

"mounts": [
"source=shared-binaries,target=/shared/bin,type=volume",
"source=${localEnv:HOME}/.gitconfig,target=/home/vscode/.gitconfig,type=bind,consistency=cached",
"source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached",
"source=${localEnv:HOME}/.plexams.yml,target=/home/vscode/.plexams.yml,type=bind,consistency=cached",
"source=${localEnv:HOME}/semester,target=/home/vscode/semester,type=bind,consistency=cached"
],

"forwardPorts": [8080, 8081, 8082],
"portsAttributes": {
"8080": {
"label": "Application",
"onAutoForward": "notify"
}
},

"postCreateCommand": "sudo chown -R vscode:vscode /shared/bin && go mod download",

"remoteEnv": {
"GOBIN": "/shared/bin",
"PATH": "${containerEnv:PATH}:/shared/bin"
},

"runArgs": ["--network=host"]
}
6 changes: 5 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/mitchellh/go-homedir"
Expand Down Expand Up @@ -78,7 +79,10 @@ func initConfig() {
if semester == "" {
semester = viper.GetString("semester")
}
viper.AddConfigPath(fmt.Sprintf("%s/%s", viper.GetString("semester-path"), semester))
p := viper.GetString("semester-path")
p = os.ExpandEnv(p) // $HOME, $USER, ...
p, _ = homedir.Expand(p) // ~ und ~user
viper.AddConfigPath(filepath.Join(p, semester))
viper.SetConfigName("plexams")
err = viper.MergeInConfig()
if err != nil {
Expand Down
Loading