Some Dinosaur
Some Dinosaur
CCoder.com
Created by Some Dinosaur on 1/20/2025 in #help
Docker in workspace
Sorry I passed out. I will get back to it tomorrow 👌
6 replies
CCoder.com
Created by Some Dinosaur on 1/20/2025 in #help
Docker in workspace
I've ran this devcontainer raw on my system and the same thing appears - so it must be just Devcontainers thing. But maybne you know how to overcome this anyways?
6 replies
CCoder.com
Created by Some Dinosaur on 1/4/2025 in #help
Coder ran on a machine with VPN can't resolve the hostname
I'm trying to set up my own DNS that I'd force the VPN to use, hoping that the name will resolve to the IP. Instead of hoping for host-name resolution I will have my own tables... maybe that works we'll see
6 replies
CCoder.com
Created by Some Dinosaur on 1/4/2025 in #help
Coder ran on a machine with VPN can't resolve the hostname
I can ping the host through the raw local ip address - so it's just the name resolution that fails.
6 replies
CCoder.com
Created by Some Dinosaur on 12/23/2024 in #help
Failed to pull GitHub private repo
ok - someone on Stackoverflow faced the same problem. I was trying to authenticate on the host with host_name:7080 but once I replaced host_name with localhost it just works. I don't know what is happening anymore
32 replies
CCoder.com
Created by Some Dinosaur on 12/23/2024 in #help
Failed to pull GitHub private repo
Ok, I tried to set up the same thing that worked with OAuth on a different machine. Now every time I click Click to Login I get:
{"message":"Cookie \"oauth_state\" must be provided."}
{"message":"Cookie \"oauth_state\" must be provided."}
32 replies
CCoder.com
Created by Syrelash on 12/31/2024 in #help
Modify $PATH to include custom bin folder
I never used /etc/environment but internet says it doesn't support export so it only allows you to set some static variables I guess? I think doing it your way might work if you've used ~/.bashrc instead but then it's per-user
9 replies
CCoder.com
Created by Syrelash on 12/31/2024 in #help
Modify $PATH to include custom bin folder
I just added this to my Dockerfile:
ENV PATH="$PATH:/uhh/idk/"
ENV PATH="$PATH:/uhh/idk/"
and it seems to work:
$ echo $PATH
/tmp/code-server/lib/code-server-4.96.2/lib/vscode/bin/remote-cli:/usr/local/cargo/bin:/usr/local/cargo/bin:/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/bin:/uuh/idk/
$ echo $PATH
/tmp/code-server/lib/code-server-4.96.2/lib/vscode/bin/remote-cli:/usr/local/cargo/bin:/usr/local/cargo/bin:/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/bin:/uuh/idk/
9 replies
CCoder.com
Created by Some Dinosaur on 12/23/2024 in #help
Failed to pull GitHub private repo
I haven't got a chance to try passing the raw key yet.
32 replies
CCoder.com
Created by Some Dinosaur on 12/25/2024 in #help
Set "extensions" and "theme" from `devcontainer.json`
(can't close it... how do I close the thread?)
38 replies
CCoder.com
Created by Some Dinosaur on 12/25/2024 in #help
Set "extensions" and "theme" from `devcontainer.json`
/close
38 replies
CCoder.com
Created by Some Dinosaur on 12/25/2024 in #help
Set "extensions" and "theme" from `devcontainer.json`
Windows I've done this from my Windows PC so I could play games in-between builds - big mistake. I had a lot of errors due to CRLF line endings that caused both scripts to fail and whole Coder frontend to freeze - not reporting any logs until I restarted it. I think the frontend should just filter out CR on Build if it causes problem but it is what it is. I'd say just avoid Windows, Coder feels a bit clunky with it.
38 replies
CCoder.com
Created by Some Dinosaur on 12/25/2024 in #help
Set "extensions" and "theme" from `devcontainer.json`
Componentisation - why not? I really wanted to keep things separate, to have like 3 scripts: vs-install.sh, vs-extensions.sh, vs-settings.sh but it's hard to do. There's no synchronization mechanism for separate script resources and as the documentation says:
When multiple scripts are assigned to the same agent, they are executed in parallel.
So if your scripts depend on each other - like in my case I can't install extensions before code-server is installed - you'll have to make scripts way more complex to add synchronization. You could do file-system based synchronization - locking a file as a mutex so that other scripts wait for it to be available - but for me it sounds like too much work for the simple setup im trying to achieve.
38 replies
CCoder.com
Created by Some Dinosaur on 12/25/2024 in #help
Set "extensions" and "theme" from `devcontainer.json`
1. The first part Install the latest code-server is just copy-paste of what was initially in startup_script. 2. Second part Import settings I wrote myself - it'll take settings from .devcontainer/devcontainer.json and merge settings with what is already set on the machine. Notice that I assume the .devcontainer folder to be available at CWD - you might want to do instead */.devcontainer/devcontainer.json to dig one level lower if you go with default workspaces folder. Or even better what I should've done - define the path as env-variable. code-server doesn't provide any command to set the settings, so I update settings.json file manually - I'd much rather have something like --install-extension command. 3. Third part to install extensions is a copy-pase from here. I changed the path too for my own CWD setup. It will call code-server --install-extension for every extension listed in your devcontainer.json. It's a simple solution and it works - I hope it works for you as well.
38 replies
CCoder.com
Created by Some Dinosaur on 12/25/2024 in #help
Set "extensions" and "theme" from `devcontainer.json`
resource "coder_script" "vs-setup" {
  agent_id     = coder_agent.main.id
  display_name = "VS Setup"
  icon         = "/icon/code.svg"
  run_on_start = true
  script = <<EOF
    #!/bin/bash
    set -e

    # Install the latest code-server.
    # Append "--version x.x.x" to install a specific version of code-server.
    curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server
    # Start code-server in the background.
    /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &

    # Import settings
    VSCODE_SETTINGS_PATH=~/.local/share/code-server/Machine/settings.json
    IMPORTED_SETTINGS_FILE=$(mktemp)
    echo "Importing settings..."
    sed 's/\/\/.*$//g' .devcontainer/devcontainer.json | jq -r -M '.customizations.vscode.settings?' > "$IMPORTED_SETTINGS_FILE"
    NEW_SETTINGS=$( jq -s '.[0] * (.[1] // {})' "$IMPORTED_SETTINGS_FILE" $VSCODE_SETTINGS_PATH )
    echo "$NEW_SETTINGS" > $VSCODE_SETTINGS_PATH
    rm "$IMPORTED_SETTINGS_FILE"

    # Install extensions
    echo "Installing extensions..."
    set +e
    extensions=( $(sed 's/\/\/.*$//g' .devcontainer/devcontainer.json | jq -r -M '[.customizations.vscode.extensions[]?, .extensions[]?] | .[]' ) )
    if [ "$${extensions[0]}" != "" ] && [ "$${extensions[0]}" != "null" ]; then
      for extension in "$${extensions[@]}"; do
        /tmp/code-server/bin/code-server --install-extension "$extension"
      done
    fi
    set -e
  EOF
}
resource "coder_script" "vs-setup" {
  agent_id     = coder_agent.main.id
  display_name = "VS Setup"
  icon         = "/icon/code.svg"
  run_on_start = true
  script = <<EOF
    #!/bin/bash
    set -e

    # Install the latest code-server.
    # Append "--version x.x.x" to install a specific version of code-server.
    curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server
    # Start code-server in the background.
    /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &

    # Import settings
    VSCODE_SETTINGS_PATH=~/.local/share/code-server/Machine/settings.json
    IMPORTED_SETTINGS_FILE=$(mktemp)
    echo "Importing settings..."
    sed 's/\/\/.*$//g' .devcontainer/devcontainer.json | jq -r -M '.customizations.vscode.settings?' > "$IMPORTED_SETTINGS_FILE"
    NEW_SETTINGS=$( jq -s '.[0] * (.[1] // {})' "$IMPORTED_SETTINGS_FILE" $VSCODE_SETTINGS_PATH )
    echo "$NEW_SETTINGS" > $VSCODE_SETTINGS_PATH
    rm "$IMPORTED_SETTINGS_FILE"

    # Install extensions
    echo "Installing extensions..."
    set +e
    extensions=( $(sed 's/\/\/.*$//g' .devcontainer/devcontainer.json | jq -r -M '[.customizations.vscode.extensions[]?, .extensions[]?] | .[]' ) )
    if [ "$${extensions[0]}" != "" ] && [ "$${extensions[0]}" != "null" ]; then
      for extension in "$${extensions[@]}"; do
        /tmp/code-server/bin/code-server --install-extension "$extension"
      done
    fi
    set -e
  EOF
}
38 replies
CCoder.com
Created by Some Dinosaur on 12/25/2024 in #help
Set "extensions" and "theme" from `devcontainer.json`
(I don't have Discord Nitro, need to post my final solution in a couple messages. sorry!) Solution I think I've got this one relatively covered now. So here's what I've done. I edited the template I had by first removing the startup_script from the resource "coder_agent" "main" because documentation on coder_agent startup_script says:
This option is an alias for defining a coder_script resource with run_on_start set to true.
So I prefer to have the init script detached, you can give it an icon and all. Next I added the coder_script:
38 replies
CCoder.com
Created by Some Dinosaur on 12/25/2024 in #help
Set "extensions" and "theme" from `devcontainer.json`
yeah I figured but I think I can't. I pasted my script to my Ubuntu remote, cleaned all line endings to LF, but it still had some leftovers 😦 feels very clunky to use these at the moment, I pasted my script raw into the TF
38 replies
CCoder.com
Created by Some Dinosaur on 12/25/2024 in #help
Set "extensions" and "theme" from `devcontainer.json`
Also because of this...:
When multiple scripts are assigned to the same agent, they are executed in parallel.
if I ever want to separate installing extensions from settings importing - I need to do some synchronization (can do file-system based) which sounds sketchy.
38 replies
CCoder.com
Created by Some Dinosaur on 12/25/2024 in #help
Set "extensions" and "theme" from `devcontainer.json`
I just pasted the script into the startup_script in resource "coder_agent" "main"... but I wish there was a way to use a resource for it :c which should be the case with what I've done above according to:
startup_script (String) A script to run after the agent starts. The script should exit when it is done to signal that the agent is ready. This option is an alias for defining a coder_script resource with run_on_start set to true.
startup_script (String) A script to run after the agent starts. The script should exit when it is done to signal that the agent is ready. This option is an alias for defining a coder_script resource with run_on_start set to true.
but it just won't work
38 replies
CCoder.com
Created by Some Dinosaur on 12/25/2024 in #help
Set "extensions" and "theme" from `devcontainer.json`
I've added a new file to the template: vs-extensions.sh and here are the contents (copied from here):
#! /bin/bash

# install and start code-server
if ! which code-server > /dev/null; then
curl -fsSL https://code-server.dev/install.sh | sh | tee code-server-install.log
fi
CODE_CLI=code-server
if code; then
CODE_CLI=code
fi
mkdir -p ~/.vscode-server/extensions

set +e
extensions=( $(sed 's/\/\/.*$//g' */.devcontainer/devcontainer.json | jq -r -M '[.customizations.vscode.extensions[]?, .extensions[]?] | .[]' ) )
if [ "$${extensions[0]}" != "" ] && [ "$${extensions[0]}" != "null" ]; then
for extension in "$${extensions[@]}"; do
$CODE_CLI --extensions-dir ~/.vscode-server/extensions --install-extension "$extension"
done
fi
set -e
fi
#! /bin/bash

# install and start code-server
if ! which code-server > /dev/null; then
curl -fsSL https://code-server.dev/install.sh | sh | tee code-server-install.log
fi
CODE_CLI=code-server
if code; then
CODE_CLI=code
fi
mkdir -p ~/.vscode-server/extensions

set +e
extensions=( $(sed 's/\/\/.*$//g' */.devcontainer/devcontainer.json | jq -r -M '[.customizations.vscode.extensions[]?, .extensions[]?] | .[]' ) )
if [ "$${extensions[0]}" != "" ] && [ "$${extensions[0]}" != "null" ]; then
for extension in "$${extensions[@]}"; do
$CODE_CLI --extensions-dir ~/.vscode-server/extensions --install-extension "$extension"
done
fi
set -e
fi
Next I've added coder_script as follows:
resource "coder_script" "vs-extensions" {
agent_id = coder_agent.main.id
display_name = "VS Extensions"
icon = "/icon/code.svg"
run_on_start = true
script = templatefile("./vs-extensions.sh", {})
}
resource "coder_script" "vs-extensions" {
agent_id = coder_agent.main.id
display_name = "VS Extensions"
icon = "/icon/code.svg"
run_on_start = true
script = templatefile("./vs-extensions.sh", {})
}
And I keep getting these weird errors about $\r:
/bin/bash: line 2: $'\r': command not found
/bin/bash: -c: line 16: syntax error near unexpected token `$'do\r''
'
/bin/bash: line 2: $'\r': command not found
/bin/bash: -c: line 16: syntax error near unexpected token `$'do\r''
'
38 replies