Thank you both for pointing me in the right direction. It was a big help and I managed to get it working perfectly.
For the sake of anyone reading this in the future, here is what I did (Silverblue 40):
Create a repo file for VSCode using sudo and nano or vim or whatever you like:
/etc/yum.repos.d/vstudio_code.repo
The file should contain the following:
[code]
name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
The “[code]” is not a typo, it should be in the file.
This will enable the VScode repo and you can then layer VScode on your Silverblue image:
rpm-ostree install code
Open the ide, go to the extensions market place and install DevContainer and Remote Containers extensions. Open settings for the Devcontainer extension and change the “Docker Command” from ‘docker’ to ‘podman’ if you want to use podman.
Use the explorer view to open a project you want to develop in a container or create a new project folder. In that folder create a directory named “.devcontainer”. In the .devcontainer directory create a file called devcontainer.json
In the devcontainer.json file:
{
"name": "Fedora Dev Container",
// Pull latest available Fedora docker image
"image": "fedora:latest",
// Set container workspace directory
"workspaceFolder": "/workspace",
// Bind local workspace to container workspace
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,Z",
// Install git, github cli, java 17
"postCreateCommand": "dnf install -y git java-17-openjdk java-17-openjdk-devel gh"
}
VSCode should detect the container file and ask you if you want to reopen the project in a container. Say yes, obvsiously. If you miss the dialog, you can also open the command pallete, search for devcontainer, and select “rebuild and open in container”.
It will take a few minutes the first time for everything to download and install, but after that getting into the project takes just a few seconds. It will automatically start the container when you are working with the project and stop it when you’re not. It will also prompt you to install any extensions in the container that might be needed such as the intellisense, java debugging, tabnine, etc.
You can also install podman desktop to make managing multiple containers a little easier.
My example above pulls the latest Fedora image and installs git and java. You can change the command to install whatever you want or even create a bash script file to execute more complex setup options and call that instead.
If you need to change configurations or Fedora versions, you can just edit the devcontainer.json file and then run the rebuild and open command to update the environment, leaving your project and code intact.
I hope this helps somebody somewhere. 