Fix misc deployment script errors
This commit is contained in:
parent
43f6652bc2
commit
c3a2aa90b2
18
packer/riju
18
packer/riju
|
@ -4,7 +4,11 @@ set -euo pipefail
|
|||
|
||||
domain="$(ls /etc/letsencrypt/live | grep -v README | head -n1)" || true
|
||||
|
||||
if [[ -n "${domain}" ]]; then
|
||||
if [[ -n "${DISABLE_TLS:-}" ]]; then
|
||||
echo "Disabling TLS due to DISABLE_TLS=${DISABLE_TLS}" >&2
|
||||
elif [[ -z "${domain}" ]]; then
|
||||
echo "No certs installed in /etc/letsencrypt/live, disabling TLS" >&2
|
||||
else
|
||||
echo "Detected cert for domain: ${domain}, enabling TLS" >&2
|
||||
export TLS=1
|
||||
TLS_PRIVATE_KEY="$(base64 "/etc/letsencrypt/live/${domain}/privkey.pem")"
|
||||
|
@ -16,8 +20,6 @@ if [[ -n "${domain}" ]]; then
|
|||
else
|
||||
echo "Domain is not riju.codes, disabling analytics" >&2
|
||||
fi
|
||||
else
|
||||
echo "No certs installed in /etc/letsencrypt/live, disabling TLS" >&2
|
||||
fi
|
||||
|
||||
if [[ -n "${DETACH:-}" ]]; then
|
||||
|
@ -29,8 +31,14 @@ else
|
|||
fi
|
||||
|
||||
port_args="${PORT_MAPPING:--p 0.0.0.0:80:6119 -p 0.0.0.0:443:6120}"
|
||||
image_name="${IMAGE_NAME:-riju:app}"
|
||||
container_name="${CONTAINER_NAME:-riju-prod}"
|
||||
|
||||
if docker container inspect ${container_name} &>/dev/null; then
|
||||
docker stop ${container_name}
|
||||
fi
|
||||
|
||||
docker run --rm ${port_args} ${extra_args} \
|
||||
-e TLS -e TLS_PRIVATE_KEY -e TLS_CERTIFICATE -e ANALYTICS \
|
||||
-h riju --name "${CONTAINER_NAME:-riju-prod}" \
|
||||
"${IMAGE_NAME:-riju:app}"
|
||||
-h riju --name "${container_name}" \
|
||||
"${image_name}"
|
||||
|
|
|
@ -16,13 +16,14 @@ docker pull "${image}"
|
|||
|
||||
echo "Start new image in test container..." >&2
|
||||
CONTAINER_NAME=riju-test IMAGE_NAME="${image}" DETACH=1 \
|
||||
PORT_MAPPING="-p 127.0.0.1:6119:6119" riju
|
||||
PORT_MAPPING="-p 127.0.0.1:6119:6119" DISABLE_TLS=0 riju
|
||||
|
||||
echo "Wait for web server to come up..." >&2
|
||||
sleep 5
|
||||
|
||||
echo "Test web server health..." >&2
|
||||
curl -fsSL http://localhost:6119 | head -n15
|
||||
output="$(curl -fsSL http://localhost:6119)"
|
||||
head -n15 <<< "${output}"
|
||||
|
||||
echo "Tear down test container..." >&2
|
||||
docker stop riju-test
|
||||
|
|
Loading…
Reference in New Issue