From ec8d0fdbdca356138053d54d5a5ae1d1710c96a7 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Sun, 2 Nov 2025 04:02:06 +0000 Subject: [PATCH] Set up deployment inside devcontainer --- .devcontainer/devcontainer.json | 9 +- .devcontainer/setup-ssh-config.sh | 28 +++++ deploy/files/authorized-ssh-keys.txt | 1 + docs/deployment-setup.md | 151 +++++++++++++++++++++++++++ 4 files changed, 187 insertions(+), 2 deletions(-) create mode 100644 .devcontainer/setup-ssh-config.sh create mode 100644 docs/deployment-setup.md 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 <