This repository has been archived by the owner on Mar 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from pandell/initial-dockerfiles
Initial dockerfiles
- Loading branch information
Showing
12 changed files
with
412 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.json] | ||
indent_size = 2 | ||
|
||
[*.yml] | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# For detailed discussion of line-endings and .gitattributes see | ||
# http://stackoverflow.com/questions/170961/whats-the-best-crlf-handling-strategy-with-git | ||
|
||
# Set default behaviour, in case users don't have core.autocrlf set. | ||
* text=auto | ||
|
||
# Text files that should be normalized (convert crlf => lf) | ||
.gitignore text | ||
.gitattr* text | ||
*.asax text | ||
*.ascx text | ||
*.ashx text | ||
*.aspx text | ||
*.bmml text | ||
*.cd text | ||
*.cmd text | ||
*.config text | ||
*.cs text diff=csharp | ||
*.cshtml text | ||
*.csproj text | ||
*.css text | ||
*.datasource text | ||
*.htc text | ||
*.htm text diff=html | ||
*.html text diff=html | ||
*.js text | ||
*.json text | ||
*.Master text | ||
*.md text | ||
*.mrt text | ||
*.patch text | ||
*.proj text | ||
*.ps1 text | ||
*.rdlc text | ||
*.resx text | ||
*.settings text | ||
*.sql text | ||
*.targets text | ||
*.tt text | ||
*.txt text | ||
*.vbs text | ||
*.xml text | ||
*.xsd text | ||
*.xslt text | ||
|
||
# Text files with forced crlf | ||
*.DotSettings text eol=crlf | ||
*.FxCop text eol=crlf | ||
*.sln text eol=crlf | ||
|
||
# Text files with forced lf | ||
package.json text eol=lf | ||
yarn.lock text eol=lf | ||
*.snap text eol=lf | ||
**/bin/*.js text eol=lf | ||
|
||
# Binary files (left alone) | ||
*.bmp binary | ||
*.dll binary | ||
*.exe binary | ||
*.gif binary | ||
*.ico binary | ||
*.jpg binary | ||
*.mdf binary | ||
*.png binary | ||
*.psd binary | ||
*.snk binary | ||
*.vsd binary | ||
*.xlsx binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"tabWidth": 4, | ||
"printWidth": 120, | ||
"quoteProps": "preserve", | ||
"overrides": [ | ||
{ | ||
"files": ["*.json", ".*.json", "*.yml"], | ||
"options": { | ||
"tabWidth": 2 | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": [ | ||
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp | ||
"EditorConfig.editorconfig", | ||
"esbenp.prettier-vscode", | ||
"ms-azuretools.vscode-docker", | ||
"ms-vscode.powershell" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Pandell Dockerfiles & Examples | ||
|
||
This repository contains Dockerfiles and example configurations for running Pandell applications in development environments. | ||
|
||
## Goals | ||
|
||
- Try to replicate a production-ish environment to run applications | ||
- Support default [container isolation mode](https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/hyperv-container) for whichever host OS is being used | ||
- Default isolation mode on Windows 10 is HyperV Isolation | ||
- Default isolation mode on Windows Server 2019 is Process Isolation | ||
- Therefore, containers targeting Windows Server 2019 should work by default on both host OSes | ||
- Support using Windows Server 2019 (without GUI) as a host-in-a-VM for non-Windows workstations | ||
- With (default) process isolation mode, nested virtualization is not required | ||
- Can use `docker-machine env` to connect to Docker host on VM | ||
|
||
## Dockerfiles | ||
|
||
### `aspnet-framework` | ||
|
||
- Windows Server 2019 | ||
- IIS 10 with .NET Framework 4.8 | ||
- URL Rewrite Module | ||
- Authentication sections in `ApplicationHost.config` unlocked | ||
- Debug utilities | ||
|
||
### `mssql-windows` | ||
|
||
Forked from [mssql-docker](https://github.com/microsoft/mssql-docker/blob/e4afa866646c25decef32f8946a995074c3251e7/windows/mssql-server-windows-express/dockerfile) to support Windows Server 2019. | ||
|
||
- Windows Server 2019 | ||
- SQL Server Express 2017 | ||
|
||
## Samples | ||
|
||
### `pli` | ||
|
||
- Shows an example using `docker-compose` that launches an application server and a database | ||
- Code is compiled on the developer workstation | ||
- Data directories and compilation output folders are mounted as volumes inside the containers | ||
- For databases, allows persistence between container runs | ||
- For application, allows for the familiar rebuild+refresh development flow | ||
- Some initial setup is required for restoring a database, but could be automated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# escape=` | ||
|
||
ARG DOTNET_VERSION=4.8 | ||
FROM mcr.microsoft.com/dotnet/framework/aspnet:${DOTNET_VERSION} | ||
|
||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] | ||
|
||
# Microsoft is not willing to enable URL Rewrite Module by default, | ||
# so we must do it here (https://github.com/microsoft/dotnet-framework-docker/issues/369) | ||
ADD https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi c:/inetpub/rewrite_amd64_en-US_2.1.msi | ||
RUN Start-Process c:/inetpub/rewrite_amd64_en-US_2.1.msi -ArgumentList "/qn" -Wait | ||
|
||
# unlock authentication modes in global configuration, since we use them in our web.config files | ||
RUN C:/Windows/System32/inetsrv/appcmd.exe unlock config -section:"system.webServer/security/authentication/anonymousAuthentication" -commit:apphost; ` | ||
C:/Windows/System32/inetsrv/appcmd.exe unlock config -section:"system.webServer/security/authentication/windowsAuthentication" -commit:apphost | ||
|
||
# copy debug script to C:/debug.ps1; when this is run, it starts | ||
# a dbgview process (redirecting output to a log file) and a LogMonitor | ||
# process that interleaves debug output with IIS/Application event log | ||
# output to STDOUT | ||
COPY debug.ps1 / | ||
|
||
# add C:/docker/dbgview.exe for use with debug.ps1 | ||
ADD https://live.sysinternals.com/Dbgview.exe /docker/dbgview.exe | ||
|
||
# add LogMonitor for redirecting various output/event sources to stdout | ||
# (see https://github.com/microsoft/windows-container-tools/tree/master/LogMonitor) | ||
ADD https://github.com/microsoft/windows-container-tools/releases/download/v1.0/LogMonitor.exe /docker/LogMonitor.exe | ||
COPY LogMonitorConfig.json /docker/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"LogConfig": { | ||
"sources": [ | ||
{ | ||
"type": "EventLog", | ||
"startAtOldestRecord": false, | ||
"eventFormatMultiLine": false, | ||
"channels": [ | ||
{ | ||
"name": "application", | ||
"level": "Warning" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "File", | ||
"directory": "c:\\inetpub\\logs", | ||
"filter": "*.log", | ||
"includeSubdirectories": true | ||
}, | ||
{ | ||
"type": "File", | ||
"directory": "c:\\docker", | ||
"filter": "*.log", | ||
"includeSubdirectories": false | ||
}, | ||
{ | ||
"type": "ETW", | ||
"eventFormatMultiLine": false, | ||
"providers": [ | ||
{ | ||
"providerName": "IIS: WWW Server", | ||
"providerGuid": "3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83", | ||
"level": "Information" | ||
}, | ||
{ | ||
"providerName": "Microsoft-Windows-IIS-Logging", | ||
"providerGuid": "7E8AD27F-B271-4EA2-A783-A47BDE29143B", | ||
"level": "Information" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# starts the LogMonitor process, wrapping dbgview, and pipes | ||
# various output sources to stdout | ||
Start-Process -FilePath C:/docker/LogMonitor.exe -ArgumentList "/config","C:/docker/LogMonitorConfig.json","C:/docker/dbgview.exe","/l","C:/docker/dbgview-output.log","/g","/n","/accepteula" -NoNewWindow -Wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# escape=` | ||
|
||
# adapted from https://github.com/microsoft/mssql-docker/blob/e4afa866646c25decef32f8946a995074c3251e7/windows/mssql-server-windows-express/dockerfile | ||
|
||
ARG WINDOWS_SERVER_VERSION=ltsc2019 | ||
FROM mcr.microsoft.com/windows/servercore:${WINDOWS_SERVER_VERSION} | ||
|
||
# Download Links: | ||
ENV sql_express_download_url "https://go.microsoft.com/fwlink/?linkid=829176" | ||
|
||
ENV sa_password="_" ` | ||
attach_dbs="[]" ` | ||
ACCEPT_EULA="_" ` | ||
sa_password_path="C:/ProgramData/Docker/secrets/sa-password" | ||
|
||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] | ||
|
||
WORKDIR / | ||
|
||
RUN Invoke-WebRequest -Uri $env:sql_express_download_url -OutFile sqlexpress.exe ; ` | ||
Start-Process -Wait -FilePath ./sqlexpress.exe -ArgumentList /qs, /x:setup ; ` | ||
./setup/setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\\System' /SQLSYSADMINACCOUNTS='BUILTIN\\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS ; ` | ||
Remove-Item -Recurse -Force sqlexpress.exe, setup | ||
|
||
RUN stop-service MSSQL`$SQLEXPRESS ; ` | ||
set-itemproperty -path 'HKLM:\\software\\microsoft\\microsoft sql server\\mssql14.SQLEXPRESS\\mssqlserver\\supersocketnetlib\\tcp\\ipall' -name tcpdynamicports -value '' ; ` | ||
set-itemproperty -path 'HKLM:\\software\\microsoft\\microsoft sql server\\mssql14.SQLEXPRESS\\mssqlserver\\supersocketnetlib\\tcp\\ipall' -name tcpport -value 1433 ; ` | ||
set-itemproperty -path 'HKLM:\\software\\microsoft\\microsoft sql server\\mssql14.SQLEXPRESS\\mssqlserver\\' -name LoginMode -value 2 ; | ||
|
||
COPY start.ps1 / | ||
|
||
CMD .\start -sa_password $env:sa_password -ACCEPT_EULA $env:ACCEPT_EULA -attach_dbs \"$env:attach_dbs\" -Verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Sets sa password and starts SQL Service, attaching additional databases from disk | ||
|
||
# adapted from https://github.com/microsoft/mssql-docker/blob/e4afa866646c25decef32f8946a995074c3251e7/windows/mssql-server-windows-express/start.ps1 | ||
|
||
param( | ||
[Parameter(Mandatory = $false)] | ||
[string]$sa_password, | ||
|
||
[Parameter(Mandatory = $false)] | ||
[string]$ACCEPT_EULA, | ||
|
||
[Parameter(Mandatory = $false)] | ||
[string]$attach_dbs | ||
) | ||
|
||
|
||
if ($ACCEPT_EULA -ne "Y" -And $ACCEPT_EULA -ne "y") { | ||
Write-Verbose "ERROR: You must accept the End User License Agreement before this container can start." | ||
Write-Verbose "Set the environment variable ACCEPT_EULA to 'Y' if you accept the agreement." | ||
|
||
exit 1 | ||
} | ||
|
||
# start the service | ||
Write-Verbose "Starting SQL Server" | ||
start-service MSSQL`$SQLEXPRESS | ||
|
||
if ($sa_password -eq "_") { | ||
$secretPath = $env:sa_password_path | ||
if (Test-Path $secretPath) { | ||
$sa_password = Get-Content -Raw $secretPath | ||
} | ||
else { | ||
Write-Verbose "WARN: Using default SA password, secret file not found at: $secretPath" | ||
} | ||
} | ||
|
||
if ($sa_password -ne "_") { | ||
Write-Verbose "Changing SA login credentials" | ||
$sqlcmd = "ALTER LOGIN sa with password=" + "'" + $sa_password + "'" + ";ALTER LOGIN sa ENABLE;" | ||
& sqlcmd -Q $sqlcmd | ||
} | ||
|
||
$attach_dbs_cleaned = $attach_dbs.TrimStart('\\').TrimEnd('\\') | ||
|
||
$dbs = $attach_dbs_cleaned | ConvertFrom-Json | ||
|
||
if ($null -ne $dbs -And $dbs.Length -gt 0) { | ||
Write-Verbose "Attaching $($dbs.Length) database(s)" | ||
|
||
Foreach ($db in $dbs) { | ||
$files = @(); | ||
Foreach ($file in $db.dbFiles) { | ||
$files += "(FILENAME = N'$($file)')"; | ||
} | ||
|
||
$files = $files -join "," | ||
$sqlcmd = "IF EXISTS (SELECT 1 FROM SYS.DATABASES WHERE NAME = '" + $($db.dbName) + "') BEGIN EXEC sp_detach_db [$($db.dbName)] END;CREATE DATABASE [$($db.dbName)] ON $($files) FOR ATTACH;" | ||
|
||
Write-Verbose "Invoke-Sqlcmd -Query $($sqlcmd)" | ||
& sqlcmd -Q $sqlcmd | ||
} | ||
} | ||
|
||
Write-Verbose "Started SQL Server." | ||
|
||
$lastCheck = (Get-Date).AddSeconds(-2) | ||
while ($true) { | ||
Get-EventLog -LogName Application -Source "MSSQL*" -After $lastCheck | Select-Object TimeGenerated, EntryType, Message | ||
$lastCheck = Get-Date | ||
Start-Sleep -Seconds 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SOLUTION_ROOT=. |
Oops, something went wrong.