blob: 090e33de777fbbd4bf8fd35e9e62c06e18ce0ca4 (
plain)
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
|
#!/usr/bin/env bash
set -euo pipefail
WORKDIR="/tmp/${EVENTLINE_JOB_NAME}"
cleanup() {
rm -rf "${WORKDIR}"
}
trap cleanup EXIT
ret=0; buildah images adyxax/alpine &>/dev/null || ret=$?
if [[ "${ret}" != 0 ]]; then
buildah rmi --all || true
ALPINE_LATEST=$(curl --silent https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/x86_64/ |
perl -lane '$latest = $1 if $_ =~ /^<a href="(alpine-minirootfs-\d+\.\d+\.\d+-x86_64\.tar\.gz)">/; END {print $latest}'
)
if [ ! -e "./${ALPINE_LATEST}" ]; then
echo "Fetching ${ALPINE_LATEST}..."
curl --silent "https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/x86_64/${ALPINE_LATEST}" \
--output "./${ALPINE_LATEST}"
fi
ctr=$(buildah from scratch)
buildah add "${ctr}" "${ALPINE_LATEST}" /
buildah run "${ctr}" /bin/sh -c 'apk upgrade --no-cache'
buildah run "${ctr}" /bin/sh -c 'apk add --no-cache pcre sqlite-libs'
buildah commit "${ctr}" adyxax/alpine
buildah rm "${ctr}"
fi
ret=0; buildah images adyxax/zig &>/dev/null || ret=$?
if [[ "${ret}" != 0 ]]; then
zig=$(buildah from adyxax/alpine)
buildah run "${zig}" /bin/sh -c 'echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories'
buildah run "${zig}" /bin/sh -c 'apk upgrade --no-cache'
buildah run "${zig}" /bin/sh -c 'apk add --no-cache zig'
buildah commit "${zig}" adyxax/zig
else
zig=$(buildah from adyxax/zig)
fi
buildah run -v "${WORKDIR}":/gb "${zig}" /bin/sh -c 'cd /gb; zig build -Drelease-small=true'
buildah rm "${zig}"
ret=0; buildah images adyxax/wasm4 &>/dev/null || ret=$?
if [[ "${ret}" != 0 ]]; then
wasm4=$(buildah from adyxax/alpine)
buildah run "${wasm4}" /bin/sh -c 'apk add --no-cache nodejs-current npm'
buildah run "${wasm4}" /bin/sh -c 'npm install -g wasm4'
buildah commit "${wasm4}" adyxax/wasm4
else
wasm4=$(buildah from adyxax/wasm4)
fi
buildah copy "${wasm4}" "${WORKDIR}/zig-out/lib/cart.wasm" /
buildah config \
--author 'Julien Dessaux' \
--cmd "w4 run --port 80 --no-open --no-qr /cart.wasm" \
--port 80 \
"${wasm4}"
buildah commit "${wasm4}" adyxax/grenade-brothers
buildah rm "${wasm4}"
trap - EXIT
|