docbrown/bin/container-setup
Joe Doss 3e0a40741e
Update containers: DEV => Forem (#9611)
This PR moves the away from the dev specific naming to forem w/r/t container
things. Also moves to the Forem quay.io org.

* Move to Forem from DEV
* Add in assets and packs directories.
2020-08-03 16:54:45 -05:00

106 lines
2.6 KiB
Bash
Executable file

#!/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! :("
fi
echo "Building the Forem container image!"
if [ "${CONTAINER_RUNTIME}" = "docker" ]; then
echo "This will take a while if you are building the container for the first time."
docker-compose build
elif [ "${CONTAINER_RUNTIME}" = "podman" ]; then
podman-compose -f container-compose.yml build
fi
echo "Starting the Forem container stack..."
if [ "${CONTAINER_RUNTIME}" = "docker" ]; then
if [[ ! -d .gems/ || ! "$(ls -A .gems)" ]]; then
echo "The .gems 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