Created
February 18, 2022 20:40
-
-
Save xificurC/5f16708ff18faf518a1553f334dc7153 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh -f | |
set -uo pipefail | |
function pr { | |
print -- "!! $*" | |
$* | |
} | |
pr sudo pacman -S --needed pwgen docker docker-compose | |
if ! groups | grep -q docker; then | |
pr sudo usermod -aG docker $USER | |
echo "RESTART NEEDED" | |
exit 0 | |
fi | |
if [[ $(systemctl is-active docker) == inactive ]]; then | |
pr sudo systemctl enable --now docker.socket | |
fi | |
if [[ ! -r docker-compose.yml ]]; then | |
dbpw=$(pwgen -s 12 1) | |
cat <<EOF >docker-compose.yml | |
version: "3.9" | |
services: | |
db: | |
image: mysql:5.7 | |
volumes: | |
- db_data:/var/lib/mysql | |
restart: always | |
environment: | |
MYSQL_ROOT_PASSWORD: $(pwgen -s 12 1) | |
MYSQL_DATABASE: wordpress | |
MYSQL_USER: wordpress | |
MYSQL_PASSWORD: $dbpw | |
wordpress: | |
depends_on: | |
- db | |
image: wordpress:latest | |
volumes: | |
- wordpress_data:/var/www/html | |
ports: | |
- "8000:80" | |
restart: always | |
environment: | |
WORDPRESS_DB_HOST: db | |
WORDPRESS_DB_USER: wordpress | |
WORDPRESS_DB_PASSWORD: $dbpw | |
WORDPRESS_DB_NAME: wordpress | |
volumes: | |
db_data: {} | |
wordpress_data: {} | |
EOF | |
fi | |
echo "NOW RUN docker-compose up -d" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment