From 9f6e9adbc78ba1205b323a4c7a36bb68806799e7 Mon Sep 17 00:00:00 2001 From: JasonHomeWorkstationUbuntu Date: Wed, 27 Jan 2021 23:42:53 +1100 Subject: [PATCH] Working on C# docker dev env --- README.md | 15 ++++++++++++++- c#/Dockerfile | 10 +++++++++- docker-compose.yaml | 4 ++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 00ec21d..010368a 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,17 @@ This repository is a playground for practising docker based programming followin * Topic 1: [Working with Dockerfiles (.NET, Golang, Python, NodeJS)](docs/working_with_dockerfiles.md) * Topic 2: [Working with code (.NET, Golang, Python, NodeJS)](docs/working_with_code.md) -* Topic 3: [Multistage & Layers](docs/multistage_layers.md) \ No newline at end of file +* Topic 3: [Multistage & Layers](docs/multistage_layers.md) + +## Reference + +VSCode official document contains many good information: +* [Developing inside a Container](https://code.visualstudio.com/docs/remote/containers) +* [devcontainer.json](https://code.visualstudio.com/docs/remote/devcontainerjson-reference) file used to tell VSCode how to access a development container +* [Tutorial: Remote development in Container](https://code.visualstudio.com/docs/remote/containers-tutorial) +* [ASP.NET Core in a container](https://code.visualstudio.com/docs/containers/quickstart-aspnet-core) describe how to create ASP.NET container from local environment (not recommended for docker-based development) +* [Container tips for docker development (like remote)](https://code.visualstudio.com/docs/remote/troubleshooting#_container-tips) +* [Adding extension to devcontainer.json](https://code.visualstudio.com/docs/remote/containers#_adding-an-extension-to-devcontainerjson) + +Blogs with good Docker related information: +* [Code in a Container](https://nabeelvalley.netlify.app/blog/2020/25-07/developing-in-a-container-vscode/) \ No newline at end of file diff --git a/c#/Dockerfile b/c#/Dockerfile index b1bdaeb..13b050e 100644 --- a/c#/Dockerfile +++ b/c#/Dockerfile @@ -9,7 +9,15 @@ RUN dotnet restore COPY ./src/ /app/ RUN mkdir /out/ -RUN dotnet publish --no-restore --output /out/ --configuration Release +RUN dotnet publish --output /out/ --configuration Release + +############# DEBUG IMAGE ################ +FROM dev as debug +RUN apt-get update +RUN apt-get install -y unzip +RUN curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l ~/vsdbg + +RUN dotnet run ############## PRODUCT IMAGE ############# FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch-slim as prod diff --git a/docker-compose.yaml b/docker-compose.yaml index 4cebf45..d140176 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,11 +1,11 @@ -version: "3" +version: "3.4" services: csharp: container_name: csharp # image name image: cruxlight/csharp_sdk:1.0.0 build: context: ./c# - target: dev + target: debug working_dir: /work entrypoint: /bin/sh stdin_open: true