forked from earthly/earthly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-arg.earth
71 lines (59 loc) · 1.41 KB
/
build-arg.earth
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
FROM alpine:3.13
WORKDIR /test
ARG global1=abc
ARG global2=def
all:
BUILD +test1
BUILD +test2
BUILD +test3
BUILD +test4
BUILD +test5
BUILD +test-global1
BUILD +test-global2
BUILD +test-global3
file-exists:
ARG VAR1=nope.txt
ARG VAR2=dummy
RUN touch "$VAR2"
RUN touch "existing-file.txt"
RUN test -f "$VAR1"
test1:
BUILD --build-arg=VAR1=existing-file.txt +file-exists
BUILD --build-arg=VAR1=dummy +file-exists
BUILD --build-arg=VAR1=dummy2 --build-arg=VAR2=dummy2 +file-exists
RUN touch dummy
BUILD --build-arg=VAR1=$(ls) +file-exists
RUN rm dummy
RUN touch existing-file.txt
BUILD --build-arg=VAR1=$(ls) +file-exists
test2:
ARG ALPINE=3.11
FROM alpine:$ALPINE
RUN echo $ALPINE
RUN test "$ALPINE" == "3.11"
dummy:
FROM alpine:3.13
test3:
ARG VAR1="test"
FROM +dummy
RUN test "$VAR1" == "test"
test4:
RUN touch dummy
ARG VAR1=$(ls)
RUN touch should-not-be-seen
RUN test "$VAR1" == "dummy"
test5:
RUN printf '"text with quotes"' >./content
ARG VAR1=$(cat ./content)
RUN test "$VAR1" == '"text with quotes"'
test-global1:
RUN test "$global1" == "abc"
RUN test "$global2" == "def"
test-global2:
FROM alpine:latest
RUN test "$global1" == "abc"
RUN test "$global2" == "def"
test-global3:
FROM +dummy
RUN test "$global1" == "abc"
RUN test "$global2" == "def"