From 6fd2b35f2940a85bee550f96e41868da4b30e2c3 Mon Sep 17 00:00:00 2001 From: Charley Wu Date: Mon, 27 Nov 2023 23:49:54 +0800 Subject: [PATCH 1/5] Set the project name for docker-compose - https://docs.docker.com/compose/environment-variables/envvars/#compose_project_name --- .devcontainer/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 7923fdc3..45733bba 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -1,5 +1,5 @@ version: '2' - +name: auth-cas_devcontainer services: dotnet: # https://github.com/devcontainers/images/blob/main/src/dotnet From 329d12ef608ae83008e1b0ef1823f9a7820aaccc Mon Sep 17 00:00:00 2001 From: Charley Wu Date: Mon, 27 Nov 2023 23:51:39 +0800 Subject: [PATCH 2/5] Simplify the mono msbuild installation --- .devcontainer/Dockerfile | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index e2bf8dfa..05250c14 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,26 +1,20 @@ # https://hub.docker.com/_/microsoft-dotnet-sdk/ FROM mcr.microsoft.com/dotnet/sdk:8.0 -ARG APT_URL="" - # install ASP.NET Core 6.0 Runtime COPY --from=mcr.microsoft.com/dotnet/aspnet:6.0-bookworm-slim /usr/share/dotnet /usr/share/dotnet -RUN set -eux; \ - # preferred mirror site - [ -n "$APT_URL" ] && [ "$APT_URL" = 'http://free.nchc.org.tw' ] && [ $(uname -m) = 'x86_64' ] && [ -e "/etc/apt/sources.list.d/debian.sources" ] && sed -i -E "/-security/! s,URIs: http?://[^\/]+,URIs: $APT_URL,g" /etc/apt/sources.list.d/debian.sources; \ - [ -n "$APT_URL" ] && [ "$APT_URL" != 'http://free.nchc.org.tw' ] && [ -e "/etc/apt/sources.list.d/debian.sources" ] && sed -i -E "s,URIs: http?://[^\/]+,URIs: $APT_URL,g" /etc/apt/sources.list.d/debian.sources; \ - # install msbuild for Mono - # https://www.mono-project.com/download/stable/#download-lin-debian - apt-get update; \ - apt-get install -y --no-install-recommends dirmngr gnupg ca-certificates; \ - # avoid connection timeout - timeout 10 apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF || apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF; \ - echo "deb http://download.mono-project.com/repo/debian stable-buster main" > /etc/apt/sources.list.d/mono-official-stable.list; \ - apt-get update; \ - apt-get install -y mono-devel; \ - # clean up - apt-get purge -y --auto-remove gnupg dirmngr; \ - rm -rf /var/lib/apt/lists/* /tmp/*; \ - # smoke test - dotnet --info && msbuild -version; \ No newline at end of file +# install msbuild for Mono +# https://hub.docker.com/_/mono/ +COPY --from=mono /etc/ca-certificates/update.d/mono-keystore /etc/ca-certificates/update.d/ +COPY --from=mono /etc/mono /etc/mono +COPY --from=mono /usr/bin/cert-sync /usr/bin/ +COPY --from=mono /usr/bin/mono /usr/bin/ +COPY --from=mono /usr/bin/msbuild /usr/bin/ +COPY --from=mono /usr/lib/mono /usr/lib/mono +COPY --from=mono /usr/lib/libmono-* /usr/lib/ +COPY --from=mono /usr/lib/libMono* /usr/lib/ + +# synchronizes the Mono TLS certificates +# https://www.mono-project.com/docs/about-mono/releases/3.12.0/#cert-sync +RUN cert-sync /etc/ssl/certs/ca-certificates.crt \ No newline at end of file From 90c12313393cb0ea8b081d40b15a7ab55169b257 Mon Sep 17 00:00:00 2001 From: Charley Wu Date: Mon, 27 Nov 2023 23:52:41 +0800 Subject: [PATCH 3/5] Tuning Dev container --- .devcontainer/devcontainer.json | 11 ++++++++++- .devcontainer/docker-compose.yml | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2c253028..e95b9962 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,8 +7,17 @@ "service": "dotnet", "workspaceFolder": "/workspaces", "postAttachCommand": "corepack enable", - // https://containers.dev/features. + "customizations": { + "vscode": { + "extensions": [ + "ms-dotnettools.csharp", + "josefpihrt-vscode.roslynator" + ] + } + }, + // https://containers.dev/features "features": { + "ghcr.io/devcontainers/features/git:1": {}, "ghcr.io/devcontainers/features/node:1": {} } } diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 45733bba..c0789d0a 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -4,7 +4,7 @@ services: dotnet: # https://github.com/devcontainers/images/blob/main/src/dotnet build: . - image: dotnet:mono + image: dotnet-sdk:mono environment: ASPNETCORE_ENVIRONMENT: Development PATH: $PATH:/home/vscode/.dotnet:/home/vscode/.dotnet/tools From 72224626811af823ca8247fe82183d2c0156a1c8 Mon Sep 17 00:00:00 2001 From: Charley Wu Date: Mon, 27 Nov 2023 23:53:01 +0800 Subject: [PATCH 4/5] Update README.md --- .devcontainer/README.md | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/.devcontainer/README.md b/.devcontainer/README.md index d6189a6d..ed0a5dc6 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -10,19 +10,30 @@ ## Getting Start -> The following instrstuctions are for macOS environment - ```sh # set up TLS certs and hosts in Host ./init.sh auth.dev.local -# run the Dev Containers +# starting container docker compose up -d # run the sample app in Host -cd ../samples/AspNetSample +cd ../samples/AspNetCoreSample dotnet run - -# browse sample app and sign-in as demo user (test:test) -open https://localhost:5001 ``` + +## Admin URLs + +- [Keycloak](https://auth.dev.local) + +## Credentials + +### Keycloak admin + +- Username: `admin` +- Password: `admin` + +### Keycloak user + +- Username: `test` +- Password: `test` \ No newline at end of file From d48ee6a13b051d8a5a3cac8dc3654035c4b1f477 Mon Sep 17 00:00:00 2001 From: Charley Wu Date: Mon, 27 Nov 2023 23:57:53 +0800 Subject: [PATCH 5/5] Add configuration for VS Code --- .vscode/launch.json | 33 +++++++++++++++++++++++++++++++++ .vscode/tasks.json | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..06935986 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,33 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md。 + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // Needs change path when updating target Framework + "program": "${workspaceFolder}/samples/AspNetCoreSample/bin/Debug/net8.0/AspNetCoreSample.dll", + "args": [], + "cwd": "${workspaceFolder}/samples/AspNetCoreSample", + "stopAtEntry": false, + // https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..b97b8b33 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,36 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/CAS.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/CAS.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": ["watch", "run", "--project", "${workspaceFolder}/CAS.sln"], + "problemMatcher": "$msCompile" + } + ] +}