Skip to main content

Tips and Tricks

Feature release status badge: PriPrev
PriPrev

Accessing credentials

Because the DDE is simply a container, you can inject credentials in any way you would have for the existing development environment. Here are some ways to get your credentials inside the container.

Mounting local files

If you are developing using a local Docker instance, you can provide Docker run arguments to mount files on your host computer inside the container. For example, you can easily mount your .aws folder to ensure access to local AWS credentials without having to copy them.

To do this, edit your devcontainer.json. The setting you need to add or modify is called mounts. Here is an example of how to reuse your AWS credentials inside the container.

{
"mounts": [
"source=${localEnv:HOME}/.aws,target=/home/gitpod/.aws,type=bind,consistency=cached"
]
}

You can use this method for any credentials stored on your host machine.

Loading environment variables from a file

Another way to load credentials into your container is to specify a local file with environment variables to set.

For example, if you create a .env file inside the .devcontainer folder, you can use it to set environment variables available anywhere inside your container.

{
"runArgs": ["--env-file", ".devcontainer/devcontainer.env"]
}

Variables in DDE Remote

There are a few core variables that the DDE makes available for its own and user scripting purposes:

NameValue
REPO_ROOTThe path to the project folder etc /workspace/true-dataops22
VS_CODE_SERVER_SETTINGS_PATHThe path to the settings.json folder
CI_COMMIT_REF_NAMEThe name of the git branch currently checked out
DATAOPS_BRANCH_NAME_PRODThe name of the branch used for production — defaults to main but can be overridden

Keeping the workspace image up-to-date

To ensure that the image you are using is always the latest version, you can add an initialize command to your devcontainer.json. This command runs before your container is created. Read more about lifecycle scripts.

{
"name": "DataOpsCDE",
"image": "dataopslive/dataops-development-workspace:5-latest",
"runArgs": ["--env-file", "${localEnv:HOME}/.devcontainer/devcontainer.env"],
"initializeCommand": [
"docker",
"pull",
"dataopslive/dataops-development-workspace:5-latest"
]
}

Adding container features

Dev containers can use "features" to gain extra functionality. VS Code gives you access to an index of these features by using the command palette to add them to your devcontainer.json file.

To add a feature, follow the below steps. In this example, we are adding "docker-in-docke"r as a feature:

  1. Open a project containing the .devcontainer/devcontainer.json file.

  2. Open the command palette, "cmd+shift+p" for Mac and "ctrl+shift+p" for Windows.

  3. Search for Configure Container Features.

  4. Search for "Docker-in-Docker".

    Configure Features

  5. Select the check box and click OK.

This should add an entry to your devcontainer.json like this:

"features": {
"ghcr.io/devcontainers-contrib/features/cookiecutter:2": {}
}