Skip to content

DevContainer deployment fails #28

@strudel0209

Description

@strudel0209

When running azd up from DevContainer environment, the deployment fails due to path scripts declared in azure.yaml not being recognized.

The script files:

preprovision.sh
postprovision.sh
postdeploy.sh
azure.yaml

have Windows-style line endings (CRLF - \r\n) instead of Unix-style line endings (LF - \n), causing the shell to interpret the carriage returns as separate characters. This is a common issue when files are created on Windows and then run on Linux.

To make it work, the following changes were needed:

  • on each:
preprovision.sh
postprovision.sh
postdeploy.sh
  1. convert the line endings using:

dos2unix /workspaces/moneta-agents/scripts/preprovision.sh

  1. do the same for the remaining files
    if dos2unix is not installed, try running:
sed -i 's/
$//' /workspaces/moneta-agents/scripts/preprovision.sh

3. do the same for the remaining files

4. Modify azure.yaml to run posdeploy from container (line 56):

run: bash /workspaces/moneta-agents/scripts/postdeploy.sh

Modified postdeploy.sh script to check if venv is present. if not, use devcontainer system Python:

#!/bin/bash
set -e

echo "Running post-deploy hook..."

# Get the absolute path to the project root directory
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

# Load Python environment if needed
if [ -f "$PROJECT_ROOT/scripts/load_python_env.sh" ]; then
    echo "Loading Python environment..."
    bash "$PROJECT_ROOT/scripts/load_python_env.sh"
fi

# Check if virtual environment exists, use it if available, otherwise use system Python
if [ -f "$PROJECT_ROOT/.venv/bin/python" ]; then
    PYTHON_CMD="$PROJECT_ROOT/.venv/bin/python"
else
    PYTHON_CMD="python"
    # Make sure required packages are installed
    echo "Virtual environment not found, installing required packages with system Python..."
    pip install -r "$PROJECT_ROOT/scripts/requirements.txt"
fi

echo "Using Python: $PYTHON_CMD"
$PYTHON_CMD "$PROJECT_ROOT/scripts/data_load/setup_cosmosdb.py"
$PYTHON_CMD "$PROJECT_ROOT/scripts/data_load/setup_aisearch.py"

Would it be possible to include these alternatives for DevContainer proper deployment?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions