A simple executor that allows you to run Dockerfile
/Containerfile
commands directly on the host system without using Docker, Podman or any other container engine. It's useful for executing build commands in a predictable environment or setting up development tools. The Machinefile executor tool parses the Dockerfile and executes the commands on the local or remote host system.
The executor supports the followuing Dockerfile
commands:
RUN
: Execute commandsCOPY
: Copy files from context to a specific locationADD
: Similar to COPY, but with additional featuresUSER
: Switch to different userENV
: Set environment variablesARG
: Define build-time variables
Note
This should ideally be run as root
.
$ ./machinefile test/Machinefile [context]
To target a remote machine, you have to set up remote keys:
$ ./machinefile -host dotfedora -user root test/Machinefile [context]
or
$ ./machinefile root@dotfedora test/Machinefile
# Single ARG
./machinefile --arg=USER="runner" test/Machinefile [context]
# Multiple ARGs
./machinefile --arg=USER="runner" --arg=VERSION="1.0" test/Machinefile [context]
# ARGs without quotes (if value doesn't contain spaces)
./machinefile --arg=USER=runner test/Machinefile [context]
If a Containerfile uses the following shebang option:
Machinefile
#!/bin/env -S machinefile --stdin
FROM ...
RUN ...
it is possible to execute the file directly
$ ./Machinefile root@dotfedora --arg USER=gbraad [context]
To incorporate this in your build process, you can use the Machinfile executor GitHub Action.
- name: Run Dockerfile commands
uses: gbraad-actions/machinefile-executor-action@v1
with:
containerfile: 'containers/Containerfile-devtools'
context: '.'
arguments: --arg=USER=gbraad
@gbraad |