15 grudnia 2021

Portainer #5 - Wordpress

Uruchomienie przygotowanej instalacji wordpress w środowisku docker jako prywatny notatnik i lista zadań:

version: '3'

networks:
  wordpress-net:
    driver: bridge
    name: wordpress-net

services:
  wordpress_db:
    image: mariadb:latest
    container_name: wordpress_db
    restart: unless-stopped
    networks: [wordpress-net]
    volumes: [wordpress_db_data:/var/lib/mysql]
    environment:
      MYSQL_ROOT_PASSWORD: ${PASSWORD}
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: ${PASSWORD}

  wordpress:
    image:  wordpress:latest
    container_name: wordpress
    restart: unless-stopped
    networks: [wordpress-net]
    ports: ["8342:80"]
    volumes: [wordpress_data:/var/www/html]
    environment:
      WORDPRESS_DB_HOST: wordpress_db
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: ${PASSWORD}
      WORDPRESS_DEBUG: 1
    depends_on: [wordpress_db]

volumes:
  wordpress_db_data:
    driver: local
    name: wordpress_db_data

  wordpress_data:
    driver: local
    name: wordpress_data

Manualnie tworzymy docker-compose.yml dla wordpress_cli.

cat > docker-compose.yml <<EOL
version: '3'

networks:
  wordpress-net:
    driver: bridge
    name: wordpress-net

services:
  wpcli:
    image: wordpress:cli
    container_name: wordpress_cli
    networks: [wordpress-net]
    volumes: [wordpress_data:/var/www/html]
    environment:
      WORDPRESS_DB_HOST: wordpress_db
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: aaaaa

volumes:
  wordpress_data:
    driver: local
    name: wordpress_data
EOL

sudo curl -L https://github.com/docker/compose/releases/download/1.28.5/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose run --rm wpcli bash
wp core install --url=portainer-pc.lan:8342 --title="RRRR" --admin_user=admin --admin_password=admin --admin_email=a@b.com --skip-email
wp user update admin --user_pass="aaaaa"
wp core update
wp post delete $(wp post list --post_type='post' --format=ids)
wp post delete $(wp post list --post_type='page' --format=ids)

Linki