Skip to content

Commit ba2e051

Browse files
Handle activation
1 parent 07c10c7 commit ba2e051

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

.devcontainer/Dockerfile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,28 @@ RUN az config set core.login_experience_v2=off 2>/dev/null || true && \
4141
az extension add --name containerapp --only-show-errors 2>/dev/null || true && \
4242
az extension add --name front-door --only-show-errors 2>/dev/null || true
4343

44-
# Configure shell aliases and helpful commands (no auto venv activation)
44+
# Configure shell aliases and helpful commands with conditional venv activation
4545
RUN echo "# APIM Samples helpful aliases" >> ~/.bashrc && \
4646
echo "alias ll='ls -alF'" >> ~/.bashrc && \
4747
echo "alias la='ls -A'" >> ~/.bashrc && \
4848
echo "alias l='ls -CF'" >> ~/.bashrc && \
49-
echo "alias pytest-cov='python -m pytest --cov=. --cov-report=html'" >> ~/.bashrc
49+
echo "alias pytest-cov='python -m pytest --cov=. --cov-report=html'" >> ~/.bashrc && \
50+
echo "" >> ~/.bashrc && \
51+
echo "# Conditionally auto-activate APIM Samples virtual environment" >> ~/.bashrc && \
52+
echo "if [ -z \"\$VIRTUAL_ENV\" ] && [ -f /workspaces/Apim-Samples/.venv/bin/activate ]; then" >> ~/.bashrc && \
53+
echo " source /workspaces/Apim-Samples/.venv/bin/activate" >> ~/.bashrc && \
54+
echo "fi" >> ~/.bashrc && \
55+
echo "" >> ~/.zshrc && \
56+
echo "# APIM Samples helpful aliases" >> ~/.zshrc && \
57+
echo "alias ll='ls -alF'" >> ~/.zshrc && \
58+
echo "alias la='ls -A'" >> ~/.zshrc && \
59+
echo "alias l='ls -CF'" >> ~/.zshrc && \
60+
echo "alias pytest-cov='python -m pytest --cov=. --cov-report=html'" >> ~/.zshrc && \
61+
echo "" >> ~/.zshrc && \
62+
echo "# Conditionally auto-activate APIM Samples virtual environment" >> ~/.zshrc && \
63+
echo "if [ -z \"\$VIRTUAL_ENV\" ] && [ -f /workspaces/Apim-Samples/.venv/bin/activate ]; then" >> ~/.zshrc && \
64+
echo " source /workspaces/Apim-Samples/.venv/bin/activate" >> ~/.zshrc && \
65+
echo "fi" >> ~/.zshrc
5066

5167
# Set final working directory
5268
WORKDIR /workspaces/Apim-Samples

0 commit comments

Comments
 (0)