forked from 28mm/blast-radius
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
38 lines (28 loc) · 1009 Bytes
/
docker-entrypoint.sh
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
#!/bin/bash
set -e
# prepare overlayFS
# shamelessly taken from https://gist.github.com/detunized/7c8fc4c37b49c5475e68ef9574587eee
mkdir -p /tmp/overlay && \
mount -t tmpfs tmpfs /tmp/overlay && \
mkdir -p /tmp/overlay/{upper,work} && \
mkdir -p /workdir-rw && \
mount -t overlay overlay -o lowerdir=/workdir,upperdir=/tmp/overlay/upper,workdir=/tmp/overlay/work /workdir-rw
cd /workdir-rw
# if we are given arguments we assume
# $1 will be "--serve" and
# $2 the actual stack to run tf in
# so we have to init terraform in the given directory $2
# if $2 is no directory just fall back to the default and run
# terraform init in /workdir
# are we meant to run terraform in a sub-directory?
[ $# == 2 ] && [ -d "$2" ] && {
cd $2
}
# is terraform already initialized?
[ -d '.terraform' ] && terraform get --update=true
# re-initialize anyway.
terraform init -input=false
# it's possible that we're in a sub-directory. leave.
cd /workdir-rw
# okay, we should be good to go.
blast-radius $1 $2 $3