Skip to content

Commit 2c36c11

Browse files
Merge pull request #556 from atheo89/python-path
Fix issue with Run and Debug on code-server workbench
2 parents 4d4841f + 1fb7f57 commit 2c36c11

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

codeserver/ubi9-python-3.9/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ COPY --chown=1001:0 utils utils/
4444
# Create and intall the extensions though build-time on a temporary directory. Later this directory will copied on the `/opt/app-root/src/.local/share/code-server/extensions` via run-code-server.sh file when it starts up.
4545
RUN mkdir -p /opt/app-root/extensions-temp && \
4646
code-server --install-extension /opt/app-root/bin/utils/ms-python.python-2024.2.1.vsix --extensions-dir /opt/app-root/extensions-temp && \
47+
code-server --install-extension /opt/app-root/bin/utils/[email protected] --extensions-dir /opt/app-root/extensions-temp && \
4748
code-server --install-extension /opt/app-root/bin/utils/ms-toolsai.jupyter-2023.9.100.vsix --extensions-dir /opt/app-root/extensions-temp
4849

4950
# Install NGINX to proxy code-server and pass probes check
@@ -113,6 +114,8 @@ COPY --chown=1001:0 run-code-server.sh run-nginx.sh ./
113114

114115
ENV SHELL /bin/bash
115116

117+
ENV PYTHONPATH=/opt/app-root/bin/python3
118+
116119
WORKDIR /opt/app-root/src
117120

118121
USER 1001

codeserver/ubi9-python-3.9/run-code-server.sh

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,55 @@ fi
1616
# Initilize access logs for culling
1717
echo '[{"id":"code-server","name":"code-server","last_activity":"'$(date -Iseconds)'","execution_state":"running","connections":1}]' > /var/log/nginx/codeserver.access.log
1818

19-
# Directory for settings file
20-
user_dir="/opt/app-root/src/.local/share/code-server/User/"
19+
# Add "/opt/app-root/src/.vscode/" directory to set default interpreter also for Run & Debug
20+
user_dir="/opt/app-root/src/.vscode/"
2121
settings_filepath="${user_dir}settings.json"
22+
launch_filepath="${user_dir}launch.json"
23+
24+
json_launch_settings='{
25+
// Use IntelliSense to learn about possible attributes.
26+
// Hover to view descriptions of existing attributes.
27+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
28+
"version": "0.2.0",
29+
"configurations": [
30+
{
31+
"name": "Python Debugger: Current File",
32+
"type": "debugpy",
33+
"request": "launch",
34+
"program": "${file}",
35+
"console": "integratedTerminal",
36+
"python": "/opt/app-root/bin/python3"
37+
}
38+
]
39+
}'
2240

2341
json_settings='{
2442
"python.defaultInterpreterPath": "/opt/app-root/bin/python3"
25-
}'
43+
}'
2644

2745
# Check if User directory exists
2846
if [ ! -d "$user_dir" ]; then
2947
echo "Debug: User directory not found, creating '$user_dir'..."
3048
mkdir -p "$user_dir"
49+
echo "$json_launch_settings" > "$launch_filepath"
50+
echo "Debug: '$launch_filepath' file created."
3151
echo "$json_settings" > "$settings_filepath"
3252
echo "Debug: '$settings_filepath' file created."
3353
else
3454
echo "Debug: User directory already exists."
35-
# Add settings.json if not present
36-
if [ ! -f "$settings_filepath" ]; then
55+
# Add settings.json and launch.json if not present
56+
if [ ! -f "$launch_filepath" ]; then
57+
echo "Debug: '$launch_filepath' file not found, creating..."
58+
echo "$json_launch_settings" > "$launch_filepath"
59+
echo "Debug: '$launch_filepath' file created."
60+
elif [ ! -f "$settings_filepath" ]; then
3761
echo "Debug: '$settings_filepath' file not found, creating..."
3862
echo "$json_settings" > "$settings_filepath"
3963
echo "Debug: '$settings_filepath' file created."
4064
else
65+
echo "Debug: '$launch_filepath' file already exists."
4166
echo "Debug: '$settings_filepath' file already exists."
67+
4268
fi
4369
fi
4470

0 commit comments

Comments
 (0)