Created
April 10, 2017 12:57
-
-
Save brad-jones/fdf75201b91192c588789be48597c1d5 to your computer and use it in GitHub Desktop.
docker-dotnet-vscode
This file contains hidden or 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
#!/usr/bin/env bash | |
docker build -t brad-jones/dotnet . |
This file contains hidden or 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
#!/usr/bin/env bash | |
# Start with docker run, this might change to a docker exec, if we setup init | |
# scripts to run an instance of this container at host boot time. Which cuts | |
# down on container startup time drastically. | |
CMD="docker run --rm" | |
# Make the container run in the background. This provides a similar expirence | |
# to how editors like vscode normally background the main editor process once | |
# it is spawned from the CLI however it does mean calls like this: | |
# code --install-extension abc will fail to show any output. | |
CMD="$CMD -d" | |
# Run the container as the same user as our host system. | |
CMD="$CMD -u `id -u`:`id -g`" | |
# Mount the home directory of our host system. | |
CMD="$CMD -v /home:/home" | |
# Ensure the working directory inside the container is the same as it is | |
# on the host system, obviously this is restricted to with-in /home. | |
CMD="$CMD -w `pwd`" | |
# Mount the hosts X11 socket into the container, | |
# allowing vscode to display on our host. | |
CMD="$CMD -v /tmp/.X11-unix/:/tmp/.X11-unix/ -e DISPLAY" | |
# Give the container direct access to the hosts shared memory. | |
# I believe this makes things just run more efficently. | |
CMD="$CMD -v /dev/shm:/dev/shm" | |
# Make the container use the hosts network stack. This will ensure any web | |
# applications that are run inside the container can easily be accessed from | |
# the host. | |
CMD="$CMD --net host" | |
# Run the approriate tagged container. | |
CMD="$CMD brad-jones/dotnet" | |
# Execute vscode inside the container | |
# Proxying all other arguments on to vscode | |
CMD="$CMD code --wait $@" | |
# Finally execute the built command. | |
$CMD |
This file contains hidden or 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
FROM microsoft/dotnet:latest | |
# Install Node.js repo | |
RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - | |
# Install the VsCode repo | |
RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg && \ | |
mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg && \ | |
echo "deb [arch=amd64] http://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list | |
# Install everything needed to run vscode, along with vscode it's self | |
RUN apt-get update && \ | |
apt-get install -y --no-install-recommends \ | |
libc6-dev \ | |
libgtk2.0-0 \ | |
libgtk-3-0 \ | |
libpango-1.0-0 \ | |
libcairo2 \ | |
libfontconfig1 \ | |
libgconf2-4 \ | |
libnss3 \ | |
libasound2 \ | |
libxtst6 \ | |
unzip \ | |
libglib2.0-bin \ | |
libcanberra-gtk-module \ | |
libgl1-mesa-glx \ | |
curl \ | |
build-essential \ | |
gettext \ | |
libstdc++6 \ | |
software-properties-common \ | |
wget \ | |
git \ | |
xterm \ | |
automake \ | |
libtool \ | |
autogen \ | |
nodejs \ | |
libnotify-bin \ | |
aspell \ | |
aspell-en \ | |
htop \ | |
git \ | |
emacs \ | |
mono-complete \ | |
gvfs-bin \ | |
libxss1 \ | |
rxvt-unicode-256color \ | |
x11-xserver-utils \ | |
sudo \ | |
vim \ | |
xdg-utils \ | |
code && \ | |
apt-get clean && \ | |
rm -rf /var/lib/apt/lists/* | |
# Create our user, that matches up with our host user. | |
# We will then volumne mount our home directory into the container. | |
RUN groupadd -r -g 1000 brad && useradd -r -u 1000 -g 1000 brad | |
USER brad |
This file contains hidden or 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
#!/usr/bin/env bash | |
# Start with docker run, this might change to a docker exec, if we setup init | |
# scripts to run an instance of this container at host boot time. Which cuts | |
# down on container startup time drastically. | |
CMD="docker run --rm" | |
# The container is interactive but does not always need to get a pseudo tty. | |
[[ -t 1 ]] && TTY="-i" || TTY="-it" | |
CMD="$CMD $TTY" | |
# Run the container as the same user as our host system. | |
CMD="$CMD -u `id -u`:`id -g`" | |
# Mount the home directory of our host system. | |
CMD="$CMD -v /home:/home" | |
# Ensure the working directory inside the container is the same as it is | |
# on the host system, obviously this is restricted to with-in /home. | |
CMD="$CMD -w `pwd`" | |
# Make the container use the hosts network stack. This will ensure any web | |
# applications that are run inside the container can easily be accessed from | |
# the host. | |
CMD="$CMD --net host" | |
# Run the approriate tagged container. | |
CMD="$CMD brad-jones/dotnet" | |
# Execute dotnet inside the container | |
# Proxying all other arguments on to vscode | |
CMD="$CMD dotnet $@" | |
# Finally execute the built command. | |
$CMD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment