Skip to content

Commit 42afe75

Browse files
committed
balena-deploy-block.sh: Deploy using compose files
Change-type: patch Signed-off-by: Alex Gonzalez <[email protected]>
1 parent 26a5889 commit 42afe75

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

automation/entry_scripts/balena-deploy-block.sh

+13-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ balena_docker_start "/scratch/docker" "/var/run" "/var/log/docker.log"
1212
balena_docker_wait
1313

1414
BALENAOS_ACCOUNT="${BALENAOS_ACCOUNT:-"balena_os"}"
15-
if [ -f "/host/appimage.docker" ]; then
16-
_local_image=$(docker load -i /host/appimage.docker | cut -d: -f1 --complement | tr -d " " )
17-
fi
1815

1916
echo "[INFO] Logging into $API_ENV as ${BALENAOS_ACCOUNT}"
2017
export BALENARC_BALENA_URL=${API_ENV}
@@ -25,22 +22,32 @@ if [ "$ESR" = "true" ]; then
2522
APPNAME="${APPNAME}-esr"
2623
fi
2724

25+
# Use /deploy folder to generate compose file to use local images that live there
26+
# Use a release dir to limit context
27+
RELEASE_DIR=$(balena_docker_create_compose_file "${MACHINE}" "${API_ENV}" "${RELEASE_VERSION}" "${BALENAOS_TOKEN}" "${BLOCKS}" "/deploy")
28+
if [ ! -f "${RELEASE_DIR}/docker-compose.yml" ]; then
29+
echo "[ERROR] Failed to generate compose file"
30+
exit 1
31+
fi
32+
2833
if [ -f "/deploy/balena.yml" ]; then
29-
echo -e "\nversion: $(balena_lib_get_os_version)" >> "/deploy/balena.yml"
34+
cp "/deploy/balena.yml" "${RELEASE_DIR}"
35+
echo -e "\nversion: $(balena_lib_get_os_version)" >> "${RELEASE_DIR}/balena.yml"
3036
fi
3137

3238
echo "[INFO] Deploying to ${BALENAOS_ACCOUNT}/$APPNAME"
3339
balena_api_create_public_app "${APPNAME}" "${BALENARC_BALENA_URL}" "${MACHINE}" "${balenaCloudEmail}" "${balenaCloudPassword}" "${ESR}" "${BOOTABLE}"
34-
_releaseID=$(balena_lib_release "${BALENAOS_ACCOUNT}/$APPNAME" "${FINAL}" "/deploy" "${API_ENV}" "$_local_image")
40+
_releaseID=$(balena_lib_release "${BALENAOS_ACCOUNT}/$APPNAME" "${FINAL}" "${RELEASE_DIR}" "${API_ENV}")
3541
if [ -z "${_releaseID}" ]; then
3642
echo "[INFO] Failed to deploy to ${BALENAOS_ACCOUNT}/$APPNAME"
3743
exit 1
3844
fi
3945

4046
# Legacy hostapp tagging
41-
if [ "${DEPLOY}" = "yes" ] && [ "${FINAL}" = "yes" ]; then
47+
if [ "${FINAL}" = "yes" ]; then
4248
balena_lib_release_finalize "${_releaseID}" "${BALENAOS_ACCOUNT}/${APPNAME}" "${API_ENV}" "${BALENAOS_TOKEN}" "${ESR}"
4349
fi
4450

4551
balena_docker_stop
52+
rm -rf "${RELEASE_DIR:?}"
4653
exit 0

0 commit comments

Comments
 (0)