-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepare-package.bash
More file actions
executable file
·66 lines (51 loc) · 2.26 KB
/
Copy pathprepare-package.bash
File metadata and controls
executable file
·66 lines (51 loc) · 2.26 KB
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
#!/usr/bin/env bash
set -eu
THIS_SCRIPT="$(readlink -f "$0")"
THIS_DIR="$(dirname "${THIS_SCRIPT}")"
LOG="${THIS_DIR}/prepare-package.log"
PRIVATE_KEY="margo-poc.private.pgp"
source "${THIS_DIR}/common.source"
check_command docker
cleanup() {
set +e
docker rmi ${APP_NAME}-web:latest &>> ${LOG}
rm -f "${APP_NAME}/${APP_NAME}-web.tar" "${APP_NAME}/${APP_NAME}-redis.tar"
gpgconf --kill gpg-agent
rm -r $GNUPGHOME
unset $GNUPGHOME
}
trap cleanup EXIT
echo ; echo "📦📦📦 Create docker-compose app and package 📦📦📦"
echo ; echo "📦 Create a pseudo docker-compose app 📦"
echo "It will only contain a docker-compose file and two container image archives."
echo
export GNUPGHOME="$(mktemp -d ${TMPDIR}/gpgtemp.XXXXXXXXXX)"
rm -f ${LOG}
gpg-agent --daemon &>> ${LOG}
KEY_ID=$(gpg --import "${PRIVATE_KEY}" 2>&1 | grep '^gpg: key .*: public key .* imported$' | sed 's/^gpg: key \(.*\): .*/\1/')
rm -f "${APP_NAME}/${PUBLIC_KEY}"
gpg --output "${APP_NAME}/${PUBLIC_KEY}" --armor --export ${KEY_ID} &>> ${LOG}
(
cd "${APP_NAME}"
echo "Creating container image archive '${APP_NAME}-web'"
docker build --platform linux/amd64 --tag ${APP_NAME}-web:latest . &>> ${LOG}
docker save ${APP_NAME}-web:latest > ${APP_NAME}-web.tar
echo "Creating container image archive '${APP_NAME}-redis.tar'"
docker pull --platform linux/amd64 redis:alpine &>> ${LOG}
docker save redis:alpine > ${APP_NAME}-redis.tar
echo "Creating '${APP_NAME}.app'"
tar -czf "${APP_NAME}.app" docker-compose.yaml ${APP_NAME}-web.tar ${APP_NAME}-redis.tar
rm -f ${APP_NAME}-web.tar ${APP_NAME}-redis.tar
echo ; echo "Content of the pseudo-app:"
tar -tzf "${APP_NAME}.app"
echo ; echo "Create app signature"
rm -f "${APP_NAME}.app.sig"
gpg --output "${APP_NAME}.app.sig" --detach-sign "${APP_NAME}.app"
gpg --verify "${APP_NAME}.app.sig" "${APP_NAME}.app" &>> ${LOG}
echo ; echo "📦 Create a pseudo-package to be pushed 📦"
echo "It will contain the app and the signature" ; echo
echo "Content of the pseudo-package:"
tar -czf "${APP_NAME}.tar.gz" "${APP_NAME}.app" "${APP_NAME}.app.sig"
tar -tzf "${APP_NAME}.tar.gz"
)
echo ; echo "📦📦📦📦📦📦📦📦📦📦📦📦📦📦📦📦📦📦📦" ; echo