romaklimenko
10/28/2016 - 1:36 PM

Running Sitecore 8.2 in a Docker container http://romaklimenko.com/posts/2016/10/29/running-sitecore-in-docker-container-is-easier-than-you-

# See also:
#   - https://github.com/Microsoft/sql-server-samples/tree/master/samples/manage/windows-containers/mssql-server-2016-express-windows

Set-StrictMode -Version latest ;

Stop-Service MSSQL`$SQLEXPRESS ;

Set-ItemProperty -Path 'HKLM:\software\microsoft\microsoft sql server\mssql13.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -Name tcpdynamicports -Value '' ;
Set-ItemProperty -Path 'HKLM:\software\microsoft\microsoft sql server\mssql13.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -Name tcpport -Value 1433 ;
Set-ItemProperty -Path 'HKLM:\software\microsoft\microsoft sql server\mssql13.SQLEXPRESS\mssqlserver' -Name LoginMode -Value 2 ;

Start-Service MSSQL`$SQLEXPRESS ;

Invoke-Sqlcmd -Query "ALTER LOGIN sa with password='Str0ng_En0ugh'; ALTER LOGIN sa ENABLE;" -ServerInstance "." ;

Invoke-Sqlcmd -Query "CREATE DATABASE Sitecore_Analytics ON (FILENAME = 'C:\sitecore\Databases\Sitecore.Analytics.mdf'), (FILENAME = 'C:\sitecore\Databases\Sitecore.Analytics.ldf') FOR ATTACH ;" -ServerInstance "." ;
Invoke-Sqlcmd -Query "CREATE DATABASE Sitecore_Core      ON (FILENAME = 'C:\sitecore\Databases\Sitecore.Core.mdf'),      (FILENAME = 'C:\sitecore\Databases\Sitecore.Core.ldf')      FOR ATTACH ;" -ServerInstance "." ;
Invoke-Sqlcmd -Query "CREATE DATABASE Sitecore_Master    ON (FILENAME = 'C:\sitecore\Databases\Sitecore.Master.mdf'),    (FILENAME = 'C:\sitecore\Databases\Sitecore.Master.ldf')    FOR ATTACH ;" -ServerInstance "." ;
Invoke-Sqlcmd -Query "CREATE DATABASE Sitecore_Web       ON (FILENAME = 'C:\sitecore\Databases\Sitecore.Web.mdf'),       (FILENAME = 'C:\sitecore\\Databases\Sitecore.Web.ldf')      FOR ATTACH ;" -ServerInstance "." ;
# See also:
#   - https://github.com/microsoft/iis-docker/blob/master/windowsservercore/Dockerfile
#   - https://github.com/microsoft/aspnet-docker/blob/master/4.6.2/Dockerfile

Add-WindowsFeature Web-Server
Add-WindowsFeature NET-Framework-45-ASPNET
Add-WindowsFeature Web-Asp-Net45

C:\Windows\System32\inetsrv\appcmd.exe delete site "default web site"

C:\Windows\System32\inetsrv\appcmd.exe add site /name:Sitecore /bindings:http/*:80: /physicalPath:c:\sitecore\Website

C:\Windows\System32\inetsrv\appcmd.exe start site Sitecore

iisreset
FROM microsoft/windowsservercore

LABEL Description="Sitecore 8.2 rev. 160729" Vendor="Sitecore" Version="8.2 rev. 160729"

# Adding the files
COPY . /
WORKDIR /

# Installing MS SQL Server
RUN SQLEXPR_x64_ENU.exe /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 && del /F /Q SQLEXPR_x64_ENU.exe && rd /q /s setup

# Setting up MS SQL Server and attaching databases
RUN powershell ./sql.ps1 -Verbose

# Setting up IIS and adding the website
RUN powershell ./iis.ps1 -Verbose

EXPOSE 80