generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass env vars to
devcontainer up
(#211)
* And env vars to build/up commands * Add env-vars-on-post-create tests * Update docs on env vars
- Loading branch information
1 parent
3e5d540
commit fb6a663
Showing
11 changed files
with
307 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
github-tests/Dockerfile/env-vars-on-post-create/.devcontainer/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# [Choice] Debian / Ubuntu version: debian-10, debian-9, ubuntu-20.04, ubuntu-18.04 | ||
# See https://github.com/microsoft/vscode-dev-containers/tree/master/containers/debian | ||
ARG VARIANT=debian-10 | ||
FROM mcr.microsoft.com/vscode/devcontainers/base:${VARIANT} | ||
|
||
|
||
# Avoid warnings by switching to noninteractive | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Set env for tracking that we're running in a devcontainer | ||
ENV DEVCONTAINER=true | ||
|
||
# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser" | ||
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs | ||
# will be updated to match your local UID/GID (when using the dockerFile property). | ||
# See https://aka.ms/vscode-remote/containers/non-root-user for details. | ||
ARG USERNAME=vscode | ||
ARG USER_UID=1000 | ||
ARG USER_GID=$USER_UID | ||
|
||
USER $USERNAME | ||
RUN \ | ||
mkdir -p ~/.local/bin \ | ||
&& echo "export PATH=\$PATH:~/.local/bin" >> ~/.bashrc | ||
|
||
# Configure apt, install packages and general tools | ||
RUN sudo apt-get update \ | ||
&& sudo apt-get -y install --no-install-recommends apt-utils dialog nano bash-completion sudo bsdmainutils \ | ||
# | ||
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed | ||
&& sudo apt-get -y install git iproute2 procps lsb-release figlet build-essential | ||
|
||
# Save command line history | ||
RUN echo "export HISTFILE=/home/$USERNAME/commandhistory/.bash_history" >> "/home/$USERNAME/.bashrc" \ | ||
&& echo "export PROMPT_COMMAND='history -a'" >> "/home/$USERNAME/.bashrc" \ | ||
&& mkdir -p /home/$USERNAME/commandhistory \ | ||
&& touch /home/$USERNAME/commandhistory/.bash_history \ | ||
&& chown -R $USERNAME /home/$USERNAME/commandhistory | ||
|
||
# Set env for tracking that we're running in a devcontainer | ||
ENV DEVCONTAINER=true | ||
|
||
# __DEVCONTAINER_SNIPPET_INSERT__ (control where snippets get inserted using the devcontainer CLI) | ||
|
||
# Switch back to dialog for any ad-hoc use of apt-get | ||
ENV DEBIAN_FRONTEND=dialog |
23 changes: 23 additions & 0 deletions
23
github-tests/Dockerfile/env-vars-on-post-create/.devcontainer/devcontainer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at: | ||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.117.1/containers/go | ||
{ | ||
"name": "env-vars-on-post-create", | ||
"dockerFile": "Dockerfile", | ||
"build": { | ||
"cacheFrom": "ghcr.io/devcontainers/ci/tests/env-vars-on-post-create:latest" | ||
}, | ||
"remoteEnv": { | ||
"TEST_ENV_VALUE": "${localEnv:TEST_ENV_VALUE}" | ||
}, | ||
|
||
// Add the IDs of extensions you want installed when the container is created. | ||
// "extensions": [], | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "./.devcontainer/post-create.sh", | ||
|
||
"remoteUser": "vscode" | ||
} |
11 changes: 11 additions & 0 deletions
11
github-tests/Dockerfile/env-vars-on-post-create/.devcontainer/post-create.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo "**************************************************" | ||
echo "*** In post-create.sh " | ||
echo "*** TEST_ENV_VALUE=${TEST_ENV_VALUE}" | ||
echo "*** TEST_ENV_VALUE2=${TEST_ENV_VALUE2}" | ||
echo "**************************************************" | ||
echo "post-create: TEST_ENV_VALUE=${TEST_ENV_VALUE}" > marker.txt | ||
echo "post-create: TEST_ENV_VALUE2=${TEST_ENV_VALUE2}" >> marker.txt | ||
|