(For myself) Try creating a C # environment with docker + code-server, cloud9

Introduction

It's like a continuation of this article. Build a code-server with docker and try to create a C # environment there.

code-server_1 Create the following directory.

python


ls
> Dockerfile  code-server  docker-compose.yml  projects

The Dockerfile and docker-compose.yml look like this. I'm using the official docker-image to install .net core there.

Dockerfile

Dockerfile


FROM codercom/code-server:3.8.0

USER root

# Install wget and other module
RUN apt-get update && apt-get install -y \
	wget

# Install code-server plugin
#* Extension install from command does not work?
RUN code-server --install-extension ms-dotnettools.csharp

# Install .NET5
ENV DOTNET_ROOT=/usr/share/dotnet
ENV PATH=/usr/share/dotnet:/root/.dotnet/tools:$PATH
#The following environment variables need to be changed
#Details 1: https://github.com/dotnet/core/issues/2186
#Details 2: https://github.com/dotnet/core/blob/master/Documentation/build-and-install-rhel6-prerequisites.md
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true

RUN wget -O dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/a0487784-534a-4912-a4dd-017382083865/be16057043a8f7b6f08c902dc48dd677/dotnet-sdk-5.0.101-linux-x64.tar.gz \
    && wget -O dotnet_runtime.tar.gz https://download.visualstudio.microsoft.com/download/pr/6bea1cea-89e8-4bf7-9fc1-f77380443db1/0fb741b7d587cce798ebee80732196ef/aspnetcore-runtime-5.0.1-linux-x64.tar.gz \
    && dotnet_sha512='398d88099d765b8f5b920a3a2607c2d2d8a946786c1a3e51e73af1e663f0ee770b2b624a630b1bec1ceed43628ea8bc97963ba6c870d42bec064bde1cd1c9edb' \
    && echo "$dotnet_sha512  dotnet.tar.gz" | sha512sum -c - \
    && dotnet_runtime_sha512='fec655aed2e73288e84d940fd356b596e266a3e74c37d9006674c4f923fb7cde5eafe30b7dcb43251528166c02724df5856e7174f1a46fc33036b0f8db92688a' \
    && echo "$dotnet_runtime_sha512  dotnet_runtime.tar.gz" | sha512sum -c - \
    && mkdir -p "/usr/share/dotnet" \
    && mkdir -p "/usr/bin/dotnet" \
    && mkdir -p "/root/.dotnet/tools" \
    && tar zxf dotnet.tar.gz -C "/usr/share/dotnet" \
    && rm dotnet.tar.gz \
    && tar zxf dotnet_runtime.tar.gz -C "/usr/share/dotnet" \
    && rm dotnet_runtime.tar.gz \
    && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
    && dotnet help

USER coder
docker-compose.yml

docker-compose.yml


version: "3"
services:
  code:
    build:
      context: .
      dockerfile: Dockerfile
    restart: always
    environment:
      PUID: 1000
      PGID: 1000
      PASSWORD: password
    ports:
      - 20000:8080
    volumes:
      - ./projects:/home/coder/project
      - ./code-server:/home/coder/.local/share/code-server

start up.

docker-compose up -d --build

Access the URL. image.png

I intend to add a C # extension with this command in the Dockerfile. Doesn't it seem like it's in? is. Even if I hit the command in the same way from the terminal, it was not reflected in the UI.

RUN code-server --install-extensions ms-dotnettools.csharp

There is no choice but to add the extension manually. I put in the three main ones. image.png

Let's make a suitable project.

python


dotnet new console -o tutorial
ls
> Program.cs  tutorial.csproj

Add files under the tutorial folder. There is an atmosphere that C # extensions can be used, but it did not generate a file. image.png

Since there is no help for it, name it Calc.cs in normal file creation. Program.cs and Calc.cs should have the following contents.

Calc.cs

Calc.cs


using System;

namespace tutorial2
{
    class Calc
    {
        public static double Add(double a, double b)
        {
            return a + b;
        }
    }
}

Program.cs

Program.cs


using System;
using tutorial2;

namespace tutorial
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            var ret = Calc.Add(1, 3);
            Console.WriteLine($"Cal Result is {ret}");
        }
    }
}

Try running it from the terminal. image.png I was able to execute it.

How about debugging? Specify .Net Core Launch in launch.json, set a breakpoint and execute it.

??? The following error is displayed in DEBUG CONSOLE. image.png

Looking at this URL, it seems that the debugger is licensed so that it only works with Microsoft's IDE. It is also mentioned in issue on code-server Original debugger? seems to be the only way to do it. .. .. The issue was also closed because the standard debugger could not be used due to licensing issues.

code-server_2

Volunteers made it by putting DotNetCore in linuxserver/code-server There was image, so I'll put that as well.

git clone https://github.com/ptr727/VSCode-Server-DotNetCore.git
cd VSCode-Server-DotnetCore
docker-compose up -d #Start-up

cloud9 As a bonus, I will try it on cloud9.

The Dockerfile and docker-compose.yml look like this. I tried to put DotNetCore in linuxserver/cloud9.

Dockerfile

Dockerfile


FROM linuxserver/cloud9:version-1.27.4

RUN mkdir -p /code/projects

# Install wget
RUN apt-get update \
    # Install wget
    && apt-get install -y wget

# Install .NET5
ENV DOTNET_ROOT=/usr/share/dotnet
ENV PATH=/usr/share/dotnet:/root/.dotnet/tools:$PATH
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true

RUN wget -O dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/a0487784-534a-4912-a4dd-017382083865/be16057043a8f7b6f08c902dc48dd677/dotnet-sdk-5.0.101-linux-x64.tar.gz \
    && wget -O dotnet_runtime.tar.gz https://download.visualstudio.microsoft.com/download/pr/6bea1cea-89e8-4bf7-9fc1-f77380443db1/0fb741b7d587cce798ebee80732196ef/aspnetcore-runtime-5.0.1-linux-x64.tar.gz \
    && dotnet_sha512='398d88099d765b8f5b920a3a2607c2d2d8a946786c1a3e51e73af1e663f0ee770b2b624a630b1bec1ceed43628ea8bc97963ba6c870d42bec064bde1cd1c9edb' \
    && echo "$dotnet_sha512  dotnet.tar.gz" | sha512sum -c - \
    && dotnet_runtime_sha512='fec655aed2e73288e84d940fd356b596e266a3e74c37d9006674c4f923fb7cde5eafe30b7dcb43251528166c02724df5856e7174f1a46fc33036b0f8db92688a' \
    && echo "$dotnet_runtime_sha512  dotnet_runtime.tar.gz" | sha512sum -c - \
    && mkdir -p "/usr/share/dotnet" \
    && mkdir -p "/usr/bin/dotnet" \
    && mkdir -p "/root/.dotnet/tools" \
    && tar zxf dotnet.tar.gz -C "/usr/share/dotnet" \
    && rm dotnet.tar.gz \
    && tar zxf dotnet_runtime.tar.gz -C "/usr/share/dotnet" \
    && rm dotnet_runtime.tar.gz \
    && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
    && dotnet help
docker-compose.yml

docker-compose.yml


version: "3"
services:
  code:
    build:
      context: .
      dockerfile: Dockerfile
    restart: always
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Asia/Tokyo
      - GITURL=https://github.com/linuxserver/docker-cloud9.git #optional
      - USERNAME=user #optional
      - PASSWORD=password #optional
    ports:
      - 50000:8000
    volumes:
      - ./projects:/code/projects
      - ./docker.sock:/var/run/docker.sock #optional

Access the URL. image.png

Like code-server, create a suitable project from the terminal and try it. I will omit it, but like code-server, I was able to do dotnet run properly. cloud9 is good because it has good intellisense and history.

How about debugging? I could set a breakpoint, but I gave up because I didn't know how to make a Runner. .. .. image.png It seems that AWS Cloud9 can do it, but what about this one?

Conclusion

I think the web-ide itself is useful and convenient I got the impression that full-scale development is still difficult because peripheral knowledge is required even after construction and extension functions do not work well. I think it can be done by a higher level person, but I'm a little. .. .. At present, is it safe to develop C # quietly in windows + visual studio? However, there are articles such as python on docker + code-server or cloud9, so can I use it without problems? When I felt like it, I wanted to try it with python + α.

Recommended Posts

(For myself) Try creating a C # environment with docker + code-server, cloud9
Creating a java web application development environment with docker for mac part1
Create a Vue3 environment with Docker!
Build a Node.js environment with Docker
Environment construction with Docker for beginners
[Oracle Cloud] Build a 4-Node RAC environment of Oracle Database 19c with Docker on OCI Compute
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]
Build a development environment for Django + MySQL + nginx with Docker Compose
Create a MySQL environment with Docker from 0-> 1
Build a Wordpress development environment with Docker
Build a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack)
Create a java web application development environment with docker for mac part2
Build a development environment for Docker + Rails6 + Postgresql
[Memo] Create a CentOS 8 environment easily with Docker
Build a WordPress development environment quickly with Docker
Prepare a scraping environment with Docker and Java
Build a development environment for Docker, java, vscode
Create a docker environment for Oracle 11g XE
Create a Spring Boot development environment with docker
How to build docker environment with Gradle for intelliJ
Easily build a Vue.js environment with Docker + Vue CLI
Build a local development environment for Open Distro for Elasticsearch with multiple nodes using Docker
Try WildFly with Docker
How to quit Docker for Mac and build a Docker development environment with Ubuntu + Vagrant
[Note] Create a java environment from scratch with docker
(For myself) Build gitlab with ubuntu18.04 + docker for home (Note)
Try connecting to AzureCosmosDB Emulator for Docker with Java
Try to build a Java development environment using Docker
Creating a lightweight Java environment that runs on Docker
[2021] Build a Docker + Vagrant environment for using React / TypeScript
(For myself) Build an IDE that you can touch from a browser with docker (trial)
Deploying a Java environment with Windows Subsystem for Linux (WSL)
I made a development environment with rails6 + docker + postgreSQL + Materialize.
Build a Node-RED environment with Docker to move and understand
I tried to create a padrino development environment with Docker
Building an environment for creating apps with Rails and Vue
Pytorch execution environment with Docker
[Docker] Rails 5.2 environment construction with docker
Build docker environment with WSL
React environment construction with Docker
Build a data processing environment with Google Cloud DataFlow + Pub / Sub
Build a SPA for Laravel 6.2 / Vue.js / Nginx / Mysql / Redis with Docker
Try AWS Lambda Runtime Interface Emulator with Docker Desktop for M1
Run logstash with Docker and try uploading data to Elastic Cloud
Prepare a transcendentally simple PHP & Apache environment on Mac with Docker
Make a C compiler to use with Rust x CLion with Docker
Building a haskell environment with Docker + VS Code on Windows 10 Home
Creating a new user with rails was angry with unknown attribute'password' for User.
"Rails 6 x MySQL 8" Docker environment construction procedure for sharing with teams
Creating a dual boot environment for Ubuntu Server 20.04.1 LTS and Windows 10
A story stuck with log output in Docker + Play framework environment
Command line that can create a directory structure for building a Laravel environment with Docker in one shot
Build a web application development environment that uses Java, MySQL, and Redis with Docker CE for Windows
# 1 [Beginner] Create a web application (website) with Eclipse from knowledge 0. "Let's build an environment for creating web applications"
Rails + MySQL environment construction with Docker
Node.js environment construction with Docker Compose
Deploy a Docker application with Greengrass
Build Couchbase local environment with Docker
Build a Tomcat 8.5 environment with Pleiades 4.8
Build PlantUML environment with VSCode + Docker
[Rails] Creating a new project with rails new