Docker
recently updated their Windows client to natively use Windows Subsystem for Linux
as its backend. For smaller projects, I use Docker
as an easy way to cross-compile without the need to bog down my personal system, keep clients projects isolated from one another, and lots of automated ad hoc testing.
The software we’re compiling is Input-Leap
, I’ve used it years on many systems at home. Input-Leap is software that mimics the functionality of a KVM switch over TCP/IP, allowing you to use a single keyboard and mouse to control many seperate computers.
First, compiling for Linux natively, and after how to compile using Docker on Windows.
Compiling on Linux / WSL natively ๐
If you’re using Windows, start by installing Windows Subsystem for Linux
, then Ubuntu
.
Open up a terminal and let’s begin the build process.
|
|
Compiling on Linux / WSL natively using Docker ๐
If you’re using Windows, start by installing Windows Subsystem for Linux
, then Ubuntu
, followed by Docker
.
What is Docker? ๐
Docker lets you seperate applications from the underlying instructure. In this example, I’m pulling (downloading) a ubuntu image which contains the base operating system we’re going to build on top of.
We’re going to write a Dockerfile. A Dockerfile is essentially a script that allows you to define which base image you’re going to use as an operating system, and which commands you’d like to run afterwards, building a new image that is a filesystem layer of filesystem changes that sits on top of our base image.
Benefits of using Docker ๐
Docker lets you quarantine the package bloat of compilation to Docker images, which you can easily remove to save space. The way Docker builds images in read-only layers allows you to use a single, always clean base image for multiple projects while maintaining isolation between them. Changes you make are contained in layers built on top of these base images. Using a Dockerfile also allows you to transparently document all the dependancies and steps needed.
Docker allows a modular approach to development that can help with security and scalability.
1. Create Directory Structure ๐
Let’s create the directories that we want to contain our installation files.
|
|
2. Writing our Dockerfile ๐
The commands that we’re adding to our Dockerfile are very similar to the ones we would run when compiling this in a native Linux environment, with a few additions. We’ll go over the differences as well as the reasons for them.
Open up your primary file editor, point it at the new Dockerfile (by default, they’re just named “Dockerfile”)
|
|
Write the following:
|
|
3. Building a new image using our Dockerfile ๐
Next, we tell Docker to build our new image using the Dockerfile we have created. Note that in this example, the resulting Docker image will be name “input-leap:build”, but you can change this tag to anything you choose.
|
|
3. Installation of Input Leap ๐
We now have a Docker image that contains the compiled binaries we need for installation of input-leap. We’re going to create a local directory, link it to the Docker images internal filesystem, and tell the installation to install it there.
|
|
When running the Docker image for installation, use the “volume” argument to bind our local faux install directory, to the installation directory created in our docker image.
|
|
With any luck, you should see a similar output.
--tty input-leap:build
[ 1%] Built target gmock
[ 2%] Built target gtest
[ 10%] Built target arch
[ 11%] Built target common
[ 17%] Built target base
[ 18%] Built target mt
[ 20%] Built target io
[ 26%] Built target net
[ 41%] Built target synlib
[ 49%] Built target server
[ 55%] Built target platform
[ 59%] Built target ipc
[ 61%] Built target client
[ 62%] Built target barrierc
[ 63%] Built target barriers
[ 68%] Built target integtests
[ 76%] Built target unittests
[ 76%] Automatic MOC and UIC for target guiunittests
[ 76%] Built target guiunittests_autogen
[ 80%] Built target guiunittests
[ 81%] Automatic MOC and UIC for target barrier
[ 81%] Built target barrier_autogen
[100%] Built target barrier
Install the project...
-- Install configuration: "Release"
-- Installing: /tmp/install/usr/local/share/icons/hicolor/scalable/apps/barrier.svg
-- Installing: /tmp/install/usr/local/share/applications/barrier.desktop
-- Installing: /tmp/install/usr/local/bin/barrierc
-- Installing: /tmp/install/usr/local/bin/barriers
-- Installing: /tmp/install/usr/local/bin/barrier
Job complete. You can now go to your faux installation directory, and find input-leap. You can use it in the existing directory, or copy it to your local /usr directory for integration.
ed@ubuntu:~/src/install$ tree .
.
โโโ usr
โโโ local
โโโ bin
โย ย โโโ barrier
โย ย โโโ barrierc
โย ย โโโ barriers
โโโ share
โโโ applications
โย ย โโโ barrier.desktop
โโโ icons
โโโ hicolor
โโโ scalable
โโโ apps
โโโ barrier.svg
Changelog ๐
Date | Description |
---|---|
03/24/2022 | Updated installation instructions to reflect updated fork |
10/20/2021 | Initial blog added. |