Skip to content

Instantly share code, notes, and snippets.

@khalidabuhakmeh
Last active October 24, 2023 20:59
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khalidabuhakmeh/20efbdff6eed1b8014884b681fb4716b to your computer and use it in GitHub Desktop.
Save khalidabuhakmeh/20efbdff6eed1b8014884b681fb4716b to your computer and use it in GitHub Desktop.
JetBrains Rider / Gateway Container
FROM mcr.microsoft.com/dotnet/sdk:6.0
# SSHD port
EXPOSE 2222
ENV DEBIAN_FRONTEND=noninteractive
ENV LC_ALL=C.UTF-8
RUN apt-get update && apt-get install -y apt-utils apt-transport-https
RUN apt-get install -y \
# Utilities \
curl unzip wget software-properties-common socat man-db gnupg2 pass lsof procps time \
# VCS \
git \
# Docker \
docker docker-compose \
# SSHD \
openssh-server \
&& rm -rf /var/lib/apt/lists/*
RUN true \
&& set -e \
&& mkdir /var/run/sshd \
&& sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config \
&& sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config \
&& echo 'root:root' | chpasswd
## SERVER
CMD /usr/sbin/sshd -D

How To Use

Requirements before starting:

  1. Docker for Desktop
  2. JetBrains Gateway or JetBrains Rider

Seriously though, just download JetBrains Toolbox

Download Dockerfile

From above, download the Dockerfile and add it to a folder/location on your disk. You'll need it for the next step.

Building and Running the container

Run the following in a terminal.

docker build -t rdev .
docker run -it -p 2222:22 rdev

Connect using JetBrains Rider

  1. From the welcome screen of Rider, select New Connection.

  2. Set the following values for the fields. a. Username : root b. Host: localhost c. Port: 2222 d. Password (prompt): root

Screenshot 2022-04-19 at 15 19 20

  1. Connect to your new container and git clone a .NET 6 project. Use open an SSH terminal link
  2. Set the Project Directory to the path of your .sln or .csproj file. (for example: https://github.com/khalidabuhakmeh/GuidGenie)

Screenshot 2022-04-19 at 15 23 09

  1. Click Download and Start IDE.

Have Fun!

@MO2k4
Copy link

MO2k4 commented Apr 19, 2022

this is awesome! i did a prepare build for the installation of the ide with an empty solution, this way one image could be reused for several projects without the need to reinstall the ide each time

steps for reproduction:

  • build image with an empty solution file (mkdir default && cd default && dotnet new sln)
  • start this image
  • connect through gateway app or rider to this container and let the ide installation go through
  • save current state of the container (docker commit )

@suddenelfilio
Copy link

I was trying this but got stuck at downloading the IDE
image

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