forked from forem/forem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer-setup
executable file
·102 lines (72 loc) · 2.64 KB
/
container-setup
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env bash
set -e
if [[ "$OSTYPE" == "darwin"* ]]; then
if hash docker 2>/dev/null; then
CONTAINER_RUNTIME=docker
else
echo "Error! We could not find docker on your Mac!"
echo "Please install Docker for Mac:"
echo "https://docs.docker.com/docker-for-mac/install/"
exit 1
fi
if hash docker-compose 2>/dev/null; then
CONTAINER_COMPOSE=docker-compose
else
echo "Error! We could not find a docker-compose on your Mac!"
echo "Please install Docker for Mac:"
echo "https://docs.docker.com/docker-for-mac/install/"
exit 1
fi
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
if hash podman 2>/dev/null; then
CONTAINER_RUNTIME=podman
elif hash docker 2>/dev/null; then
CONTAINER_RUNTIME=docker
else
echo "Error! We could not find a container runtime on your Linux install!"
echo "Please install Podman v1.9.3 or greater:"
echo "https://podman.io/getting-started/installation.html"
exit 1
fi
if hash podman-compose 2>/dev/null; then
CONTAINER_COMPOSE=podman-compose
elif hash docker 2>/dev/null; then
CONTAINER_COMPOSE=docker-compose
else
echo "Error! We could not find ${CONTAINER_COMPOSE} on your Linux install!"
echo "Please install Podman Compose:"
echo "https://github.com/containers/podman-compose#installation"
exit 1
fi
else
echo "Oof! Sorry! This OS is unsupported! :("
echo "If you're on Windows OS and have Docker or Podman for Windows installed:"
echo "Docker: https://docs.docker.com/docker-for-windows/install/"
echo "Podman: https://podman.io/getting-started/installation"
echo
echo "Execute the following:"
echo "docker-compose build"
echo "docker-compose up"
exit 1
fi
echo "Starting the Forem container stack..."
if [ "${CONTAINER_RUNTIME}" = "docker" ]; then
if [[ ! -d vendor/bundle || ! "$(ls -A vendor/bundle)" ]]; then
echo "The vendor/bundle directory is empty or does not exist."
echo "This will cause bundle install to run which takes a long time with ${CONTAINER_RUNTIME}."
echo "Depending on your hardware specs, the initial setup can take"
echo "30 to 45 minutes. Please stand by..."
sleep 10
fi
docker-compose up
elif [ "${CONTAINER_RUNTIME}" = "podman" ]; then
if podman pod exists forem; then
echo "The forem pod is already setup. Please run:"
echo ""
echo "podman-compose -p forem -f container-compose.yml down"
echo ""
echo "to bring down the Forem container stack before running container-setup."
else
podman-compose -p forem -f container-compose.yml up
fi
fi