Skip to content

Commit

Permalink
Allow the users to run earthly without docker
Browse files Browse the repository at this point in the history
Running earthly inside docker adds a layer of complexity to the system,
which is bound to bring bugs with it.
I ran into a few issue running earthly inside docker, e.g.

earthly/earthly#2838

and

earthly/earthly#3167.

Hence, I added the environment variable EARTHLY_BIN and documented it.
  • Loading branch information
oz123 committed Sep 26, 2023
1 parent 82ec3f5 commit fcf12e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Skip this step if your base image is ubuntu or opensuse-leap. If you are buildin
| Parameter | Description | Type | Default Value |
|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|-------------------------|
| CUSTOM_TAG | Environment name for provider image tagging. The default value is `demo`. | String | `demo` |
| EARTHLY_BIN | Path to earthly binary on the host system (e.g. /usr/local/bin/earthly). If empty the docker image of earthly is used. | String | |
| IMAGE_REGISTRY | Image registry name that will store the image artifacts. The default value points to the *ttl.sh* image registry, an anonymous and ephemeral Docker image registry where images live for a maximum of 24 hours by default. If you wish to make the images exist longer than 24 hours, you can use any other image registry to suit your needs. | String | `ttl.sh` |
| OS_DISTRIBUTION | OS distribution of your choice. For example, it can be `ubuntu` or `opensuse-leap`. | String | `ubuntu` |
| IMAGE_REPO | Image repository name in your chosen registry. | String | `$OS_DISTRIBUTION` |
Expand Down
7 changes: 6 additions & 1 deletion earthly.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/bash

set -e

function build_with_proxy() {
export HTTP_PROXY=$HTTP_PROXY
export HTTPS_PROXY=$HTTPS_PROXY
Expand Down Expand Up @@ -37,7 +40,9 @@ if ! docker run --rm --privileged alpine sh -c 'echo "Privileged container test"
echo "Privileged containers are not allowed for the current user."
exit 1
fi
if [ -z "$HTTP_PROXY" ] && [ -z "$HTTPS_PROXY"]; then
if [ ! -z "${EARTHLY_BIN}" ]; then
"${EARTHLY_BIN}" --allow-privileged "$@"
elif [ -z "$HTTP_PROXY" ] && [ -z "$HTTPS_PROXY"]; then
build_without_proxy "$@"
else
build_with_proxy "$@"
Expand Down

0 comments on commit fcf12e5

Please sign in to comment.