diff --git a/Dockerfile b/Dockerfile index 9789606..e5cd4a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ No newline at end of file +RUN yarn global add serve +CMD ["serve","-s","build"] diff --git a/Dockerfile_win b/Dockerfile_win new file mode 100644 index 0000000..c99eeb2 --- /dev/null +++ b/Dockerfile_win @@ -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 "\ + 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"] diff --git a/README.md b/README.md index b50d5ce..a591dc6 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. \ No newline at end of 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. diff --git a/script/InstallopenIMIS.ps1 b/script/InstallopenIMIS.ps1 new file mode 100644 index 0000000..ec4d9f4 --- /dev/null +++ b/script/InstallopenIMIS.ps1 @@ -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) + diff --git a/script/configureConnectionStr.ps1 b/script/configureConnectionStr.ps1 new file mode 100644 index 0000000..d8e4ae3 --- /dev/null +++ b/script/configureConnectionStr.ps1 @@ -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 +} \ No newline at end of file diff --git a/script/downloadIMIS.ps1 b/script/downloadIMIS.ps1 new file mode 100644 index 0000000..e5b04a9 --- /dev/null +++ b/script/downloadIMIS.ps1 @@ -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" \ No newline at end of file