From 47e2e491434afad954db7d6897affb0c66e34648 Mon Sep 17 00:00:00 2001 From: Pete Bachant Date: Thu, 11 Dec 2025 16:21:09 +0000 Subject: [PATCH] Adjust init and add scripts --- Dockerfile | 4 +++- devcontainer.json | 9 ++++----- scripts/post-create.sh | 5 +++++ scripts/post-start.sh | 3 +++ scripts/update-content.sh | 3 +++ 5 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 scripts/post-create.sh create mode 100644 scripts/post-start.sh create mode 100644 scripts/update-content.sh diff --git a/Dockerfile b/Dockerfile index 5ee7e7d..953d6b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,7 +54,9 @@ RUN curl -L -o /usr/local/bin/pixi -fsSL --compressed "https://github.com/prefix # Add init scripts ENV INIT_SCRIPTS_DIR=/usr/local/share/devcontainer-init RUN mkdir -p ${INIT_SCRIPTS_DIR} -COPY scripts/check-envs.sh ${INIT_SCRIPTS_DIR} +COPY scripts/post-create.sh ${INIT_SCRIPTS_DIR} +COPY scripts/post-start.sh ${INIT_SCRIPTS_DIR} +COPY scripts/update-content.sh ${INIT_SCRIPTS_DIR} # Install Calkit RUN uv pip install --system --no-cache-dir "calkit-python>=0.32.7" diff --git a/devcontainer.json b/devcontainer.json index 1b0cb54..3e6898a 100644 --- a/devcontainer.json +++ b/devcontainer.json @@ -41,9 +41,8 @@ } } }, - "mounts": [ - "source=${localEnv:HOME}/.calkit,target=/home/vscode/.calkit,type=bind,consistency=cached" - ], - "updateContentCommand": "while ! docker info > /dev/null 2>&1; do sleep 1; done && conda init bash && . /opt/conda/bin/activate && calkit check envs", - "postStartCommand": ". /opt/conda/bin/activate; mkdir -p $HOME/.cache; calkit config github-codespace > $HOME/.cache/calkit-config.log 2>&1 || true; calkit pull > $HOME/.cache/calkit-pull.log 2>&1 || true" + "initializeCommand": "mkdir -p .calkit/temp && echo '*' > .calkit/temp/.gitignore && bash -c 'echo \"CALKIT_TOKEN=$(calkit config get token)\" > .calkit/temp/.env' && bash -c 'echo \"CALKIT_DVC_TOKEN=$(calkit config get dvc_token)\" >> .calkit/temp/.env'", + "postCreateCommand": "bash $INIT_SCRIPTS_DIR/post-create.sh", + "updateContentCommand": "bash $INIT_SCRIPTS_DIR/update-content.sh", + "postStartCommand": "bash $INIT_SCRIPTS_DIR/post-start.sh" } diff --git a/scripts/post-create.sh b/scripts/post-create.sh new file mode 100644 index 0000000..4fb98ba --- /dev/null +++ b/scripts/post-create.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +TEMP_ENV=.calkit/temp/.env +source $TEMP_ENV && calkit config set token $CALKIT_TOKEN && calkit config set dvc_token $CALKIT_DVC_TOKEN +rm -f $TEMP_ENV diff --git a/scripts/post-start.sh b/scripts/post-start.sh new file mode 100644 index 0000000..84d3056 --- /dev/null +++ b/scripts/post-start.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +. /opt/conda/bin/activate; mkdir -p $HOME/.cache; calkit config github-codespace > $HOME/.cache/calkit-config.log 2>&1 || true; calkit pull > $HOME/.cache/calkit-pull.log 2>&1 || true diff --git a/scripts/update-content.sh b/scripts/update-content.sh new file mode 100644 index 0000000..34ee4e6 --- /dev/null +++ b/scripts/update-content.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +while ! docker info > /dev/null 2>&1; do sleep 1; done && conda init bash && . /opt/conda/bin/activate && calkit check envs