Linux Build Details

Perfect Assistant relies on Docker to perform Linux builds which can be used to deploy to a variety of services. This section describes the intricacies of this build process to help better understand the abilities and limitations of Perfect Assistant.

Docker Usage

Without Docker support, Perfect Assistant (subsequently referred to as "PA") can only help facilitate local macOS builds and dependency management through Swift Package Manager. After Docker is properly installed PA can resolve and automatically manage required Apt dependencies and build binaries which are ready to be deployed to a variety of services.

As part of completing the Docker installation through PA, one or more publicly available base Docker images are pulled from Docker Hub to your local machine. These images are crafted to be as simple as possible and include only a core Ubuntu 16.04 OS and the Swift toolchain version which you select for your project.

The base images are pulled from the repository located at PA Images Tagged. The exact version used for builds depends on the toolchain version selected in your project editor, although all current versions are fixated on Ubuntu 16.04 which is the most recent "Long Term Support" version of Ubuntu as of this writing.

Docker Builds

When PA performs an individual release or debug Linux build it will first create a temporary Docker container using one of these Swift toolchain base images. This container is created with local macOS mounts for its ".build" directory. Locally, this directory is called ".build_lin". Into this all related Linux build artifacts and products will be placed.

Linux Apt Dependencies

PA will then perform an initial "swift package fetch" operation using this container. This will pull down all required dependencies. After this has succeeded PA will then scan these downloaded packages and suss out all required Apt dependencies and actions which would be required for the project to run on the target Ubuntu OS. It does this via one of two mechanisms:

  • Package.swift "providers" keys.
    • These standard Package.swift elements indicate the Apt (or Homebrew) dependencies required by individual lower level packages.
  • PADockerfile
    • These non-standard but convention based files can be included in a Git repository to indicate actions which should be included in Dockerfiles. These can include simple Apt install directives or can indicate further commands which should be executed to support the dependency. For example, a MySQL client pc file might require editing in order to operate cleanly with SPM.
PA will first check if a dependant repository contains a PADockerfile and use that. If it does not then PA will honour the "providers" specification in the dependency's Package file.

Together, these dependency actions are conglomerated into a single list of actions which is either used directly when producing a deployment Docker image or further processed into a shell script which can be used to fully configure a stand-alone machine instance such as for EC2.

Project PADockerfile

If a project directly contains a top level PADockerfile (which is rare) then this file will be used as a base to produce both a PADockerfile_build and a PADockerfile_deploy file. Without this file, PA will generate a temporary and non-concrete PADockerfile for the project. At its most primitive this generated file will indicate only the base image upon which the resulting Docker image will be built. All determined dependency actions will be appended to this file and the result will be used for performing all further debug, release, and deployment builds.

The PADockerfile_deploy and PADockerfile_build files will reside in the project's directory and can be used as a reference indicating the exact dependencies required to run and deploy the project. If these files are deleted they will be automatically recreated by PA as needed.

Final

The initial dependency fetch will be performed on the base Swift toolchain enabled image. This image may be labeled such as "perfectlysoft/perfectassistant:3.1" (the exact tag will vary depending on the selected Swift toolchain). All project builds will be performed on a custom image created for the project. This image will include into its build the project's determined dependency actions and will be tagged according to the project's normalized name. For example a project named "PerfectTemplate" would build against an image named "perfectassistant/perfecttemplate". When choosing to build a deployment image, all release build produced binaries will be copied into the resulting deployment image and the image will be tagged such as "perfectassistant/perfecttemplate:deploy".

The source and destination images will remain tagged within your local Docker system and can be used however you wish. PA will use the final deployment image directly if the project is being deployed to a container based system such as App Engine. When deploying to a virtual machine based system, PA will produce the deployment container but will copy the produced binaries to the host. PA will use the previously determined dependency actions and execute them on the Linux host in order to ensure that all the project's required Apt dependencies are in place.

Next: Managing Deployments