From 73f6d139c60ef58e9167b0cb776720384f76d8ed Mon Sep 17 00:00:00 2001 From: Cody Robertson Date: Wed, 11 Dec 2024 10:36:26 -0500 Subject: [PATCH] Leverage devcontainer postStartCommand hook - Ensures workspace is properly mounted *before* `hugo server` is ran - It attempted to run the command before the `config.yaml` was available --- .devcontainer/Dockerfile | 3 +-- .devcontainer/devcontainer.json | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 85ced9d..d84b21c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -51,5 +51,4 @@ USER vscode EXPOSE 1313 # Set the working directory to the container workspace directory -WORKDIR ${WORKSPACE_DIR} -CMD ["hugo", "server", "--bind=0.0.0.0"] \ No newline at end of file +WORKDIR ${WORKSPACE_DIR} \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e3d6a62..d230d7f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "AlmaLinux_WWW_Container", - "overrideCommand": false, + "overrideCommand": true, "build": { "dockerfile": "Dockerfile", "args": { @@ -33,5 +33,6 @@ }, "forwardPorts": [1313], "remoteUser": "vscode", - "postCreateCommand": "echo 'function git_branch() { local branch; branch=\"$(git symbolic-ref --short HEAD 2> /dev/null)\"; if [[ -n \"$branch\" ]]; then echo -n \"$branch\"; return 0; fi; return 1; } && function git_has_changes() { git diff --quiet HEAD 2> /dev/null || echo -n \"✗\"; } && export WHITE=\"\\[\\033[1;37m\\]\" && export GREEN=\"\\[\\033[0;32m\\]\" && export BLUE=\"\\[\\033[0;94m\\]\" && export RED=\"\\[\\033[1;31m\\]\" && export YELLOW=\"\\[\\033[1;33m\\]\" && export RESET=\"\\[\\033[0m\\]\" && function prompt_command() { PS1=\"${GREEN}\\u${WHITE} ➜ ${BLUE}\\w ${BLUE}(${RED}\\$(git_branch)${YELLOW}\\$(git_has_changes)${BLUE})${RESET}$ \"; } && export PROMPT_COMMAND=\"prompt_command\"' >> ~/.bashrc" + "postCreateCommand": "echo 'function git_branch() { local branch; branch=\"$(git symbolic-ref --short HEAD 2> /dev/null)\"; if [[ -n \"$branch\" ]]; then echo -n \"$branch\"; return 0; fi; return 1; } && function git_has_changes() { git diff --quiet HEAD 2> /dev/null || echo -n \"✗\"; } && export WHITE=\"\\[\\033[1;37m\\]\" && export GREEN=\"\\[\\033[0;32m\\]\" && export BLUE=\"\\[\\033[0;94m\\]\" && export RED=\"\\[\\033[1;31m\\]\" && export YELLOW=\"\\[\\033[1;33m\\]\" && export RESET=\"\\[\\033[0m\\]\" && function prompt_command() { PS1=\"${GREEN}\\u${WHITE} ➜ ${BLUE}\\w ${BLUE}(${RED}\\$(git_branch)${YELLOW}\\$(git_has_changes)${BLUE})${RESET}$ \"; } && export PROMPT_COMMAND=\"prompt_command\"' >> ~/.bashrc", + "postStartCommand": "hugo server --bind=0.0.0.0" }