-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new UDC to perform an optimized git deep clone #22
Merged
+194
−75
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3e1754d
Add new ud to perform an op[timized deep clone
idodod fdb496d
change comment; add new lines
idodod 435e52b
use full semantic version for known hosts copy
idodod 3a356b1
update test
idodod 90e11fd
configure ssh before running earthly
idodod ff3c571
remove debug messages
idodod dbaae92
Merge branch 'main' into ido-add-git-deep-clone-udc
idodod da1a867
use hello-world repo instead for tests
idodod 2e384b4
Merge branch 'ido-add-git-deep-clone-udc' of github.com:earthly/lib i…
idodod b86ff15
move git, ssh, dind under utils
idodod 9a7ebb1
rename test
idodod df7781d
Merge branch 'main' into ido-add-git-deep-clone-udc
idodod 8546d9e
add new line
idodod 68763ce
Merge branch 'main' into ido-add-git-deep-clone-udc
idodod File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
VERSION 0.7 | ||
|
||
test: | ||
BUILD ./dind+test | ||
BUILD ./git+test | ||
BUILD ./ssh+test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
VERSION 0.7 | ||
|
||
INSTALL: | ||
COMMAND | ||
COPY +install-dind-script/install-dind.sh /tmp/install-dind.sh | ||
RUN /tmp/install-dind.sh | ||
|
||
install-dind-script: | ||
FROM alpine:3.18.4 | ||
COPY ./install-dind.sh ./ | ||
SAVE ARTIFACT ./install-dind.sh | ||
|
||
test: | ||
BUILD ./tests+all |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
VERSION 0.7 | ||
|
||
all: | ||
BUILD +test-install-dind-for-image \ | ||
--base_image=docker:dind \ | ||
--base_image=alpine:latest \ | ||
--base_image=debian:stable \ | ||
--base_image=debian:stable-slim \ | ||
--base_image=debian:oldstable \ | ||
--base_image=ubuntu:latest \ | ||
--base_image=amazonlinux:1 \ | ||
--base_image=amazonlinux:2 \ | ||
--base_image=earthly/dind:alpine \ | ||
--base_image=earthly/dind:ubuntu | ||
|
||
test-install-dind-for-image: | ||
ARG --required base_image | ||
FROM alpine | ||
ARG TARGETPLATFORM | ||
IF [ "${base_image%:*}" = "amazonlinux" ] && [ "$TARGETPLATFORM" = "linux/arm64" ] # no amazonlinux:1 for arm64/UDC not supported atm for amazonlinux:2 on arm - skipping | ||
RUN echo skipping $base_image with platform $TARGETPLATFORM | ||
ELSE | ||
FROM "$base_image" | ||
# docker-compose will fail with: | ||
# Error response from daemon: Invalid container name (-hello-1), only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed | ||
# if docker-compose.yml is in the root directory, due to the --project flag defaulting to "". | ||
# This bug does not exist in the official earthly/dind:alpine image. | ||
WORKDIR /dind-test | ||
|
||
DO ..+INSTALL | ||
RUN echo " | ||
version: \"3\" | ||
services: | ||
hello: | ||
image: hello-world:latest | ||
" >./docker-compose.yml | ||
WITH DOCKER --compose docker-compose.yml | ||
RUN true | ||
END | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
VERSION --arg-scope-and-set 0.7 | ||
|
||
# DEEP_CLONE deep clones the provided git url | ||
DEEP_CLONE: | ||
COMMAND | ||
ARG USE_GIT_ENV="false" | ||
IF [ $USE_GIT_ENV = "true" ] | ||
FROM alpine/git:v2.40.1 | ||
END | ||
DO ../ssh+ADD_KNOWN_HOSTS | ||
ARG --required GIT_URL | ||
ARG DEST_DIR | ||
LET dest_dir=$DEST_DIR | ||
IF [ -z $dest_dir ] | ||
SET dest_dir=$(basename ${GIT_URL%.git}) | ||
END | ||
GIT CLONE $GIT_URL $dest_dir | ||
WORKDIR $dest_dir | ||
RUN git remote set-url origin $GIT_URL | ||
ARG git_hash=$(git rev-parse HEAD) | ||
ARG SECRET_PATH | ||
IF [ -z $SECRET_PATH ] | ||
RUN --ssh git fetch --unshallow | ||
ELSE | ||
RUN --mount=type=secret,id=$SECRET_PATH,mode=0400,target=/root/.ssh/id_rsa \ | ||
git fetch --unshallow | ||
END | ||
|
||
test: | ||
BUILD ./tests+all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
VERSION --arg-scope-and-set --pass-args 0.7 | ||
|
||
PROJECT earthly-technologies/core | ||
|
||
all: | ||
BUILD --platform=linux/amd64 --platform=linux/arm64 +test-deep-clone-image \ | ||
--base_image=alpine/git:latest \ | ||
--base_image=alpine:latest \ | ||
--base_image=debian:stable \ | ||
--base_image=debian:stable-slim \ | ||
--base_image=ubuntu:latest \ | ||
--base_image=amazonlinux:1 \ | ||
--base_image=amazonlinux:2 \ | ||
--GIT_URL=https://github.com/earthly/hello-world.git \ | ||
[email protected]:earthly/hello-world.git \ | ||
[email protected]:earthly/hello-world \ | ||
--SECRET_PATH="" \ | ||
--SECRET_PATH="littleredcorvette-id_rsa" \ | ||
--DEST_DIR="" \ | ||
--DEST_DIR="some-other-dir" | ||
|
||
test-deep-clone-image: | ||
ARG --required base_image | ||
ARG TARGETPLATFORM | ||
FROM alpine | ||
IF [ "$base_image" = "amazonlinux:1" ] && [ "$TARGETPLATFORM" = "linux/arm64" ] # no amazonlinux:1 for arm64, skipping | ||
RUN echo skipping $base_image with platform $TARGETPLATFORM | ||
ELSE | ||
FROM "$base_image" | ||
LET use_git_env="true" | ||
IF [ "${base_image%:*}" = "alpine/git" ] | ||
SET use_git_env="false" | ||
RUN apk add git | ||
ELSE IF [ "${base_image%:*}" = "alpine" ] | ||
RUN apk add git | ||
ELSE IF [ "${base_image%:*}" = "debian" ] | ||
RUN apt update && apt install -y git | ||
ELSE IF [ "${base_image%:*}" = "ubuntu" ] | ||
RUN apt-get update && apt-get -y install git | ||
ELSE IF [[ $base_image == amazonlinux* ]] | ||
RUN yum -y install git | ||
END | ||
DO --pass-args ..+DEEP_CLONE --USE_GIT_ENV=$use_git_env | ||
IF [ -n $DEST_DIR ] | ||
WORKDIR $DEST_DIR | ||
END | ||
RUN git checkout main | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
VERSION 0.7 | ||
|
||
# ADD_KNOWN_HOSTS appends some known public keys into the $target_file | ||
ADD_KNOWN_HOSTS: | ||
COMMAND | ||
ARG target_file=~/.ssh/known_hosts | ||
LET expanded_target_file="$(eval echo $target_file)" | ||
COPY +known-hosts/known_hosts /tmp/. | ||
RUN mkdir -p $(dirname $expanded_target_file) && cat /tmp/known_hosts >> $expanded_target_file | ||
RUN rm /tmp/known_hosts | ||
|
||
# known-hosts is used to copy the known_hosts file into the build context (internal use) | ||
known-hosts: | ||
FROM alpine:3.18.4 | ||
COPY known_hosts . | ||
SAVE ARTIFACT known_hosts | ||
|
||
test: | ||
BUILD ./tests+all |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vladaionescu
I'm not even sure we need to keep this for backwards compatibility since we're going to cut a new release/tag for
utils
and discontinue the global tag (which users can still use).Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep it, because we have many users of INSTALL_DIND who don't use a tag at all. (We should update our docs too to suggest using a tag)
I wonder if we should add a
RUN echo <some-warning-message>
when using the outter INSTALL_DIND, to invite the users to use the new version directly + a tag.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that'd a good idea