Building for Windows

The Windows images for OpenResty use a multi-stage Docker build to create a minimal final image.

Build Process

  1. Stage 1 (Downloader): A larger Windows Server Core image with PowerShell and Chocolatey (mcr.microsoft.com/dotnet/framework/runtime) is used to download the OpenResty Windows .zip package and Strawberry Perl.
  2. Stage 2 (Final Image): A minimal nanoserver image is used as the base. The downloaded OpenResty and Perl binaries from the first stage are copied into this image.

This process results in a much smaller final image than if the build tools were included.

How to Build

Clone the repository and run the docker build command targeting the windows/Dockerfile:

git clone https://github.com/openresty/docker-openresty.git
cd docker-openresty
docker build -t my-windows-openresty -f windows/Dockerfile .

Windows Container Version Compatibility

It is crucial that the version of the Windows container image matches the version of the Windows host it runs on. The Dockerfiles are configured for specific Windows Server versions. You may need to adjust the RESTY_IMAGE_TAG and RESTY_INSTALL_TAG arguments to match your host environment.

See the official Microsoft documentation on Windows container version compatibility for more details.

Build Arguments

Key Default Description
RESTY_INSTALL_BASE "mcr.microsoft.com/dotnet/framework/runtime" The Windows image used for the downloader stage.
RESTY_INSTALL_TAG "4.8-windowsservercore-ltsc2019" The tag for the downloader stage image.
RESTY_IMAGE_BASE "mcr.microsoft.com/windows/nanoserver" The base Windows image for the final runtime image.
RESTY_IMAGE_TAG "1809" The tag for the final runtime image.
RESTY_VERSION 1.27.1.2 The version of OpenResty to download.