-
Notifications
You must be signed in to change notification settings - Fork 3
/
Earthfile
148 lines (128 loc) · 4.4 KB
/
Earthfile
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
VERSION 0.8
IMPORT --allow-privileged github.com/cardano-foundation/cf-gha-workflows/./earthfiles/functions:main AS functions
ARG --global DOCKER_IMAGES_TARGETS="ledger-sync aggregation streamer scheduler"
ARG --global DOCKER_IMAGE_PREFIX="cf-ledger-sync"
ARG --global DOCKER_IMAGES_EXTRA_TAGS=""
ARG --global DOCKER_REGISTRIES=""
ARG --global PUSH=false
ARG --global GRADLE_BUILD_ARGS="clean build -PskipSigning=true --stacktrace"
all:
WAIT
BUILD +gradle-build
END
LOCALLY
FOR image_target IN $DOCKER_IMAGES_TARGETS
BUILD +$image_target --PUSH=$PUSH
END
docker-publish:
BUILD +all --PUSH=$PUSH
TEMPLATED_DOCKERFILE_BUILD:
FUNCTION
ARG DOCKERFILE_TARGET
ARG DOCKER_IMAGE_NAME
FROM DOCKERFILE --build-arg GRADLE_BUILD_ARGS=${GRADLE_BUILD_ARGS} -f Dockerfile --target ${DOCKERFILE_TARGET} .
SAVE IMAGE ${DOCKER_IMAGE_NAME}:latest
gradle-build:
FROM DOCKERFILE \
--build-arg GRADLE_BUILD_ARGS="${GRADLE_BUILD_ARGS}" \
-f Dockerfile --target build .
ARG RELEASE_TAG=$(grep version gradle.properties | awk '{print $NF}')
LET APP_JAR_PATH=""
LET APP_JAR_NAME=""
RUN mkdir -p /release
FOR target IN $DOCKER_IMAGES_TARGETS
IF [ $target = "ledger-sync" ]
SET APP_JAR_PATH="/app/application/build/libs"
SET APP_JAR_NAME=${DOCKER_IMAGE_PREFIX}-${RELEASE_TAG}.jar
ELSE
SET APP_JAR_PATH="/app/${target}-app/build/libs"
SET APP_JAR_NAME=${DOCKER_IMAGE_PREFIX}-${target}-${RELEASE_TAG}.jar
END
RUN mv ${APP_JAR_PATH}/*jar /release/${APP_JAR_NAME}
RUN md5sum /release/${APP_JAR_NAME} > /release/${APP_JAR_NAME}.md5sum
END
SAVE ARTIFACT /release/* AS LOCAL release/
ledger-sync:
ARG EARTHLY_TARGET_NAME
WAIT
DO +TEMPLATED_DOCKERFILE_BUILD \
--DOCKERFILE_TARGET=${EARTHLY_TARGET_NAME} \
--DOCKER_IMAGE_NAME=${DOCKER_IMAGE_PREFIX}
END
DO functions+DOCKER_TAG_N_PUSH \
--PUSH=$PUSH \
--DOCKER_IMAGE_NAME=${DOCKER_IMAGE_PREFIX} \
--DOCKER_IMAGES_EXTRA_TAGS="${DOCKER_IMAGES_EXTRA_TAGS}"
aggregation:
ARG EARTHLY_TARGET_NAME
WAIT
DO +TEMPLATED_DOCKERFILE_BUILD \
--DOCKERFILE_TARGET=${EARTHLY_TARGET_NAME} \
--DOCKER_IMAGE_NAME=${DOCKER_IMAGE_PREFIX}-${EARTHLY_TARGET_NAME}
END
DO functions+DOCKER_TAG_N_PUSH \
--PUSH=$PUSH \
--DOCKER_IMAGE_NAME=${DOCKER_IMAGE_PREFIX}-${EARTHLY_TARGET_NAME} \
--DOCKER_IMAGES_EXTRA_TAGS="${DOCKER_IMAGES_EXTRA_TAGS}"
streamer:
ARG EARTHLY_TARGET_NAME
WAIT
DO +TEMPLATED_DOCKERFILE_BUILD \
--DOCKERFILE_TARGET=${EARTHLY_TARGET_NAME} \
--DOCKER_IMAGE_NAME=${DOCKER_IMAGE_PREFIX}-${EARTHLY_TARGET_NAME}
END
DO functions+DOCKER_TAG_N_PUSH \
--PUSH=$PUSH \
--DOCKER_IMAGE_NAME=${DOCKER_IMAGE_PREFIX}-${EARTHLY_TARGET_NAME} \
--DOCKER_IMAGES_EXTRA_TAGS="${DOCKER_IMAGES_EXTRA_TAGS}"
scheduler:
ARG EARTHLY_TARGET_NAME
WAIT
DO +TEMPLATED_DOCKERFILE_BUILD \
--DOCKERFILE_TARGET=${EARTHLY_TARGET_NAME} \
--DOCKER_IMAGE_NAME=${DOCKER_IMAGE_PREFIX}-${EARTHLY_TARGET_NAME}
END
DO functions+DOCKER_TAG_N_PUSH \
--PUSH=$PUSH \
--DOCKER_IMAGE_NAME=${DOCKER_IMAGE_PREFIX}-${EARTHLY_TARGET_NAME} \
--DOCKER_IMAGES_EXTRA_TAGS="${DOCKER_IMAGES_EXTRA_TAGS}"
docker-compose-up:
LOCALLY
WAIT
BUILD +all
END
ARG network=preprod
ARG background
IF [ "${background}" = "true" ]
ENV DOCKER_COMPOSE_UP_ARGS="-d"
END
IF [ "${network}" = "preview" ]
ARG CARDANO_NODE_HOST=preview-node.world.dev.cardano.org
ARG CARDANO_NODE_PORT=3001
ARG CARDANO_PROTOCOL_MAGIC=2
ELSE IF [ "${network}" = "preprod" ]
ARG CARDANO_NODE_HOST=preprod-node.world.dev.cardano.org
ARG CARDANO_NODE_PORT=3001
ARG CARDANO_PROTOCOL_MAGIC=1
ELSE IF [ "${network}" = "sanchonet" ]
ARG CARDANO_NODE_HOST=sanchonet-node.play.dev.cardano.org
ARG CARDANO_NODE_PORT=3001
ARG CARDANO_PROTOCOL_MAGIC=4
ELSE IF [ "${network}" = "mainnet" ]
ARG CARDANO_NODE_HOST=backbone.cardano-mainnet.iohk.io
ARG CARDANO_NODE_PORT=3001
ARG CARDANO_PROTOCOL_MAGIC=764824073
END
ENV NETWORK=${network}
ENV STORE_CARDANO_HOST=${CARDANO_NODE_HOST}
ENV STORE_CARDANO_PORT=${CARDANO_NODE_PORT}
ENV STORE_CARDANO_PROTOCOL_MAGIC=${CARDANO_PROTOCOL_MAGIC}
ENV CF_LEDGER_SYNC_DOCKER_IMAGE=cf-ledger-sync:latest
RUN docker compose up ${DOCKER_COMPOSE_UP_ARGS}
docker-compose-down:
LOCALLY
ARG cleanup
IF [ "${cleanup}" = "true" ]
ENV DOCKER_COMPOSE_DOWN_ARGS="-v"
END
RUN docker compose down ${DOCKER_COMPOSE_DOWN_ARGS}