diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f69d7175..4b67e665 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,13 +9,18 @@ // Features to add to the dev container. More info: https://containers.dev/features. "features": { "ghcr.io/devcontainers/features/node:1": {}, - "ghcr.io/rails/devcontainer/features/mysql-client": {} + "ghcr.io/rails/devcontainer/features/mysql-client": {}, + "ghcr.io/devcontainers-extra/features/ansible:2": {} }, "containerEnv": { "DB_HOST": "mysql" }, + "remoteEnv": { + "IMPRESS_DEPLOY_USER": "${localEnv:USER}" + }, + // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts": [3000], @@ -27,5 +32,5 @@ // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "bin/setup --skip-server" + "postCreateCommand": "bash .devcontainer/setup-ssh-config.sh && bin/setup --skip-server" } diff --git a/.devcontainer/setup-ssh-config.sh b/.devcontainer/setup-ssh-config.sh new file mode 100644 index 00000000..97c185e3 --- /dev/null +++ b/.devcontainer/setup-ssh-config.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# Creates SSH config for devcontainer to use host's SSH identity +# This allows `ssh impress.openneo.net` to work without hardcoding usernames + +mkdir -p ~/.ssh +chmod 700 ~/.ssh + +# Only create SSH config if IMPRESS_DEPLOY_USER is explicitly set +if [ -z "$IMPRESS_DEPLOY_USER" ]; then + echo "⚠️ IMPRESS_DEPLOY_USER not set - skipping SSH config creation." + echo " This should be automatically set from your host \$USER environment variable." + echo " See docs/deployment-setup.md for details." + exit 0 +fi + +cat > ~/.ssh/config <