Skip to content

Creation of Devcontainer to support VS Code and GitHub Codespaces - #6997

Merged
potatoqualitee merged 10 commits into
developmentfrom
devcontainer
Dec 4, 2020
Merged

Creation of Devcontainer to support VS Code and GitHub Codespaces#6997
potatoqualitee merged 10 commits into
developmentfrom
devcontainer

Conversation

@wsmelton

@wsmeltonwsmelton commented Nov 29, 2020

Copy link
Copy Markdown
Member

Does not pertain to the direct codebase of the module.

This is the addition of DevContainers support for the repository for VS Code (remote container development) and GitHub Codespaces.

VS Code Remote Container Development

To test for VS Code:

  1. Clone repository
  2. Do a git fetch
  3. Checkout the devcontainer branch (git checkout devcontainer)
  4. Reload VS Code
  5. You should be prompted to reopen in a container

image

I've added environment variables with the "servers" listed so you can easily grab what each container name is:
image

PS /workspace>$servers=$env:MY_SERVERS.Split(',')
PS /workspace>$servers
dbatools1
dbatools2
dbatools3
PS /workspace>

After the above is done you can then proceed to create connections to each server based on the SA_PASSWORD that is set (since these are SQL Server containers at the base image):

image

PS /workspace>Import-Module ./dbatools.psd1
PS /workspace>$cred= [pscredential]::new('sa',(ConvertTo-SecureString$env:SA_PASSWORD-AsPlainText -Force))
PS /workspace>$serversCn=Connect-DbaInstance-SqlInstance $servers-SqlCredential $cred
PS /workspace>$serversCn.NetName
ef4266d0e0a7
5dae5ae59158
519bccb6e0fc
PS /workspace>$serverCn| ft
ComputerName Name Product Version HostPlatform IsAzure IsClustered ConnectedAs
-----------------------------------------------------------------------
dbatools1 dbatools1 Microsoft SQL Server 15.0.4073 Linux False False sa
dbatools2 dbatools2 Microsoft SQL Server 15.0.4073 Linux False False sa
dbatools3 dbatools3 Microsoft SQL Server 15.0.4073 Linux False False sa
PS /workspace>

Being that VS Code reopens the workspace into the container you can either just close the VS Code window or utilize the command palette option to reopen in local:

image

GitHub Codespaces

Note this is in beta, so be aware miles may vary on experience

To test for GitHub Codespaces (requires your account has been added to the beta):

  1. Navigate to the repo on GitHub
  2. Switch to the devcontainer branch
  3. Click the drop-down for Code
  4. Click Open with Codespaces
  5. Click + New codespace

When you first create the codespace it will go through to initialize the environment for Codespaces itself, and then begin building the container and starting it.

image

If all goes well VS Code (web) will open and the workspace loaded:

image

You can also access this via a PR (for maintainers):

image

If you utilize VS Code sync feature and tied it to your GitHub user all your preferences and extensions will be installed; in addition to the ones set to install by default by the devcontainer definition.

@potatoqualitee

Copy link
Copy Markdown
Member

haaa! So dang cool!!!

@potatoqualitee
potatoqualitee merged commit 5ce35a1 into developmentDec 4, 2020
@potatoqualitee
potatoqualitee deleted the devcontainer branch December 4, 2020 14:01
@potatoqualitee

Copy link
Copy Markdown
Member

Will play shortly!

@wsmelton

Copy link
Copy Markdown
MemberAuthor

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@wsmelton@potatoqualitee