Skip to content

Commit 487a973

Browse files
committed
build: removed all references to ssl
1 parent 581219e commit 487a973

7 files changed

Lines changed: 21 additions & 126 deletions

File tree

README.md

Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ HTTP_PORT=8006
8989
HTTPS_PORT=8007
9090
ENV=docker-dev
9191
TAG=local
92-
secretstore_password_path=C:\Automation\secretstorepasswd.xml
93-
secretstore_vault_name=MyVaultName
9492
ROOT_PATH=../../../../../ # your solution folder
9593
```
9694

@@ -112,100 +110,10 @@ If needed variables are not defined by one of the two first methods, it will sta
112110
|csproj Path|CSPROJ_PATH|"./**/*.csproj"| The path to your .csproj
113111
|sln Path|SLN_PATH|"./*.sln"| The path to your .sln
114112
|Entrypoint Script Path|ENTRYPOINT_SCRIPT_PATH|"./.build/DynamicDockerCompose/Scripts/entrypoint.sh"| The path to the entrypoint shell bash
115-
|Certificate Path|CERTIFICATE_PATH|SecretStore|The path to your valid HTTPS certificate
116-
|Certificate Password|CERTIFICATE_PASSWORD|SecretStore|The HTTPS certificate password
117113

118114
## Local certificates for development purposes
119115

120-
If you don't already have one, create your trusted HTTPS development certificate:
121-
122-
```powershell
123-
124-
PM > dotnet dev-certs https --clean
125-
//Cleaning HTTPS development certificates from the machine. A prompt might get displayed to confirm the removal of some of the certificates.
126-
//HTTPS development certificates successfully removed from the machine.
127-
128-
PM > dotnet dev-certs https -ep $env:USERPROFILE\.aspnet\https\aspnetapp.pfx --trust
129-
//Trusting the HTTPS development certificate was requested.A confirmation prompt will be displayed if the certificate was not previously trusted.Click yes on the prompt to trust the certificate.
130-
//Successfully created and trusted a new HTTPS certificate.
131-
132-
PM > dotnet dev-certs https --check
133-
//A valid certificate was found: C40087E6CA2F2A811F3BF78E3C5FE6BA8FA2XXXX - CN = localhost - Valid from 2023 - 01 - 27 23:21:10Z to 2024 - 01 - 27 23:21:10Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
134-
//Run the command with both--check and --trust options to ensure that the certificate is not only valid but also trusted.
135-
136-
```
137-
138-
## Securing HTTPS certificate properties
139-
140-
Once the certificate is created, we will store its path and password as secrets in the PowerShell [SecretManagement and SecretStore](https://learn.microsoft.com/en-us/powershell/utility-modules/secretmanagement/how-to/using-secrets-in-automation?view=ps-modules) modules.
141-
142-
> More info available here : [Use the SecretStore in automation](https://learn.microsoft.com/en-us/powershell/utility-modules/secretmanagement/how-to/using-secrets-in-automation?view=ps-modules)
143-
144-
```powershell
145-
Install-Module -Name Microsoft.PowerShell.SecretStore -Repository PSGallery -Force
146-
Install-Module -Name Microsoft.PowerShell.SecretManagement -Repository PSGallery -Force
147-
Import-Module Microsoft.PowerShell.SecretStore
148-
Import-Module Microsoft.PowerShell.SecretManagement
149-
```
150-
Get the identification information of the username 'SecureStore':
151-
152-
```powershell
153-
PS> $credential = Get-Credential -UserName 'SecureStore'
154-
155-
PowerShell credential request
156-
Enter your credentials.
157-
Password for user SecureStore: **************
158-
```
159-
160-
Once you set the password you can export it to an XML file, encrypted by Windows Data Protection (DPAPI).
161-
162-
```powershell
163-
$securePasswordPath = 'C:\Automation\securestorepasswd.xml'
164-
$credential.Password | Export-Clixml -Path $securePasswordPath
165-
```
166-
167-
### Register and configure your vault
168-
169-
Next you must configure the SecretStore vault. The configuration sets user interaction to None, so that SecretStore never prompts the user. The configuration requires a password, and the password is passed in as a SecureString object. The -Confirm:false parameter is used so that PowerShell does not prompt for confirmation.
170-
171-
```powershell
172-
Register-SecretVault -Name YourVaultName -ModuleName Microsoft.PowerShell.SecretStore
173-
$password = Import-CliXml -Path $securePasswordPath
174-
175-
$storeConfiguration = @{
176-
Authentication = 'Password'
177-
PasswordTimeout = 3600 # 1 hour
178-
Interaction = 'None'
179-
Password = $password
180-
Confirm = $false
181-
}
182-
Set-SecretStoreConfiguration @storeConfiguration
183-
```
184-
185-
Set your secrets
186-
187-
```powershell
188-
Unlock-SecretStore -Password $password
189-
Set-Secret -Name CERTIFICATE_PATH -Secret "/root/.aspnet/https/aspnetapp.pfx" -Vault YourVaultName -Metadata @{Purpose="Certificate Path"}
190-
Set-Secret -Name CERTIFICATE_PASSWORD -Secret "Password1" -Vault YourVaultName -Metadata @{Purpose="Certificate Password"}
191-
```
192-
193-
To get the list of all of your secrets, you can run:
194-
```powershell
195-
Get-SecretInfo -Name CERTIFICATE_PATH -Vault YourVaultName | Select Name, Type, VaultName, Metadata
196-
```
197-
To remove your vault, run:
198-
```powershell
199-
Unregister-SecretVault -Name YourVaultName
200-
```
201-
202-
Then, reference the secret store password location and the vault name in the .env file [as showed above](#setting-up-your-environment-file):
203-
```
204-
secretstore_password_path=C:\Automation\securestorepasswd.xml
205-
secretstore_vault_name=YourVaultName
206-
```
207-
208-
The script will try to unlock the specified vault with the provided password to get the HTTPS certificate path and password.
116+
I recommend using [DockerMkcertForLocalSSL](https://github.com/PixsysBE/DockerMkcertForLocalSSL) to easily take care of local SSL certificates. Copy/Paste the required files into the .config folder and follow instructions from the installation section.
209117

210118
## Compose your application
211119
> Make sure Docker Desktop is running first
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## [1.3.3](https://github.com/PixsysBE/DynamicDockerCompose/compare/v1.3.2...v1.3.3) (2024-09-05)
2+
3+
4+
### Bug Fixes
5+
6+
* removed init script ([581219e](https://github.com/PixsysBE/DynamicDockerCompose/commit/581219e4184e31d4f6664a57addf38d1e94d142d))

src/DynamicDockerCompose/DynamicDockerCompose/.build/DynamicDockerCompose/dynamic-docker-compose.functions.ps1

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,9 @@ Gets relative path from an absolute path
155155
# }
156156
function Get-Relative-Path-From-Absolute-Path {
157157
param (
158-
[string]$fromPath, # Chemin absolu du dossier d'origine
159-
[string]$toPath # Chemin absolu du dossier cible
158+
[string]$fromPath, # absolute path to source
159+
[string]$toPath, # absolute path to target
160+
[switch]$invertSlashs
160161
)
161162

162163
Write-Verbose ("[Get-Relative-Path-From-Absolute-Path] fromPath: $fromPath")
@@ -188,9 +189,12 @@ function Get-Relative-Path-From-Absolute-Path {
188189
$relativePath += ($toParts[$commonLength..($toParts.Length - 1)] -join $separator)
189190

190191
# Retire la barre oblique inverse finale si elle est présente
191-
$trimmedRelativePath = $relativePath.TrimEnd($separator)
192+
$trimmedRelativePath = ".\" + $relativePath.TrimEnd($separator)
192193

193-
return ".\${trimmedRelativePath}"
194+
if($invertSlashs.IsPresent){
195+
return $trimmedRelativePath -replace '\\', '/'
196+
}
197+
return $trimmedRelativePath
194198
}
195199

196200
<#

src/DynamicDockerCompose/DynamicDockerCompose/.build/DynamicDockerCompose/dynamic-docker-compose.ps1

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,7 @@ if($template -eq "dotnet-webapp")
8585
$csprojPath = Get-Variable-Absolute-Path -variableName "CSPROJ_PATH" -filter "*.csproj" -searchFromPath $env:rootAbsolutePath -excludePattern ".Tests.csproj"
8686
Add-Variable-To-Collection -name "CSPROJ_PATH" -value ( Get-Relative-Path-From-Absolute-Path -fromPath $env:rootAbsolutePath -toPath $csprojPath) -collection ([ref]$variables)
8787
$entrypointScriptPath = Get-Variable-Absolute-Path -variableName "ENTRYPOINT_SCRIPT_PATH" -filter "entrypoint.sh" -searchFromPath $env:rootAbsolutePath -Directory "**/.build/DynamicDockerCompose/Scripts" -collection ([ref]$variables) -envFileContent ([ref]$envFileContent)
88-
# Add-Variable-To-Collection -name "ENTRYPOINT_SCRIPT_PATH" -value $entrypointScriptPath -collection ([ref]$variables)
89-
Add-Variable-To-Collection -name "ENTRYPOINT_SCRIPT_PATH" -value ( Get-Relative-Path-From-Absolute-Path -fromPath $env:rootAbsolutePath -toPath $entrypointScriptPath) -collection ([ref]$variables)
90-
$secretstorePasswordPath = Get-Variable-Absolute-Path -variableName "secretstore_password_path" -searchFromPath $env:rootAbsolutePath -collection ([ref]$variables) -envFileContent ([ref]$envFileContent)
91-
Add-Variable-To-Collection -name "secretstore_password_path" -value $secretstorePasswordPath -collection ([ref]$variables)
92-
$secretstoreVaultName = Get-Variable-Absolute-Path -variableName "secretstore_vault_name" -searchFromPath $env:rootAbsolutePath -collection ([ref]$variables) -envFileContent ([ref]$envFileContent)
93-
Add-Variable-To-Collection -name "secretstore_vault_name" -value $secretstoreVaultName -collection ([ref]$variables)
94-
if ((-not [string]::IsNullOrWhiteSpace($secretstorePasswordPath)) -and (-not [string]::IsNullOrWhiteSpace($secretstorePasswordPath))) {
95-
# Unlock secret store to get secrets
96-
$secretstorePassword = Import-CliXml -Path $secretstorePasswordPath
97-
Unlock-SecretStore -Password $secretstorePassword
98-
Add-Variable-To-Collection -name CERTIFICATE_PATH -value (Get-Secret -Name CERTIFICATE_PATH -Vault $secretstoreVaultName -AsPlainText) -collection ([ref]$variables)
99-
Add-Variable-To-Collection -name CERTIFICATE_PASSWORD -value (Get-Secret -Name CERTIFICATE_PASSWORD -Vault $secretstoreVaultName -AsPlainText) -collection ([ref]$variables)
100-
}
88+
Add-Variable-To-Collection -name "ENTRYPOINT_SCRIPT_PATH" -value ( Get-Relative-Path-From-Absolute-Path -fromPath $env:rootAbsolutePath -toPath $entrypointScriptPath -invertSlashs) -collection ([ref]$variables)
10189
}
10290

10391
if($list.IsPresent){

src/DynamicDockerCompose/DynamicDockerCompose/.config/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ COPY --from=publish /app/publish .
2323

2424
# Copy and make executable the endpoint shell script
2525
ARG ENTRYPOINT_SCRIPT_PATH
26-
COPY ${ENTRYPOINT_SCRIPT_PATH} "./entrypoint.sh"
26+
COPY ["${ENTRYPOINT_SCRIPT_PATH}", "./entrypoint.sh"]
2727
RUN chmod +x ./entrypoint.sh
2828
ARG SOLUTION_NAME
2929
ENV DLLNAME="${SOLUTION_NAME}.dll"

src/DynamicDockerCompose/DynamicDockerCompose/.config/docker-compose.yaml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,5 @@ services:
1212
- ENTRYPOINT_SCRIPT_PATH=${ENTRYPOINT_SCRIPT_PATH}
1313
ports:
1414
- "${HTTP_PORT}:8080"
15-
- "${HTTPS_PORT}:443"
1615
environment:
17-
- ASPNETCORE_URLS=https://+;http://+
18-
- ASPNETCORE_HTTP_PORTS=${HTTP_PORT}
19-
- ASPNETCORE_HTTPS_PORTS=${HTTPS_PORT}
20-
- ASPNETCORE_ENVIRONMENT=${ENV}
21-
- ASPNETCORE_Kestrel__Certificates__Default__Path=${CERTIFICATE_PATH}
22-
- ASPNETCORE_Kestrel__Certificates__Default__Password=${CERTIFICATE_PASSWORD}
23-
volumes:
24-
- ${APPDATA}\microsoft\UserSecrets\:/root/.microsoft/usersecrets
25-
- ${USERPROFILE}\.aspnet\https:/root/.aspnet/https/
16+
- ASPNETCORE_ENVIRONMENT=${ENV}
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
COMPOSE_PROJECT_NAME=my-project # project name, will be used to generate containers names
2-
HTTP_PORT=8006
3-
HTTPS_PORT=8007
2+
HTTP_PORT=80
3+
HTTPS_PORT=443
44
ENV=docker-dev
5-
TAG=local
6-
secretstore_password_path=C:\Automation\secretstorepasswd.xml
7-
secretstore_vault_name=MyVaultName
5+
TAG=local

0 commit comments

Comments
 (0)