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
3 changes: 3 additions & 0 deletions .devcontainer/config/aliases/example.aliases.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

alias hello="echo 'Hello, world!'"
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

# Aliases for GIT shortcuts (https://laracasts.com/series/how-to-contribute-to-open-source/episodes/5)
alias wip='git add . && git commit -m '\''Work in progress'\'
alias nope='git reset --hard && git clean -f -d && git checkout HEAD'
159 changes: 119 additions & 40 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,71 @@
{
"name": "Library python-pipeline",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"name": "python-pipeline",
"build": {
"dockerfile": "docker/devcontainer/Dockerfile",
"context": ".."
},
"customizations": {
"vscode": {
"extensions": [
/**
* Common extensions
**/
"aaron-bond.better-comments",
"charliermarsh.ruff",
"DavidAnson.vscode-markdownlint",
"github.copilot",
"github.copilot-chat",
"github.vscode-github-actions",
"mikestead.dotenv",
"ms-python.debugpy",
/**
* Common file types support (highlighting, formatting, lintering, etc.)
**/
"editorconfig.editorconfig", // .editorconfig
"tamasfe.even-better-toml", // .toml
"xshrim.txt-syntax", // .txt, .log, .conf, .ini, .properties, etc.
"redhat.vscode-yaml", // .yaml, .yml
"DavidAnson.vscode-markdownlint", // .md
/**
* AI extensions
**/
"github.copilot",
"github.copilot-chat",
"chrisdias.promptboost",
/**
* Opinionated extensions (Themes, colors, etc.)
**/
"pkief.material-icon-theme", // popular icon theme
"atomiks.moonlight", // default theme for cursor
/**
* Bash script extensions - .devcontainer scripts, .sh files, etc.
**/
"mads-hartmann.bash-ide-vscode",
"rogalmic.bash-debug",
"jetmartin.bats",
"foxundermoon.shell-format",
"timonwong.shellcheck",
"jeff-hykin.better-shellscript-syntax",
/**
* Container/Docker extensions
**/
"ms-azuretools.vscode-containers",
"jeff-hykin.better-dockerfile-syntax",
"exiasr.hadolint",
/**
* Python extensions
**/
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"pkief.material-icon-theme",
"redhat.vscode-yaml",
"tamasfe.even-better-toml",
"ms-vscode.vscode-websearchforcopilot",
"ms-vscode.vscode-commander"
// "ms-python.vscode-pylance", // language server (highlighting, intellisense, etc.)
"astral-sh.ty", // language server (highlighting, intellisense, etc.)
"charliermarsh.ruff", // linter and formatter
"njpwerner.autodocstring", // docstring generator
"ms-toolsai.jupyter", // Jupyter Notebooks
"ms-python.debugpy", // debugger
/**
* Auto-applied devcontainer feature extensions (docker-outside-of-docker)
**/
"-ms-azuretools.vscode-docker" // removed, replaced by "vscode-containers"
],
"settings": {
/**
* Common settings
**/
"editor.linkedEditing": true,
"editor.formatOnSave": true,
"editor.rulers": [
Expand All @@ -32,17 +76,42 @@
"editor.guides.highlightActiveIndentation": true,
"explorer.sortOrderLexicographicOptions": "upper",
"files.insertFinalNewline": true,
"files.eol": "\n",
"files.trimTrailingWhitespace": true,
"ruff.nativeServer": "on",
"files.watcherExclude": {
"**/.git/*": true,
"**/node_modules/*": true,
"**/vendor/*": true
},
"files.associations": {
"*.zsh": "shellscript"
},
"terminal.integrated.shell.linux": "/bin/zsh",
/**
* Settings for Opinionated Extensions (themes, colors, etc.)
**/
"workbench.iconTheme": "material-icon-theme",
// Jupyter Notebook
"notebook.formatOnSave.enabled": true,
"notebook.codeActionsOnSave": {
"notebook.source.fixAll": "explicit",
"notebook.source.organizeImports": "explicit"
"workbench.colorTheme": "Moonlight",
/**
* Settings for Extensions
**/
// MkDocs
"yaml.schemas": {
"https://squidfunk.github.io/mkdocs-material/schema.json": "mkdocs.yml"
},
"yaml.customTags": [
"!ENV scalar",
"!ENV sequence",
"!relative scalar",
"tag:yaml.org,2002:python/name:material.extensions.emoji.to_svg",
"tag:yaml.org,2002:python/name:material.extensions.emoji.twemoji",
"tag:yaml.org,2002:python/name:pymdownx.superfences.fence_code_format",
"tag:yaml.org,2002:python/object/apply:pymdownx.slugs.slugify mapping"
],
// shell-format
"shellformat.flag": "-ci",
// Python
"ruff.nativeServer": "on",
"python.analysis.autoSearchPaths": true,
"python.analysis.diagnosticMode": "workspace",
"python.analysis.importFormat": "relative",
Expand All @@ -51,28 +120,23 @@
"${containerWorkspaceFolder}/src"
],
"python.envFile": "${containerWorkspaceFolder}/.env",
"python.terminal.activateEnvironment": true,
"python.terminal.activateEnvironment": false,
"python.defaultInterpreterPath": "${containerWorkspaceFolder}/.venv/bin/python",
// Test (python)
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"python.testing.cwd": "${containerWorkspaceFolder}/tests",
"python.testing.pytestPath": "${containerWorkspaceFolder}/.venv/bin/pytest",
"python.testing.autoTestDiscoverOnSaveEnabled": true,
// MkDocs schema for the YAML extension
"yaml.schemas": {
"https://squidfunk.github.io/mkdocs-material/schema.json": "mkdocs.yml"
// Jupyter Notebook (python)
"notebook.formatOnSave.enabled": true,
"notebook.codeActionsOnSave": {
"notebook.source.fixAll": "explicit",
"notebook.source.organizeImports": "explicit"
},
"yaml.customTags": [
"!ENV scalar",
"!ENV sequence",
"!relative scalar",
"tag:yaml.org,2002:python/name:material.extensions.emoji.to_svg",
"tag:yaml.org,2002:python/name:material.extensions.emoji.twemoji",
"tag:yaml.org,2002:python/name:pymdownx.superfences.fence_code_format",
"tag:yaml.org,2002:python/object/apply:pymdownx.slugs.slugify mapping"
],
// Settings per file type
/**
* Per-MIME settings
**/
"[toml]": {
"editor.defaultFormatter": "tamasfe.even-better-toml",
"editor.formatOnSave": true
Expand All @@ -82,6 +146,9 @@
"editor.formatOnSave": true,
"editor.wordWrap": "on"
},
"[shellscript]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[python]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff",
Expand All @@ -95,14 +162,26 @@
},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"configureZshAsDefaultShell": true
"configureZshAsDefaultShell": true,
"installOhMyZsh": true,
"upgradePackages": true
},
"ghcr.io/thecodecrate/devcontainer-features/bash-aliases:1": {},
"ghcr.io/thecodecrate/devcontainer-features/uv:1": {}
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
},
"remoteUser": "vscode",
"postCreateCommand": "zsh -i .devcontainer/scripts/post-create.sh",
"onCreateCommand": ".devcontainer/lifecycle/_loaders/30-loader-on-container-create.zsh",
"postCreateCommand": ".devcontainer/lifecycle/_loaders/40-loader-on-container-created.zsh",
"postStartCommand": ".devcontainer/lifecycle/_loaders/60-loader-on-container-start.zsh",
"containerEnv": {
"PYTHONPATH": "${containerWorkspaceFolder}/src"
}
"INSIDE_DEVCONTAINER": "true",
"HOST_DIR": "${localWorkspaceFolder}",
"WORKSPACE_DIR": "${containerWorkspaceFolder}",
"PYTHONPATH": "${containerWorkspaceFolder}/src",
"UV_LINK_MODE": "copy"
},
"runArgs": [
"--add-host=host.docker.internal:host-gateway"
]
}
8 changes: 8 additions & 0 deletions .devcontainer/docker/devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM mcr.microsoft.com/devcontainers/base:ubuntu

# Lifecycle scripts
USER vscode
ENV WORKSPACE_DIR=/tmp/workspace
COPY .devcontainer/tools ${WORKSPACE_DIR}/.devcontainer/tools
COPY .devcontainer/lifecycle ${WORKSPACE_DIR}/.devcontainer/lifecycle
RUN zsh ${WORKSPACE_DIR}/.devcontainer/lifecycle/_loaders/00-loader-on-dockerfile.zsh
7 changes: 0 additions & 7 deletions .devcontainer/etc/bash-aliases/clean-cache--aliases.sh

This file was deleted.

5 changes: 0 additions & 5 deletions .devcontainer/etc/bash-aliases/deploy--aliases.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env zsh

# Ensure local bin directory exists
mkdir -p "${HOME}/.local/bin"
18 changes: 18 additions & 0 deletions .devcontainer/lifecycle/00-on-dockerfile/05-install-tools.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env zsh

# Globals
SRC_TOOLS_DIR="${WORKSPACE_DIR}/.devcontainer/tools"
DST_TOOLS_DIR="/usr/local/bin/devcontainer-tools"
SHARED_BIN_DIR="/usr/local/bin"

# Copy tools to the destination directory
sudo mkdir -p "${DST_TOOLS_DIR}"
sudo cp -r "${SRC_TOOLS_DIR}/." "${DST_TOOLS_DIR}/"
sudo chmod -R +x "${DST_TOOLS_DIR}/**/install.zsh"

# Install tools for dev container setup
sudo "${DST_TOOLS_DIR}/enable-config-dir/install.zsh" --prefix "${SHARED_BIN_DIR}" --create-dirs
sudo "${DST_TOOLS_DIR}/setup-omz-plugins/install.zsh" --prefix "${SHARED_BIN_DIR}" --create-dirs
sudo "${DST_TOOLS_DIR}/switch-apt-mirror/install.zsh" --prefix "${SHARED_BIN_DIR}" --create-dirs

# vim: set ft=sh:
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env zsh

# Configure faster apt sources (Azure/Microsoft mirrors)
sudo switch-apt-mirror "http://azure.archive.ubuntu.com/ubuntu/"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env zsh

# Shell Linter, Formatter
sudo apt install -qq -y --no-install-recommends \
shellcheck \
shfmt
16 changes: 16 additions & 0 deletions .devcontainer/lifecycle/00-on-dockerfile/15-docker-host.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env zsh
#
# This script configures Docker contexts for dev container environments
# supporting both Docker-in-Docker (DinD) and Docker-outside-Docker patterns.
#
# NOTES:
# - Part 1/2 of the Docker host setup. Part 2 is in `30-on-container-create/15-docker-host.zsh`.
#

# Create docker-host group with matching host GID for Docker socket access
HOST_DOCKER_GID=$(stat -c '%g' /var/run/docker-host.sock 2>/dev/null || echo "997")
sudo groupadd -g "$HOST_DOCKER_GID" docker-host

# Add vscode user to docker-host group
[ -z "$USER" ] && USER=$(whoami 2>/dev/null || echo "vscode")
sudo usermod -aG docker-host "$USER"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env zsh

# Set the user to 'vscode' if not already set
[ -z "$USER" ] && USER=$(whoami 2>/dev/null || echo "vscode")

# Add vscode user to www-data group
sudo usermod -aG www-data "$USER"
17 changes: 17 additions & 0 deletions .devcontainer/lifecycle/00-on-dockerfile/20-meslo-font.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env zsh
#
# Download and install Meslo fonts
#
# Note: Font is already set up in `.vscode/settings.json`
#

# Download Meslo fonts
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf -P "${HOME}/.local/share/fonts"
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf -P "${HOME}/.local/share/fonts"
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf -P "${HOME}/.local/share/fonts"
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf -P "${HOME}/.local/share/fonts"

# Update font cache
sudo apt install -y fontconfig

fc-cache -fv "${HOME}/.local/share/fonts"
9 changes: 9 additions & 0 deletions .devcontainer/lifecycle/00-on-dockerfile/33-install-uv.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env zsh
# This script installs uv/uvx, required for `.vscode/mcp.json`

# Dowload and install uv
curl -LsSf https://astral.sh/uv/install.sh | sh

# Auto-completion
echo 'eval "$(uv generate-shell-completion zsh)"' >> ~/.zshrc
echo 'eval "$(uvx --generate-shell-completion zsh)"' >> ~/.zshrc
8 changes: 8 additions & 0 deletions .devcontainer/lifecycle/00-on-dockerfile/65-hadolint.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env zsh
# vim: set ft=sh:

# Install HADOLINT
HADOLINT_URL=https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64

sudo wget -q -O /usr/local/bin/hadolint "$HADOLINT_URL"
sudo chmod +x /usr/local/bin/hadolint
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env zsh

# Build apt sources index
sudo apt update
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env zsh

echo '[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path zsh)"' >> ~/.zshrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env zsh
#
# This script configures Docker contexts for dev container environments
# supporting both Docker-in-Docker (DinD) and Docker-outside-Docker patterns.
#
# NOTES:
# - Part 2/2 of the Docker host setup. Part 1 is in `00-on-dockerfile/15-docker-host.zsh`.
#

# Setup Docker context for docker-outside-docker
docker context create docker-host --docker "host=unix:///var/run/docker-host.sock"

# "default" context uses DinD
docker context use default
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/zsh

# Install virtual environment
(cd $WORKSPACE_DIR && uv sync --frozen)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env zsh

# ohmyzsh plugins from GitHub
setup-omz-plugins \
zsh-users/zsh-autosuggestions \
zsh-users/zsh-syntax-highlighting \
zsh-users/zsh-completions \
zsh-users/zsh-history-substring-search \
matthiasha/zsh-uv-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Configure alias files loading
enable-config-dir "${WORKSPACE_DIR}/.devcontainer/config/aliases"

# Configure config files loading
enable-config-dir "${WORKSPACE_DIR}/.devcontainer/config/custom"
Loading
Loading