Skip to content

Commit

Permalink
Finish feature/windows docker
Browse files Browse the repository at this point in the history
Windows container
  • Loading branch information
dragos-dobre authored Apr 27, 2020
2 parents 72b1437 + 0506072 commit ebb9da6
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM node:10 AS react-build
RUN mkdir app
COPY . /app/
COPY ./ /app
WORKDIR /app
RUN node openimis-config.js
RUN . ./modules-installs.txt
RUN yarn install --network-timeout 1000000
RUN yarn build
RUN yarn global add serve
RUN yarn global add serve
CMD ["serve","-s","build"]
60 changes: 60 additions & 0 deletions Dockerfile_win
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
ARG INSTALL_BASE="mcr.microsoft.com/windows/servercore"
ARG INSTALL_TAG="ltsc2016"
ARG WINDOWS_VERSION="4.8-windowsservercore-ltsc2016"
ARG WINDOWS_BASE="mcr.microsoft.com/dotnet/framework/aspnet"

#FROM "${INSTALL_BASE}:${INSTALL_TAG}" AS downloader
#ARG NEW_OPENIMIS_HOST
#ENV NPM_CONFIG_LOGLEVEL info
#ARG NODE_VERSION="10.16.3"
#ARG ARCH="64"


#SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
#WORKDIR C:/dl
#ARG NODE_URL="https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-x${ARCH}.msi"

## download node and build the front end
#RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;\
# Invoke-WebRequest -Uri $Env:NODE_URL -OutFile nodejs.msi -UseBasicParsing;\
# Start-Process msiexec.exe -Wait -ArgumentList '/q /i nodejs.msi';
#RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;\
# Invoke-WebRequest -Uri https://classic.yarnpkg.com/latest.msi -OutFile yarn.msi -UseBasicParsing;\
# Start-Process msiexec.exe -Wait -ArgumentList '/q /i yarn.msi';

#COPY ./ C:/app

#WORKDIR C:/app
#RUN node openimis-config.js
#RUN ./modules-installs.txt;
#RUN yarn install --network-timeout 1000000
#RUN yarn build



FROM "${WINDOWS_BASE}:${WINDOWS_VERSION}"
ARG OPENIMIS_VERSION="1.4.1"
LABEL vendor="openIMIS"\
maintainer="Patrick Delcroix <patrick.delcroix@swisspth.ch>"\
org.openimis.webapp.is-beta= \
org.openimis.webapp.is-production="" \
org.openimis.webapp.version="${OPENIMIS_VERSION}"
ADD https://github.com/openimis/web_app_vb/releases/download/v${OPENIMIS_VERSION}/openIMIS_Web_App_x64_v${OPENIMIS_VERSION}.zip /temp/openIMIS.zip
ADD "https://github.com/openimis/web_service_vb/releases/download/v1.2.1/openIMIS_Web_Services_v1.2.1.zip" /temp/Service.zip
# ADD "https://github.com/openimis/policy_renewal_service_vb/releases/download/v1.2.0/ImisPolicyRenewalSetup.zip" /temp/Renewal.zip
# ADD "https://github.com/openimis/assign_photo_service_vb/releases/download/v1.2.0/AssignPhotosSetup.zip" /temp/photo.zip
# ADD "https://github.com/openimis/feedback_prompt_service_vb/releases/download/v1.2.0/ImisFeedbackPromptSetup.zip" /temp/feedback.zip
ADD "https://github.com/shibayan/iislua/releases/download/v0.6.1/iislua_x64.msi" /temp/iislua_x64.msi
ADD "https://go.microsoft.com/fwlink/?LinkID=615136" /temp/ARS.mis
COPY script/configureConnectionStr.ps1 /temp/configureConnectionStr.ps1
COPY script/InstallopenIMIS.ps1 /temp/InstallopenIMIS.ps1
RUN powershell -Command /temp/InstallopenIMIS.ps1 $env:username;\
Start-Process msiexec.exe -Wait -ArgumentList '/q /i /temp/iislua_x64.msi';
RUN Start-Process msiexec.exe -Wait -ArgumentList '/q /i /temp/ars.msi';
#ADD https://github.com/openimis/openimis-fe_js/releases/download/v1.1.0/openIMIS_FE_v1.1.0.zip C:/temp/build.zip
#RUN Expand-Archive -Path C:/temp/build.zip -DestinationPath C:/inetpub/wwwroot/openIMIS/front

WORKDIR "/inetpub/wwwroot"
#COPY --from=downloader /app/build /inetpub/wwwroot/openIMIS/front

ENTRYPOINT ["powershell","-Command","C:\\temp\\configureConnectionStr.ps1"]
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# openIMIS Frontent Reference Implementation
# openIMIS Frontent Reference Implementation : Windows Docker
This repository holds the configuration files for the openIMIS Frontend Reference Implementation:
- Legacy web applictation
- Modular front end

Please look for the direction on the openIMIS Wiki: https://openimis.atlassian.net/wiki/spaces/OP/pages/963182705/MO1.1+Install+the+modular+openIMIS+using+Docker

Note: the modular frontend is part of the release ZIP of the legacy webapp, if the modular frontend need to be changed then new modular frontend static files need to be placed in /inetroot/www/openIMIS/front

Note 2: The docker file can be change to build first the frontend by uncommenting the "downloader" related lines.

This repo branches, tags,... are maintained by openIMIS official delivery team who use it to build the official openIMIS Docker images containing the official modules (versions) list.

In case of troubles, please consult/contact our service desk via our [ticketing site](https://openimis.atlassian.net/servicedesk/customer).

# openIMIS Frontent Reference Implementation : Linux
This repository holds the configuration files for the openIMIS Frontend Reference Implementation.
It serves 2 distinct use cases:
- developers who want to implement new modules or modify existing frontend modules of openIMIS
Expand Down Expand Up @@ -81,4 +96,4 @@ When release candidate is accepted:
* tag the git repo according to your new version number
* upload openimis-be docker image to docker hub

Note: This image only provides the openimis frontend server. The full openIMIS deployment (with the backend,...) is managed from openimis-dist_dck repo and its docker-compose.yml file.
Note: This image only provides the openimis frontend server. The full openIMIS deployment (with the backend,...) is managed from openimis-dist_dck repo and its docker-compose.yml file.
60 changes: 60 additions & 0 deletions script/InstallopenIMIS.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#https://blog.backslasher.net/event-log-permissions-with-scripts.html
param(
[string]$IISUser = 'IIS_IUSRS',
[string]$source='IMIS',
[string]$LogName="$source-LOG",
[string]$SiteName = "Default Web Site",
[string]$PathZip = "/temp"
)
#configure ISS
Import-Module WebAdministration

$ZipFiles = Get-ChildItem "$PathZip/" -Filter *.zip
Write-Output "move app binaries in wwwroot"

if(Test-Path IIS:\Sites\$SiteName){
Write-output "Site $Sitename exist"
} else{
Write-output "Site $Sitename doesn't exist, create it"
New-WebSite -Name $Sitename -IPAddress -PhysicalPath /inetpub/wwwroot/
}
foreach($Zip in $ZipFiles){
$ZipName = $Zip.BaseName
New-Item -ItemType directory -Path /temp/$ZipName
Expand-Archive $PathZip/$Zip -DestinationPath /temp/$ZipName/
$singleFile = (Get-ChildItem /temp/$ZipName/ | Measure-Object).count
$subdirectoryPath = ""
Write-output " number of file found $singleFile"
if($singleFile -eq 1){
$subdirectoryPath = Get-ChildItem -Directory /temp/$ZipName/ -Name | Select-Object -First 1
Write-Output "sub directory $subdirectoryPath detected "
$subdirectoryPath = "/$subdirectoryPath"
}
if($ZipName -eq "openIMIS"){
New-Item -ItemType directory -Path /inetpub/wwwroot/$ZipName
Set-ItemProperty "IIS:\Sites\$SiteName\" -name physicalPath -value C:\inetpub\wwwroot\$ZipName
Move-Item -Path "/temp/$ZipName$subdirectoryPath/*" -Destination "/inetpub/wwwroot/$ZipName/"
Write-Output "Create a copy of the $ZipName config files"
Copy-Item "/inetpub/wwwroot/$ZipName/Web.config" -Destination "/inetpub/wwwroot/$ZipName/Web.config.sample"
}elseif(Test-Path "/temp/$ZipName$subdirectoryPath/Web.config"){
New-Item -ItemType directory -Path /inetpub/wwwroot/$ZipName
New-WebApplication -Name $ZipName -Site $SiteName -PhysicalPath C:\inetpub\wwwroot\$ZipName -ApplicationPool DefaultAppPool
Move-Item -Path "/temp/$ZipName$subdirectoryPath/*" -Destination "/inetpub/wwwroot/$ZipName/"
Write-Output "Create a copy of the $ZipName config files"
Copy-Item "/inetpub/wwwroot/$ZipName/Web.config" -Destination "/inetpub/wwwroot/$ZipName/Web.config.sample"
}else{
Write-Output "Move $ZipName in the service directory"
New-Item -ItemType directory -Path /service/$ZipName
Move-Item -Path "/temp/$ZipName$subdirectoryPath/*" -Destination /service/$ZipName/
}

}

Write-Output "Create the eventlog/source"
New-EventLog -LogName $LogName -Source $source
Write-Output "give the right to $IISUser to the eventlog"
$LogPath = 'HKLM:\SYSTEM\CurrentControlSet\services\EventLog\'+$LogName;
$acl = Get-Acl $LogPath
$ace = New-Object System.Security.AccessControl.RegistryAccessRule $IISUser,'WriteKey, ReadKey','allow'
$acl.AddAccessRule($ace)

38 changes: 38 additions & 0 deletions script/configureConnectionStr.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
param(
[string]$DB_HOSTNAME=$Env:DB_HOST,
[string]$DB_NAME=$Env:DB_NAME,
[string]$DB_USER=$Env:DB_USER,
[string]$DB_PASSWORD=$Env:DB_PASS
)

Write-Output 'Old config: '
Write-Output 'Source=[DatabaseIPAdress];Initial Catalog=IMIS;User ID=[ImisUserId];Password=[ImisUserPassword]'
Write-Output 'New config: '
Write-Output "Source=$DB_HOSTNAME;Initial Catalog=$DB_NAME;User ID=$DB_USER;Password=$DB_PASSWORD"
$WebDirectories = Get-ChildItem -Directory /inetpub/wwwroot/
foreach($webRoot in $WebDirectories){
$webRootName = $webRoot.Name
Write-Output "write the $webRootName config files"
if (Test-Path /inetpub/wwwroot/$webRootName/Web.config){
(Get-Content /inetpub/wwwroot/$webRootName/Web.config.sample)`
-replace '\[DatabaseIPAdress\]',$DB_HOSTNAME`
-replace '\[ImisUserId\]',$DB_USER`
-replace '\[IMISDB\]',$DB_NAME`
-replace '\[ImisUserPassword\]',$DB_PASSWORD`
| Out-File -Encoding UTF8 /inetpub/wwwroot/$webRootName/Web.config;`
Write-Output ('Pointing to legacy openIMIS on https://'+$Env:LEGACY_OPENIMIS_HOST)
}
}

Write-Output "launch IIS"
$ISSprocess = (Start-Process C:\ServiceMonitor.exe -ArgumentList 'w3svc' -PassThru )
$handle = $proc.Handle
$ISSprocess.WaitForExit();
While ($true){
Get-EventLog -LogName IMIS-LOG -Source IMIS -After (Get-Date).AddMinutes(-1) | Sort-Object Time
if ($ISSprocess.ExitCode -ne 0) {
Write-Warning "$_ exited with status code $($proc.ExitCode)"
break;
}
Start-Sleep -s 60
}
27 changes: 27 additions & 0 deletions script/downloadIMIS.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
param(
[string]$PathZip = "/temp"
)

#setting https protocols
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# lattest open IMIS binaries
$urlWebApp = "https://github.com/openimis/web_app_vb/releases/download/v1.3.0/openIMIS_Web_App_x64_v1.3.0.zip"
$urlWebService = "https://github.com/openimis/web_service_vb/releases/download/v1.2.1/openIMIS_Web_Services_v1.2.1.zip"
# $urlRenewalService = "https://github.com/openimis/policy_renewal_service_vb/releases/download/v1.2.0/ImisPolicyRenewalSetup.zip"
#$urlBackupService = "https://github.com/openimis/backup_service_vb/releases/download/v1.2.0/ImisBackupSetupx64.zip"
# $urlPhotoService = "https://github.com/openimis/assign_photo_service_vb/releases/download/v1.2.0/AssignPhotosSetup.zip"
# $urlfeedbackService = "https://github.com/openimis/feedback_prompt_service_vb/releases/download/v1.2.0/ImisFeedbackPromptSetup.zip"
#dowload
Write-Output "download OpenIMIS binaries"
Invoke-WebRequest -Uri $urlWebApp -OutFile "$PathZip/openIMIS.zip"
Write-Output "download web services binaries"
Invoke-WebRequest -Uri $urlWebService -OutFile "$PathZip/Service.zip"
Write-Output "download Renewal service binaries"
# Invoke-WebRequest -Uri $urlRenewalService -OutFile "$PathZip/RenewalService.zip"
#Write-Output "download Backup service binaries"
#Invoke-WebRequest -Uri $urlBackupService -OutFile "$PathZip/BackupService.zip"
# Write-Output "download Photo update service binaries"
# Invoke-WebRequest -Uri $urlPhotoService -OutFile "$PathZip/PhotoService.zip"
# Write-Output "download Feedback prompt binaries"
# Invoke-WebRequest -Uri $urlfeedbackService -OutFile "$PathZip/FBService.zip"
# Write-Output "uncompress app binaries"

0 comments on commit ebb9da6

Please sign in to comment.