Skip to content

Instantly share code, notes, and snippets.

@valyakuttan
Last active September 6, 2023 04:12
Show Gist options
  • Save valyakuttan/368b8d3282c33d4343fba52a8cc94155 to your computer and use it in GitHub Desktop.
Save valyakuttan/368b8d3282c33d4343fba52a8cc94155 to your computer and use it in GitHub Desktop.
Fedora Silverblue vscode flatpak configuration

How to configure flatpak version of Visual Studio Code on Fedora Silverblue

1 podman Configuration

  • Create a a file ${HOME}/.config/containers/containers.conf with the following contents:

    
    [containers]
    env = [
      "BUILDAH_FORMAT=docker"
    ]
    label = false
    userns = "keep-id"
    
    
  • Redirect unqualified searches by podman to docker.io by editing /etc/containers/registries.conf

    
    # Comment out this line 
    unqualified-search-registries = ["registry.fedoraproject.org", "registry.access.redhat.com", "docker.io", "quay.io"]
    
    # Instead add the following line
    unqualified-search-registries = ["docker.io"]
    
    

2 podman-compose Configuration

  • Start and Enable the Podman Socket

    
    $ systemctl --user enable --now podman.socket
    
    $ # check the status
    $ systemctl --user status podman.socket
    
    $ curl -w "\n" -H "Content-Type: application/json" \
            --unix-socket /var/run/user/$UID/podman/podman.sock \
          http://localhost/_ping
    
    $ # This should return OK
    
    
  • Set DOCKER_HOST environment varibale by adding following line to ${HOME}/.bashrc

    
    export DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock
    
    
  • Install podman-compose

    
    $ rpm-ostree install podman-compose
     
    

3 Visual Studio Code Configuration

  • Give Flatpak vscode write permission to /tmp folder

    
    $ flatpak override --user --filesystem=/tmp com.visualstudio.code
    
    
  • Download host-spawn

  • Copy host-spawn binary to directory $HOME/.var/app/com.visualstudio.code/data/node_modules/bin and make it executable.

    
    $ chmod +x host-spawn
    
    
  • Create two symlinks in $HOME/.var/app/com.visualstudio.code/data/node_modules/bin

    
    $ ln -s host-spawn podman
    
    
  • Configure Dev Container VSCode extension Docker path as podman

4 Dev container Configuration

  • Install Dev Containers extension

  • In your devcontainer.json file, you must set remoteUser and containerUser properly. For base image from Microsoft set both properties to vscode.

        
    "remoteUser": "vscode",
    
    "containerUser": "vscode",
    
    
  • To access local workspace folder from container set the propery workspaceMount as

    
    "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
    
    "workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,Z"
    
    

References

  1. Vscode + devcontainers

  2. Fedora Silverblue : VS code's remote container extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment