This API provides the ability to build a Windows executable installer.
Typically, this is accomplished using Wine and InnoSetup on the same server. However, maintaining this setup has become increasingly difficult due to compatibility issues with newer 64-bit distributions.
We created a thin flask application that serves as the wrapper for a Docker-based solution, and acts as a builder for .exe installers.
This guide explains how to create a Windows executable using Inno Setup and Wine, utilizing a temporary Docker container as the builder. This functionality is utilized by our Flask application to generate the Windows executable installer at the request of the client application.
This api exposes a /compile
route, which takes 2 parameters:
path
: the absolute path of the directory that Innosetup config file residesfile_name
(OPTIONAL): the file name of the Innosetup config file (.iss file)
To run this app we will use gunicorn.
To set up the environment and run the application, follow these steps:
- Install
virtualenv
by visiting the official installation guide. - Create a new environment by running
virtualenv env_name
. Refer to the user guide for more details. - Activate the environment by running
source /path/to/newly/created/env/bin/activate
. - Install the required dependencies by running
pip install -r requirements.txt
. - Navigate to the
project_root/src
directory. - Run the application using the following command:
gunicorn --conf gunicorn_conf.py --bind 0.0.0.0:<local-port> main:app
- Test a
POST
request to http://0.0.0.0:/compile
To create the installers for the required client application, we will utilize a Docker container.
This approach allows us to run commands within the container and generate the installer in the mounted directory.
-
Install Docker by following the instructions provided in the official Docker documentation.
-
Add your user to the Docker group to ensure proper permissions.
-
Pull the required Docker image by executing the following command:
docker pull amake/innosetup:innosetup6
-
Test that the Docker image is working correctly by running the following commands:
su - server_user cd /path/to/dir/with/iss-file docker run --rm -i -v $PWD:/work amake/innosetup:innosetup6 <iss-file-name>
Note: Make sure to include the Docker image tag to avoid inconsistent results.
#!/usr/bin/env bash
exec docker run --rm -i -v $PWD:/work amake/innosetup:innosetup6 "$@"
Depending on configured permissions on current directory, the container may not have write access to the mounted folder. This means, that will not be able to create the "Output" folder, and would not be able to create files inside.
To mitigate that we could expand our script to:
- create a folder "Output"
- Add write permission to any 777
- Create executable
- Change back the permissions
#!/usr/bin/env bash
# Create the Output directory if it doesn't exist
if [ ! -d "Output" ]; then
mkdir Output
chmod 777 Output
fi
exec docker run --rm -i -v $PWD:/work amake/innosetup:innosetup6 "$@"
chmod 775 Output
The Apache Licence. Please see the Licence File for more information.