Skip to content

Commit 23a8ed8

Browse files
committed
fix devcontainer for testing of feature
1 parent af1a734 commit 23a8ed8

File tree

7 files changed

+120
-14
lines changed

7 files changed

+120
-14
lines changed

.devcontainer/devcontainer.json

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
1+
// For format details, see https://containers.dev/implementors/json_reference/
12
{
2-
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-20-bookworm",
3+
"name": "Python 3 Developer Container",
4+
"build": {
5+
"dockerfile": "../Dockerfile",
6+
"target": "developer"
7+
},
38
"customizations": {
49
"vscode": {
10+
// Set *default* container specific settings.json values on container create.
511
"settings": {
6-
"json.schemas": [
7-
{
8-
"fileMatch": [
9-
"*/devcontainer-feature.json"
10-
],
11-
"url": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainerFeature.schema.json"
12-
}
13-
]
12+
"python.defaultInterpreterPath": "/venv/bin/python"
1413
},
14+
// Add the IDs of extensions you want installed when the container is created.
1515
"extensions": [
16-
"mads-hartmann.bash-ide-vscode"
16+
"ms-python.python",
17+
"github.vscode-github-actions",
18+
"tamasfe.even-better-toml",
19+
"redhat.vscode-yaml",
20+
"ryanluker.vscode-coverage-gutters",
21+
"charliermarsh.ruff",
22+
"ms-azuretools.vscode-docker"
1723
]
1824
}
1925
},
2026
"features": {
21-
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
27+
"./features/terminalhistory": {}
2228
},
23-
"remoteUser": "node",
24-
"updateContentCommand": "npm install -g @devcontainers/cli"
25-
}
29+
"runArgs": [
30+
// Allow the container to access the host X11 display and EPICS CA
31+
"--net=host",
32+
// Make sure SELinux does not disable with access to host filesystems like tmp
33+
"--security-opt=label=disable"
34+
],
35+
// Mount the parent as /workspaces so we can pip install peers as editable
36+
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
37+
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/devcontainer_rc"
38+
}
File renamed without changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "BASH terminal auto history configuration",
3+
"id": "bashconfig",
4+
"version": "1.0.0",
5+
"description": "Make default BASH terminal nicer",
6+
"containerEnv": {
7+
"CONFIG_FOLDER": "/devcontainer_rc",
8+
"CONFIG_STAGING": "/devcontainer_staging"
9+
},
10+
"mounts": [
11+
{
12+
"source": "${localEnv:HOME}/.config/devcontainer_rc",
13+
"target": "/devcontainer_rc",
14+
"type": "bind"
15+
}
16+
],
17+
"onCreateCommand": "bash /devcontainer_staging/onCreateCommand.sh"
18+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
mkdir -p $CONFIG_STAGING
4+
5+
# -------------------------------------------------------------------------------
6+
cat > $CONFIG_STAGING/onCreateCommand.sh \
7+
<< EOF
8+
#!/bin/bash
9+
10+
# copy in the opinionated default settings from the feature
11+
cp $CONFIG_STAGING/feature_settings_rc $CONFIG_FOLDER/feature_settings_rc
12+
13+
# copy in the user editable settings unless they already exist
14+
if [[ ! -f $CONFIG_FOLDER/bashrc ]] ; then
15+
cp $CONFIG_STAGING/bashrc $CONFIG_FOLDER
16+
cp $CONFIG_STAGING/inputrc $CONFIG_FOLDER
17+
fi
18+
19+
# hook in the config to the root account
20+
ln -s $CONFIG_FOLDER/inputrc /root/.inputrc
21+
echo "source $CONFIG_FOLDER/bashrc" >> /root/.bashrc
22+
EOF
23+
24+
# -------------------------------------------------------------------------------
25+
cat > $CONFIG_STAGING/inputrc \
26+
<< EOF
27+
# Readline configuration for bash shell.
28+
29+
# Incremental history searching with up and down arrows (C-P and C-N for old
30+
# style navigation).
31+
"\e[A": history-search-backward
32+
"\e[B": history-search-forward
33+
34+
# Control left and right for word movement
35+
"\e[5C": forward-word
36+
"\e[5D": backward-word
37+
EOF
38+
39+
# -------------------------------------------------------------------------------
40+
cat > $CONFIG_STAGING/bashrc \
41+
<< EOF
42+
#!/bin/bash
43+
44+
# execute default opinionated settings - delete this line to remove defaults
45+
source $CONFIG_FOLDER/feature_settings_rc
46+
47+
# add your personal custom settings below
48+
EOF
49+
50+
# -------------------------------------------------------------------------------
51+
cat > $CONFIG_STAGING/feature_settings_rc \
52+
<< EOF
53+
#!/bin/bash
54+
55+
# default opinioned bash configuration
56+
57+
# set the prompt
58+
export PS1="\[\033[1;34m\]\W \[\033[0m\]# "
59+
60+
# enable enternal shared history
61+
export HISTCONTROL=ignoreboth:erasedups
62+
export HISTFILESIZE=-1
63+
export SAVEHIST=-1
64+
export HISTFILE=$CONFIG_FOLDER/.bash_eternal_history
65+
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
66+
EOF

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# The devcontainer should use the developer target and run as root with podman
2+
# or docker with user namespaces.
3+
ARG PYTHON_VERSION=3.11
4+
FROM python:${PYTHON_VERSION} AS developer
5+
6+
# Set up a virtual environment and put it in PATH
7+
RUN python -m venv /venv
8+
ENV PATH=/venv/bin:$PATH

src

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.devcontainer/features

0 commit comments

Comments
 (0)