-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from gilesknap/main
fix the devcontainer for local feature testing
- Loading branch information
Showing
15 changed files
with
224 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,38 @@ | ||
// For format details, see https://containers.dev/implementors/json_reference/ | ||
{ | ||
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-20-bookworm", | ||
"name": "Python 3 Developer Container", | ||
"build": { | ||
"dockerfile": "../Dockerfile", | ||
"target": "developer" | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"json.schemas": [ | ||
{ | ||
"fileMatch": [ | ||
"*/devcontainer-feature.json" | ||
], | ||
"url": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainerFeature.schema.json" | ||
} | ||
] | ||
"python.defaultInterpreterPath": "/venv/bin/python" | ||
}, | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"mads-hartmann.bash-ide-vscode" | ||
"ms-python.python", | ||
"github.vscode-github-actions", | ||
"tamasfe.even-better-toml", | ||
"redhat.vscode-yaml", | ||
"ryanluker.vscode-coverage-gutters", | ||
"charliermarsh.ruff", | ||
"ms-azuretools.vscode-docker" | ||
] | ||
} | ||
}, | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": {} | ||
"./features/terminalhistory": {} | ||
}, | ||
"remoteUser": "node", | ||
"updateContentCommand": "npm install -g @devcontainers/cli" | ||
} | ||
"runArgs": [ | ||
// Allow the container to access the host X11 display and EPICS CA | ||
"--net=host", | ||
// Make sure SELinux does not disable with access to host filesystems like tmp | ||
"--security-opt=label=disable" | ||
], | ||
// Mount the parent as /workspaces so we can pip install peers as editable | ||
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind", | ||
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/devcontainer_rc" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,4 @@ | |
"installsAfter": [ | ||
"ghcr.io/devcontainers/features/common-utils" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
.devcontainer/features/terminalhistory/devcontainer-feature.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "BASH terminal auto history configuration", | ||
"id": "bashconfig", | ||
"version": "1.0.0", | ||
"description": "Make default BASH terminal nicer", | ||
"containerEnv": { | ||
"CONFIG_FOLDER": "/devcontainer_rc", | ||
"CONFIG_STAGING": "/devcontainer_staging" | ||
}, | ||
"mounts": [ | ||
{ | ||
"source": "${localEnv:HOME}/.config/devcontainer_rc", | ||
"target": "/devcontainer_rc", | ||
"type": "bind" | ||
} | ||
], | ||
"onCreateCommand": "bash /devcontainer_staging/onCreateCommand.sh" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/bash | ||
|
||
mkdir -p $CONFIG_STAGING | ||
|
||
# ------------------------------------------------------------------------------- | ||
cat > $CONFIG_STAGING/onCreateCommand.sh \ | ||
<< EOF | ||
#!/bin/bash | ||
# copy in the opinionated default settings from the feature | ||
cp $CONFIG_STAGING/feature_settings_rc $CONFIG_FOLDER/feature_settings_rc | ||
# copy in the user editable settings unless they already exist | ||
if [[ ! -f $CONFIG_FOLDER/bashrc ]] ; then | ||
cp $CONFIG_STAGING/bashrc $CONFIG_FOLDER | ||
cp $CONFIG_STAGING/inputrc $CONFIG_FOLDER | ||
fi | ||
# hook in the config to the root account | ||
ln -s $CONFIG_FOLDER/inputrc /root/.inputrc | ||
echo "source $CONFIG_FOLDER/bashrc" >> /root/.bashrc | ||
EOF | ||
|
||
# ------------------------------------------------------------------------------- | ||
cat > $CONFIG_STAGING/inputrc \ | ||
<< EOF | ||
# Readline configuration for bash shell. | ||
# Incremental history searching with up and down arrows (C-P and C-N for old | ||
# style navigation). | ||
"\e[A": history-search-backward | ||
"\e[B": history-search-forward | ||
# Control left and right for word movement | ||
"\e[5C": forward-word | ||
"\e[5D": backward-word | ||
EOF | ||
|
||
# ------------------------------------------------------------------------------- | ||
cat > $CONFIG_STAGING/bashrc \ | ||
<< EOF | ||
#!/bin/bash | ||
# execute default opinionated settings - delete this line to remove defaults | ||
source $CONFIG_FOLDER/feature_settings_rc | ||
# add your personal custom settings below | ||
EOF | ||
|
||
# ------------------------------------------------------------------------------- | ||
cat > $CONFIG_STAGING/feature_settings_rc \ | ||
<< EOF | ||
#!/bin/bash | ||
# default opinioned bash configuration | ||
# set the prompt | ||
export PS1="\[\033[1;34m\]\W \[\033[0m\]# " | ||
# enable enternal shared history | ||
export HISTCONTROL=ignoreboth:erasedups | ||
export HISTFILESIZE=-1 | ||
export SAVEHIST=-1 | ||
export HISTFILE=$CONFIG_FOLDER/.bash_eternal_history | ||
PROMPT_COMMAND="history -a; $PROMPT_COMMAND" | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
name: "Validate devcontainer-feature.json files" | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
|
||
jobs: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# The devcontainer should use the developer target and run as root with podman | ||
# or docker with user namespaces. | ||
ARG PYTHON_VERSION=3.11 | ||
FROM python:${PYTHON_VERSION} AS developer | ||
|
||
# Set up a virtual environment and put it in PATH | ||
RUN python -m venv /venv | ||
ENV PATH=/venv/bin:$PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.devcontainer/features |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.