From 6282b7895150a0330045076c07859ea960f143c4 Mon Sep 17 00:00:00 2001 From: Bogdan Marian Date: Fri, 2 Dec 2022 11:43:11 +0200 Subject: [PATCH 1/9] Update PostgreSQL version to 15.1 --- .github/workflows/publishDockerImages.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publishDockerImages.yml b/.github/workflows/publishDockerImages.yml index 95eb9a8..b2747bc 100644 --- a/.github/workflows/publishDockerImages.yml +++ b/.github/workflows/publishDockerImages.yml @@ -10,7 +10,7 @@ on: env: DOCKER_IMAGE: "satrapu/postgresql" - POSTGRESQL_VERSION: "14.0" + POSTGRESQL_VERSION: "15.1" DOCKER_HUB_USER: "${{ secrets.DOCKER_HUB_USER }}" DOCKER_HUB_TOKEN: "${{ secrets.DOCKER_HUB_TOKEN }}" @@ -24,7 +24,7 @@ jobs: env: CI_PLATFORM: ${{ matrix.os }} - EXTRA_BUILD_ARG: 14.0-1 + EXTRA_BUILD_ARG: 15.1-1 steps: - uses: actions/checkout@v1 From 336eaaf04effe2ed5ce76347fb7a79aa4d834771 Mon Sep 17 00:00:00 2001 From: Bogdan Marian Date: Fri, 2 Dec 2022 18:00:47 +0200 Subject: [PATCH 2/9] Remove unnecessary Docker image build argument --- .github/workflows/publishDockerImages.yml | 1 - build.sh | 1 - postgresql/Dockerfile.windows | 5 ++--- postgresql/README.md | 10 ++++------ 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/publishDockerImages.yml b/.github/workflows/publishDockerImages.yml index b2747bc..f917e35 100644 --- a/.github/workflows/publishDockerImages.yml +++ b/.github/workflows/publishDockerImages.yml @@ -24,7 +24,6 @@ jobs: env: CI_PLATFORM: ${{ matrix.os }} - EXTRA_BUILD_ARG: 15.1-1 steps: - uses: actions/checkout@v1 diff --git a/build.sh b/build.sh index e0effa5..13b37c1 100644 --- a/build.sh +++ b/build.sh @@ -28,7 +28,6 @@ cd ./postgresql docker image build \ --build-arg POSTGRESQL_VERSION=$POSTGRESQL_VERSION \ - --build-arg EXTRA_BUILD_ARG=$EXTRA_BUILD_ARG \ --file $DOCKERFILE \ --tag $DOCKER_IMAGE:$VERSION_TAG \ . diff --git a/postgresql/Dockerfile.windows b/postgresql/Dockerfile.windows index 217ea36..3393fea 100644 --- a/postgresql/Dockerfile.windows +++ b/postgresql/Dockerfile.windows @@ -3,9 +3,8 @@ FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS download SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -ARG EXTRA_BUILD_ARG - -RUN Invoke-WebRequest $('https://get.enterprisedb.com/postgresql/postgresql-{0}-windows-x64-binaries.zip' -f $env:EXTRA_BUILD_ARG) -OutFile 'postgres.zip' -UseBasicParsing ; \ +# PostgreSQL binaries provided by EDB can be found here: https://www.enterprisedb.com/download-postgresql-binaries. +RUN Invoke-WebRequest $('https://sbp.enterprisedb.com/getfile.jsp?fileid=1258228') -OutFile 'postgres.zip' -UseBasicParsing ; \ Expand-Archive postgres.zip -DestinationPath C:\ ; \ Remove-Item postgres.zip diff --git a/postgresql/README.md b/postgresql/README.md index cc460d6..746b427 100644 --- a/postgresql/README.md +++ b/postgresql/README.md @@ -15,7 +15,7 @@ docker container run \ --detach \ -p 5432:5432 \ -v postgresql_linux_data:/var/lib/postgresql/data \ - satrapu/postgresql:14.0-linux + satrapu/postgresql:15.1-linux ``` ### On Windows with PowerShell @@ -29,7 +29,7 @@ docker container run ` --detach ` -p 5432:5432 ` -v postgresql_windows_data:C:/pgsql/data ` - satrapu/postgresql:14.0-windows + satrapu/postgresql:15.1-windows ``` **IMPORTANT** A user `postgres` with default password `postgres` has been added to the container. @@ -39,7 +39,7 @@ docker container run ` ### On Linux with Bash ```shell -export VERSION=14.0 +export VERSION=15.1 docker image build \ --build-arg VERSION=$POSTGRESQL_VERSION \ @@ -54,12 +54,10 @@ docker image push satrapu/postgresql:$POSTGRESQL_VERSION-linux ### On Windows with PowerShell ```powershell -export POSTGRESQL_VERSION=14.0 -export EXTRA_BUILD_ARG=14.0-1 +export POSTGRESQL_VERSION=15.1 docker image build ` --build-arg POSTGRESQL_VERSION=$POSTGRESQL_VERSION ` - --build-arg EXTRA_BUILD_ARG=$EXTRA_BUILD_ARG ` --file Dockerfile.windows ` --tag satrapu/postgresql:latest-windows satrapu/postgresql:$POSTGRESQL_VERSION-windows ` . From bf40d88cc42ecb1f6a5a5f5e86efa1313582c837 Mon Sep 17 00:00:00 2001 From: Bogdan Marian Date: Fri, 2 Dec 2022 20:54:10 +0200 Subject: [PATCH 3/9] Remove unnecessary lines --- postgresql/Dockerfile.windows | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/postgresql/Dockerfile.windows b/postgresql/Dockerfile.windows index 3393fea..b633a02 100644 --- a/postgresql/Dockerfile.windows +++ b/postgresql/Dockerfile.windows @@ -1,16 +1,13 @@ - FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS download SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] # PostgreSQL binaries provided by EDB can be found here: https://www.enterprisedb.com/download-postgresql-binaries. RUN Invoke-WebRequest $('https://sbp.enterprisedb.com/getfile.jsp?fileid=1258228') -OutFile 'postgres.zip' -UseBasicParsing ; \ - Expand-Archive postgres.zip -DestinationPath C:\ ; \ - Remove-Item postgres.zip + Expand-Archive postgres.zip -DestinationPath C:\ RUN Invoke-WebRequest 'http://download.microsoft.com/download/0/6/4/064F84EA-D1DB-4EAA-9A5C-CC2F0FF6A638/vc_redist.x64.exe' -OutFile vcredist_x64.exe ; \ - Start-Process vcredist_x64.exe -ArgumentList '/install', '/passive', '/norestart' -NoNewWindow -Wait ; \ - Remove-Item vcredist_x64.exe + Start-Process vcredist_x64.exe -ArgumentList '/install', '/passive', '/norestart' -NoNewWindow -Wait FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 @@ -42,4 +39,4 @@ RUN pg_ctl -D "C:/pgsql/data" start && \ dropdb ContainerUser && \ pg_ctl -D "C:/pgsql/data" stop -CMD ["C:/pgsql/bin/postgres.exe", "-D", "C:/pgsql/data"] +CMD ["C:/pgsql/bin/postgres.exe", "-D", "C:/pgsql/data"] \ No newline at end of file From 9b4210f6b95405c3750c1019e1f96f42895817a9 Mon Sep 17 00:00:00 2001 From: Bogdan Marian Date: Fri, 2 Dec 2022 21:00:15 +0200 Subject: [PATCH 4/9] Fix error: 'Empty continuation line' --- postgresql/Dockerfile.windows | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/postgresql/Dockerfile.windows b/postgresql/Dockerfile.windows index b633a02..f4024a5 100644 --- a/postgresql/Dockerfile.windows +++ b/postgresql/Dockerfile.windows @@ -4,10 +4,10 @@ SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPref # PostgreSQL binaries provided by EDB can be found here: https://www.enterprisedb.com/download-postgresql-binaries. RUN Invoke-WebRequest $('https://sbp.enterprisedb.com/getfile.jsp?fileid=1258228') -OutFile 'postgres.zip' -UseBasicParsing ; \ - Expand-Archive postgres.zip -DestinationPath C:\ + Expand-Archive 'postgres.zip' -DestinationPath C:\ ; -RUN Invoke-WebRequest 'http://download.microsoft.com/download/0/6/4/064F84EA-D1DB-4EAA-9A5C-CC2F0FF6A638/vc_redist.x64.exe' -OutFile vcredist_x64.exe ; \ - Start-Process vcredist_x64.exe -ArgumentList '/install', '/passive', '/norestart' -NoNewWindow -Wait +RUN Invoke-WebRequest 'http://download.microsoft.com/download/0/6/4/064F84EA-D1DB-4EAA-9A5C-CC2F0FF6A638/vc_redist.x64.exe' -OutFile 'vcredist_x64.exe' ; \ + Start-Process 'vcredist_x64.exe' -ArgumentList '/install', '/passive', '/norestart' -NoNewWindow -Wait ; FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 From 9cba6946b436f0163abe0e0bd6b844aca205f31d Mon Sep 17 00:00:00 2001 From: Bogdan Marian Date: Fri, 2 Dec 2022 21:56:52 +0200 Subject: [PATCH 5/9] Use 7-Zip to bypass long path related issue --- postgresql/Dockerfile.windows | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/postgresql/Dockerfile.windows b/postgresql/Dockerfile.windows index f4024a5..ea3fcac 100644 --- a/postgresql/Dockerfile.windows +++ b/postgresql/Dockerfile.windows @@ -2,7 +2,13 @@ FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS download SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -# PostgreSQL binaries provided by EDB can be found here: https://www.enterprisedb.com/download-postgresql-binaries. +# Install 7zip module since the "Expand-Archive" PowerShell command might fail in case of long paths. +RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; \ + Install-PackageProvider -Name NuGet -Force ; \ + Set-PSRepository -Name 'PSGallery' -SourceLocation "https://www.powershellgallery.com/api/v2" -InstallationPolicy Trusted ; \ + Install-Module -Name 7Zip4PowerShell -Force ; + +# Install PostgreSQL using the binaries provided by EDB, which are found here: https://www.enterprisedb.com/download-postgresql-binaries. RUN Invoke-WebRequest $('https://sbp.enterprisedb.com/getfile.jsp?fileid=1258228') -OutFile 'postgres.zip' -UseBasicParsing ; \ Expand-Archive 'postgres.zip' -DestinationPath C:\ ; From 3f322c6db208172639a9b907e2061456d4a64585 Mon Sep 17 00:00:00 2001 From: Bogdan Marian Date: Fri, 2 Dec 2022 22:06:10 +0200 Subject: [PATCH 6/9] Use 7-Zip to unzip PostgreSQL archive --- postgresql/Dockerfile.windows | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgresql/Dockerfile.windows b/postgresql/Dockerfile.windows index ea3fcac..269e896 100644 --- a/postgresql/Dockerfile.windows +++ b/postgresql/Dockerfile.windows @@ -10,7 +10,7 @@ RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tl # Install PostgreSQL using the binaries provided by EDB, which are found here: https://www.enterprisedb.com/download-postgresql-binaries. RUN Invoke-WebRequest $('https://sbp.enterprisedb.com/getfile.jsp?fileid=1258228') -OutFile 'postgres.zip' -UseBasicParsing ; \ - Expand-Archive 'postgres.zip' -DestinationPath C:\ ; + Expand-7Zip -ArchiveFileName 'postgres.zip' -TargetPath C:\ ; RUN Invoke-WebRequest 'http://download.microsoft.com/download/0/6/4/064F84EA-D1DB-4EAA-9A5C-CC2F0FF6A638/vc_redist.x64.exe' -OutFile 'vcredist_x64.exe' ; \ Start-Process 'vcredist_x64.exe' -ArgumentList '/install', '/passive', '/norestart' -NoNewWindow -Wait ; From fcc33ad09ab2b21d48a0952977695f5fd7d08863 Mon Sep 17 00:00:00 2001 From: Bogdan Marian Date: Fri, 2 Dec 2022 22:16:02 +0200 Subject: [PATCH 7/9] Use the same types of quotes and path separator --- postgresql/Dockerfile.windows | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/postgresql/Dockerfile.windows b/postgresql/Dockerfile.windows index 269e896..b3900a8 100644 --- a/postgresql/Dockerfile.windows +++ b/postgresql/Dockerfile.windows @@ -5,15 +5,15 @@ SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPref # Install 7zip module since the "Expand-Archive" PowerShell command might fail in case of long paths. RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; \ Install-PackageProvider -Name NuGet -Force ; \ - Set-PSRepository -Name 'PSGallery' -SourceLocation "https://www.powershellgallery.com/api/v2" -InstallationPolicy Trusted ; \ + Set-PSRepository -Name "PSGallery" -SourceLocation "https://www.powershellgallery.com/api/v2" -InstallationPolicy Trusted ; \ Install-Module -Name 7Zip4PowerShell -Force ; # Install PostgreSQL using the binaries provided by EDB, which are found here: https://www.enterprisedb.com/download-postgresql-binaries. -RUN Invoke-WebRequest $('https://sbp.enterprisedb.com/getfile.jsp?fileid=1258228') -OutFile 'postgres.zip' -UseBasicParsing ; \ - Expand-7Zip -ArchiveFileName 'postgres.zip' -TargetPath C:\ ; +RUN Invoke-WebRequest $("https://sbp.enterprisedb.com/getfile.jsp?fileid=1258228") -OutFile "postgres.zip" -UseBasicParsing ; \ + Expand-7Zip -ArchiveFileName "postgres.zip" -TargetPath "C:/" ; -RUN Invoke-WebRequest 'http://download.microsoft.com/download/0/6/4/064F84EA-D1DB-4EAA-9A5C-CC2F0FF6A638/vc_redist.x64.exe' -OutFile 'vcredist_x64.exe' ; \ - Start-Process 'vcredist_x64.exe' -ArgumentList '/install', '/passive', '/norestart' -NoNewWindow -Wait ; +RUN Invoke-WebRequest "http://download.microsoft.com/download/0/6/4/064F84EA-D1DB-4EAA-9A5C-CC2F0FF6A638/vc_redist.x64.exe" -OutFile "vcredist_x64.exe" ; \ + Start-Process "vcredist_x64.exe" -ArgumentList "/install", "/passive", "/norestart" -NoNewWindow -Wait ; FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 @@ -23,7 +23,7 @@ COPY --from=download /pgsql /pgsql COPY --from=download /windows/system32/VCRUNTIME140.dll /pgsql/bin/VCRUNTIME140.dll COPY --from=download /windows/system32/msvcp140.dll /pgsql/bin/msvcp140.dll -RUN setx /M PATH "C:\pgsql\bin;%PATH%" +RUN setx /M PATH "C:/pgsql/bin;%PATH%" EXPOSE 5432 From 36f7275ef76ac7550a6cd1d08cdfa052254620c8 Mon Sep 17 00:00:00 2001 From: Bogdan Marian Date: Fri, 2 Dec 2022 22:21:17 +0200 Subject: [PATCH 8/9] Fix command used for downloading archive --- postgresql/Dockerfile.windows | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgresql/Dockerfile.windows b/postgresql/Dockerfile.windows index b3900a8..8e1d0b0 100644 --- a/postgresql/Dockerfile.windows +++ b/postgresql/Dockerfile.windows @@ -9,7 +9,7 @@ RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tl Install-Module -Name 7Zip4PowerShell -Force ; # Install PostgreSQL using the binaries provided by EDB, which are found here: https://www.enterprisedb.com/download-postgresql-binaries. -RUN Invoke-WebRequest $("https://sbp.enterprisedb.com/getfile.jsp?fileid=1258228") -OutFile "postgres.zip" -UseBasicParsing ; \ +RUN Invoke-WebRequest "https://sbp.enterprisedb.com/getfile.jsp?fileid=1258228" -OutFile "postgres.zip" -UseBasicParsing ; \ Expand-7Zip -ArchiveFileName "postgres.zip" -TargetPath "C:/" ; RUN Invoke-WebRequest "http://download.microsoft.com/download/0/6/4/064F84EA-D1DB-4EAA-9A5C-CC2F0FF6A638/vc_redist.x64.exe" -OutFile "vcredist_x64.exe" ; \ From 2cec6e1e537dc048c4bf31273c1ee34414e2c595 Mon Sep 17 00:00:00 2001 From: Bogdan Marian Date: Fri, 2 Dec 2022 22:41:19 +0200 Subject: [PATCH 9/9] Enable long paths support --- postgresql/Dockerfile.windows | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/postgresql/Dockerfile.windows b/postgresql/Dockerfile.windows index 8e1d0b0..0b992ea 100644 --- a/postgresql/Dockerfile.windows +++ b/postgresql/Dockerfile.windows @@ -2,15 +2,13 @@ FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS download SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -# Install 7zip module since the "Expand-Archive" PowerShell command might fail in case of long paths. -RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; \ - Install-PackageProvider -Name NuGet -Force ; \ - Set-PSRepository -Name "PSGallery" -SourceLocation "https://www.powershellgallery.com/api/v2" -InstallationPolicy Trusted ; \ - Install-Module -Name 7Zip4PowerShell -Force ; - +# Enable long paths. +# See more here: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=powershell#enable-long-paths-in-windows-10-version-1607-and-later. +RUN New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force ; + # Install PostgreSQL using the binaries provided by EDB, which are found here: https://www.enterprisedb.com/download-postgresql-binaries. RUN Invoke-WebRequest "https://sbp.enterprisedb.com/getfile.jsp?fileid=1258228" -OutFile "postgres.zip" -UseBasicParsing ; \ - Expand-7Zip -ArchiveFileName "postgres.zip" -TargetPath "C:/" ; + Expand-Archive "postgres.zip" -DestinationPath "C:/" ; RUN Invoke-WebRequest "http://download.microsoft.com/download/0/6/4/064F84EA-D1DB-4EAA-9A5C-CC2F0FF6A638/vc_redist.x64.exe" -OutFile "vcredist_x64.exe" ; \ Start-Process "vcredist_x64.exe" -ArgumentList "/install", "/passive", "/norestart" -NoNewWindow -Wait ;