Skip to content

Commit

Permalink
Add launch.json configuration on .vscode directory together with sett…
Browse files Browse the repository at this point in the history
…ings.json file
  • Loading branch information
atheo89 committed Jun 12, 2024
1 parent ed22ccd commit 318a659
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
2 changes: 2 additions & 0 deletions codeserver/ubi9-python-3.9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ COPY --chown=1001:0 run-code-server.sh run-nginx.sh ./

ENV SHELL /bin/bash

ENV PYTHONPATH=/opt/app-root/bin/python3

WORKDIR /opt/app-root/src

USER 1001
Expand Down
36 changes: 31 additions & 5 deletions codeserver/ubi9-python-3.9/run-code-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,55 @@ fi
# Initilize access logs for culling
echo '[{"id":"code-server","name":"code-server","last_activity":"'$(date -Iseconds)'","execution_state":"running","connections":1}]' > /var/log/nginx/codeserver.access.log

# Directory for settings file
user_dir="/opt/app-root/src/.local/share/code-server/User/"
# Add "/opt/app-root/src/.vscode/" directory to set default interpreter also for Run & Debug
user_dir="/opt/app-root/src/.vscode/"
settings_filepath="${user_dir}settings.json"
launch_filepath="${user_dir}launch.json"

json_launch_settings='{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"python": "/opt/app-root/bin/python3"
}
]
}'

json_settings='{
"python.defaultInterpreterPath": "/opt/app-root/bin/python3"
}'
}'

# Check if User directory exists
if [ ! -d "$user_dir" ]; then
echo "Debug: User directory not found, creating '$user_dir'..."
mkdir -p "$user_dir"
echo "$json_launch_settings" > "$launch_filepath"
echo "Debug: '$launch_filepath' file created."
echo "$json_settings" > "$settings_filepath"
echo "Debug: '$settings_filepath' file created."
else
echo "Debug: User directory already exists."
# Add settings.json if not present
if [ ! -f "$settings_filepath" ]; then
# Add settings.json and launch.json if not present
if [ ! -f "$launch_filepath" ]; then
echo "Debug: '$launch_filepath' file not found, creating..."
echo "$json_launch_settings" > "$launch_filepath"
echo "Debug: '$launch_filepath' file created."
elif [ ! -f "$settings_filepath" ]; then
echo "Debug: '$settings_filepath' file not found, creating..."
echo "$json_settings" > "$settings_filepath"
echo "Debug: '$settings_filepath' file created."
else
echo "Debug: '$launch_filepath' file already exists."
echo "Debug: '$settings_filepath' file already exists."

fi
fi

Expand Down

0 comments on commit 318a659

Please sign in to comment.