-
Notifications
You must be signed in to change notification settings - Fork 6
/
docker-setup.sh
52 lines (45 loc) · 1.24 KB
/
docker-setup.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
MACHINE=$(uname -m)
if [ "$MACHINE" == "x86_64" ] || [ "$MACHINE" == "i686" ]; then
OS_ARCH="amd64"
elif [ "$MACHINE" == "aarch64" ] || [ "$MACHINE" == "arm64" ]; then
OS_ARCH="arm64v8"
else
OS_ARCH="amd64"
echo "Unknown platform - falling back to amd64"
fi
CONFIG_FILE="$(pwd)/files/datafiles/config"
MAIN_PORT=$(grep "\bmainport\b" "$CONFIG_FILE" | awk '{ print $2 }')
WIZ_PORT=$(grep "\bwizport\b" "$CONFIG_FILE" | awk '{ print $2 }')
LINK_PORT=$(grep "\blinkport\b" "$CONFIG_FILE" | awk '{ print $2 }')
cat << EOT > Dockerfile
FROM ${OS_ARCH}/alpine
RUN apk add build-base supervisor bash busybox-extras gdb
COPY supervisord.conf /etc/supervisord.conf
WORKDIR /amnuts
EXPOSE $MAIN_PORT
EXPOSE $WIZ_PORT
EXPOSE $LINK_PORT
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
EOT
cat << EOT > docker-compose.yml
version: "3"
services:
amnuts:
build: ./
image: amnuts-build
environment:
- "MAIN_PORT=$MAIN_PORT"
- "WIZ_PORT=$WIZ_PORT"
- "LINK_PORT=$LINK_PORT"
ports:
- "${MAIN_PORT}:${MAIN_PORT}"
- "${WIZ_PORT}:${WIZ_PORT}"
- "${LINK_PORT}:${LINK_PORT}"
volumes:
- .:/amnuts
security_opt:
- seccomp:unconfined
cap_add:
- SYS_PTRACE
EOT