Skip to content

Commit bb484e3

Browse files
Merge pull request #116 from michaelPf85/latest-php-version
Dynamically get latest PHP version
2 parents 283aa1e + a163dbb commit bb484e3

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

php/Dockerfile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ FROM microsoft/iis:windowsservercore
22

33
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
44

5-
ENV PHP_VERSION 7.1.3
6-
ENV PHP_SHA1 4000132114cecdec82c83b09aed6a962ed928e0b
7-
85
WORKDIR /Users/ContainerAdministrator/Downloads
96

107
# Visual C++ 2015 Redistributable
@@ -13,8 +10,16 @@ RUN Invoke-WebRequest 'https://download.microsoft.com/download/9/3/F/93FCF1E7-E6
1310
Remove-Item vc_redist.x64.exe;
1411

1512
# Install PHP
16-
RUN Invoke-WebRequest $('http://windows.php.net/downloads/releases/php-{0}-nts-Win32-VC14-x64.zip' -f $env:PHP_VERSION) -OutFile 'php.zip'; \
17-
if ((Get-FileHash php.zip -Algorithm sha1).Hash -ne $env:PHP_SHA1) {exit 1} ; \
13+
RUN $download_page = Invoke-WebRequest -UseBasicParsing -Uri 'http://windows.php.net/download'; \
14+
$re = 'php-\d.+-nts.+x64\.zip$'; \
15+
$url = $download_page.links | ? href -match $re | % href | select -First 1; \
16+
$filename = $url.Substring(20); \
17+
$checksums = Invoke-WebRequest -UseBasicParsing -Uri 'http://windows.php.net/downloads/releases/sha1sum.txt'; \
18+
$sumpattern = '([0-9A-F]+)\s+'+$filename; \
19+
$checksums.Content.Split(\"`n\") | Select-String -Pattern $sumpattern | %{ $sum = $_.Matches[0].Groups[1].Value.ToUpper() }; \
20+
$fullurl = 'http://windows.php.net' + $url; \
21+
Invoke-WebRequest -UseBasicParsing -Uri $fullurl -OutFile php.zip; \
22+
if ((Get-FileHash php.zip -Algorithm sha1).Hash -ne $sum) {exit 1} ; \
1823
Expand-Archive -Path php.zip -DestinationPath c:\php; \
1924
[Environment]::SetEnvironmentVariable('PATH', $env:Path + ';C:\php', [EnvironmentVariableTarget]::Machine); \
2025
$env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \
@@ -36,7 +41,7 @@ RUN .\configure_iis.ps1; \
3641
Remove-Item configure_iis.ps1;
3742

3843
# Expose the Site
39-
RUN New-WebSite -Name "www" -PhysicalPath C:\www -Port 80
44+
RUN New-WebSite -Name 'www' -PhysicalPath C:\www -Port 80
4045

4146
# Change working directory to web root
4247
WORKDIR /www

0 commit comments

Comments
 (0)