Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ops(docker): arm64 support & improvement for smoother install/uninstall #66

Closed
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ build: ## Build all services.
username: ## Generate Username (Use only after make up).
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} exec web python3 manage.py createsuperuser

migrations: ## Make migrations
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} exec web python3 manage.py migrate

pull: ## Pull Docker images.
docker login docker.pkg.github.com
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} pull
Expand Down
48 changes: 39 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,27 @@ services:
environment:
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
- PGUSER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_PORT=${POSTGRES_PORT}
volumes:
- postgres_data:/var/lib/postgresql/data/
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5
networks:
- rengine_network

redis:
image: "redis:alpine"
hostname: redis
healthcheck:
test: ["CMD", "redis-cli","ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
- rengine_network

Expand Down Expand Up @@ -47,9 +58,16 @@ services:
- POSTGRES_HOST=${POSTGRES_HOST}
- MAX_CONCURRENCY=${MAX_CONCURRENCY}
- MIN_CONCURRENCY=${MIN_CONCURRENCY}
healthcheck:
test: ["CMD", "celery","-A","reNgine","status"]
interval: 10s
timeout: 10s
retries: 60
depends_on:
- db
- redis
db:
condition: service_healthy
redis:
condition: service_healthy
networks:
- rengine_network

Expand All @@ -66,7 +84,8 @@ services:
- POSTGRES_PORT=${POSTGRES_PORT}
- POSTGRES_HOST=${POSTGRES_HOST}
depends_on:
- celery
celery:
condition: service_healthy
volumes:
- ./web:/usr/src/app
- github_repos:/usr/src/github
Expand Down Expand Up @@ -108,10 +127,18 @@ services:
- static_volume:/usr/src/app/staticfiles/
ports:
- "8000:8000"
healthcheck:
test: ["CMD", "curl", "-f", "-k", "http://localhost:8000"]
interval: 10s
timeout: 10s
retries: 10
depends_on:
- db
- celery
- celery-beat
db:
condition: service_healthy
celery:
condition: service_healthy
celery-beat:
condition: service_started
networks:
rengine_network:
aliases:
Expand All @@ -124,9 +151,12 @@ services:
- 8082:8082/tcp
- 443:443/tcp
depends_on:
- web
- db
- redis
web:
condition: service_healthy
db:
condition: service_healthy
redis:
condition: service_healthy
secrets:
- source: proxy.ca
target: /etc/nginx/certs/rengine_chain.pem
Expand Down
167 changes: 79 additions & 88 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,129 +1,120 @@
#!/bin/bash

#log messages in different colors
log() {
tput setaf "$2"
printf "$1\r\n"
tput sgr0 # Reset text color
}

# Check for root privileges
if [ "$(id -u)" -ne 0 ]; then
log "Error: Please run this script as root!" 1
log "Example: sudo $0" 1
exit 1
fi

tput setaf 2;
cat web/art/reNgine.txt

tput setaf 1; echo "Before running this script, please make sure Docker is running and you have made changes to .env file."
tput setaf 2; echo "Changing the postgres username & password from .env is highly recommended."
log "\r\nBefore running this script, please make sure Docker is running and you have made changes to .env file." 1
log "Changing the postgres username & password from .env is highly recommended.\r\n" 1

log "#########################################################################" 4
log "Please note that, this installation script is only intended for Linux" 3
log "x86_64 and arm64 platform (Rasp. pi and Apple Mx series) are supported" 3
log "#########################################################################\r\n" 4

tput setaf 4;
tput setaf 1;
read -p "Are you sure, you made changes to .env file (y/n)? " answer
case ${answer:0:1} in
y|Y|yes|YES|Yes )
echo "Continiuing Installation!"
log "Continiuing Installation!" 2
;;
* )
if [ -x "$(command -v nano)" ]; then
tput setaf 2; echo "nano already installed, skipping."
log "nano already installed, skipping." 2
else
sudo apt update && sudo apt install nano -y
tput setaf 2; echo "nano installed!!!"
log "nano installed!!!" 2
fi
nano .env
;;
esac

echo " "
tput setaf 3;
echo "#########################################################################"
echo "Please note that, this installation script is only intended for Linux"
echo "For Mac and Windows, refer to the official guide https://rengine.wiki"
echo "#########################################################################"

echo " "
tput setaf 4;
echo "Installing reNgine and it's dependencies"

echo " "
if [ "$EUID" -ne 0 ]
then
tput setaf 1; echo "Error installing reNgine, Please run this script as root!"
tput setaf 1; echo "Example: sudo ./install.sh"
exit
fi
log "\r\nInstalling reNgine and its dependencies" 4
log "=========================================================================" 4

log "\r\n#########################################################################" 4
log "Installing curl..." 4

echo " "
tput setaf 4;
echo "#########################################################################"
echo "Installing curl..."
echo "#########################################################################"
if [ -x "$(command -v curl)" ]; then
tput setaf 2; echo "CURL already installed, skipping."
if ! command -v curl 2> /dev/null; then
apt update && apt install curl -y
log "CURL installed!!!" 2
else
sudo apt update && sudo apt install curl -y
tput setaf 2; echo "CURL installed!!!"
log "CURL already installed, skipping." 2
fi

echo " "
tput setaf 4;
echo "#########################################################################"
echo "Installing Docker..."
echo "#########################################################################"
if [ -x "$(command -v docker)" ]; then
tput setaf 2; echo "Docker already installed, skipping."
else

log "\r\n#########################################################################" 4
log "Installing Docker..." 4

if ! command -v docker 2> /dev/null; then
curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
tput setaf 2; echo "Docker installed!!!"
log "Docker installed!!!" 2
else
log "Docker already installed, skipping." 2
fi

echo " "
tput setaf 4;
echo "#########################################################################"
echo "Installing docker compose"
echo "#########################################################################"
if [ -x "$(command -v docker compose)" ]; then
tput setaf 2; echo "docker compose already installed, skipping."
else
curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
log "\r\n#########################################################################" 4
log "Installing docker-compose" 4

if ! command -v docker-compose 2> /dev/null; then
curl -L "https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
tput setaf 2; echo "docker compose installed!!!"
log "docker-compose installed!!!" 2
else
log "docker-compose already installed, skipping." 2
fi

echo " "
tput setaf 4;
echo "#########################################################################"
echo "Installing make"
echo "#########################################################################"
if [ -x "$(command -v make)" ]; then
tput setaf 2; echo "make already installed, skipping."
log "\r\n#########################################################################" 4
log "Installing make" 4

if ! command -v make 2> /dev/null; then
apt install make -y
log "make installed!!!" 2
else
apt install make
log "make already installed, skipping." 2
fi

echo " "
tput setaf 4;
echo "#########################################################################"
echo "Checking Docker status"
echo "#########################################################################"
log "\r\n#########################################################################" 4
log "Checking Docker status" 4
if docker info >/dev/null 2>&1; then
tput setaf 4;
echo "Docker is running."
log "Docker is running." 2
else
tput setaf 1;
echo "Docker is not running. Please run docker and try again."
echo "You can run docker service using sudo systemctl start docker"
log "Docker is not running. Please run docker and try again." 1
log "You can run Docker service using: sudo systemctl start docker" 1
exit 1
fi

echo " "
tput setaf 4;
echo "#########################################################################"
echo "Installing reNgine"
echo "#########################################################################"
make certs && make build && make up && tput setaf 2 && echo "reNgine is installed!!!" && failed=0 || failed=1
log "\r\n#########################################################################" 4
log "Installing reNgine, please be patient it could take a while" 4

if [ "${failed}" -eq 0 ]; then
sleep 3
log "\r\n=========================================================================" 5
log "Generating certificates and building docker images" 5
log "=========================================================================" 5
make certs && make build && log "reNgine is built" 2 || { log "reNgine installation failed!!" 1; exit 1; }

echo " "
tput setaf 4;
echo "#########################################################################"
echo "Creating an account"
echo "#########################################################################"
make username
log "\r\n=========================================================================" 5
log "Docker containers starting, please wait celery container could be long" 5
log "=========================================================================" 5
make up && log "reNgine is installed!!!" 2 || { log "reNgine installation failed!!" 1; exit 1; }

tput setaf 2 && printf "\n%s\n" "Thank you for installing reNgine, happy recon!!"
else
tput setaf 1 && printf "\n%s\n" "reNgine installation failed!!"
fi

log "\r\n#########################################################################" 4
log "Creating an account" 4
log "#########################################################################" 4
make username

log "\r\nThank you for installing reNgine, happy recon!!" 2
Loading