Archive for febrero, 2023
watchtower para mantener tu moodle actualizado.
# Creo la carpeta
mkdir wt
# ingreso
cd wt
# creo el docker-compose.yml
vi docker-compose.yml
version: '3.7'
services:
watchtower:
image: containrrr/watchtower:latest
container_name: watchtower
restart: always
env_file:
- ./.env
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- WATCHTOWER_CLEANUP=${WATCHTOWER_CLEANUP}
- WATCHTOWER_INCLUDE_RESTARTING=${WATCHTOWER_INCLUDE_RESTARTING}
- WATCHTOWER_INCLUDE_STOPPED=${WATCHTOWER_INCLUDE_STOPPED}
- WATCHTOWER_REVIVE_STOPPED=${WATCHTOWER_REVIVE_STOPPED}
- WATCHTOWER_NO_RESTART=${WATCHTOWER_NO_RESTART}
- WATCHTOWER_TIMEOUT=${WATCHTOWER_TIMEOUT}
- WATCHTOWER_SCHEDULE=${WATCHTOWER_SCHEDULE}
- WATCHTOWER_DEBUG=${WATCHTOWER_DEBUG}
- WATCHTOWER_LABEL_ENABLE=${WATCHTOWER_LABEL_ENABLE}
- WATCHTOWER_NOTIFICATIONS=${WATCHTOWER_NOTIFICATIONS}
- WATCHTOWER_NOTIFICATION_EMAIL_FROM=${WATCHTOWER_NOTIFICATION_EMAIL_FROM}
- WATCHTOWER_NOTIFICATION_EMAIL_TO=${WATCHTOWER_NOTIFICATION_EMAIL_TO}
- WATCHTOWER_NOTIFICATION_EMAIL_SERVER=${WATCHTOWER_NOTIFICATION_EMAIL_SERVER}
- WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER=${WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER}
- WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=${WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD}
- WATCHTOWER_NOTIFICATION_EMAIL_DELAY=${WATCHTOWER_NOTIFICATION_EMAIL_DELAY}
- WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT=${WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT}
- TZ=${TZ}
labels:
- "com.centurylinklabs.watchtower.enable=true"
db:
image: mariadb:latest
env_file:
- ./.env
environment:
- MARIADB_USER=${MARIADB_USER}
- MARIADB_PASSWORD=${MARIADB_PASSWORD}
- MARIADB_DATABASE=${MARIADB_DATABASE}
- MARIADB_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD}
- TZ=${TZ}
labels:
- "com.centurylinklabs.watchtower.enable=true"
volumes:
- ./db:/bitnami/mariadb
restart: always
ports:
- "3606:3606"
moodle:
image: bitnami/moodle:latest
env_file:
- ./.env
environment:
- BITNAMI_DEBUG=${BITNAMI_DEBUG}
- MARIADB_HOST=${MARIADB_HOST}
- MARIADB_PORT_NUMBER=${MARIADB_PORT_NUMBER}
- MOODLE_DATABASE_USER=${MOODLE_DATABASE_USER}
- MOODLE_DATABASE_PASSWORD=${MOODLE_DATABASE_PASSWORD}
- MOODLE_DATABASE_NAME=${MOODLE_DATABASE_NAME}
- MOODLE_USERNAME=${MOODLE_USERNAME}
- MOODLE_PASSWORD=${MOODLE_PASSWORD}
- MOODLE_SITE_NAME=${MOODLE_SITE_NAME}
- TZ=${TZ}
labels:
- "com.centurylinklabs.watchtower.enable=true"
volumes:
- ./moodle:/bitnami/moodle
- ./moodledata:/bitnami/moodledata
restart: always
ports:
- "80:8080"
depends_on:
- db
# creo el .env
vi .env
BITNAMI_DEBUG=true
MARIADB_USER=bn_moodle
MARIADB_PASSWORD=bn_password
MARIADB_DATABASE=bitnami_moodle
MARIADB_ROOT_PASSWORD=root_password
MARIADB_HOST=db
MARIADB_PORT_NUMBER=3306
MOODLE_DATABASE_USER=bn_moodle
MOODLE_DATABASE_PASSWORD=bn_password
MOODLE_DATABASE_NAME=bitnami_moodle
MOODLE_USERNAME=Pablo
MOODLE_PASSWORD=clave
MOODLE_SITE_NAME=titulo
WATCHTOWER_CLEANUP=true
WATCHTOWER_INCLUDE_RESTARTING=true
WATCHTOWER_INCLUDE_STOPPED=true
WATCHTOWER_REVIVE_STOPPED=false
WATCHTOWER_NO_RESTART=false
WATCHTOWER_TIMEOUT=30s
WATCHTOWER_SCHEDULE=30 * * * *
WATCHTOWER_DEBUG=false
WATCHTOWER_LABEL_ENABLE=1
WATCHTOWER_NOTIFICATIONS=email
WATCHTOWER_NOTIFICATION_EMAIL_FROM=mail@gmail.com
WATCHTOWER_NOTIFICATION_EMAIL_TO=mail@gmail.com
WATCHTOWER_NOTIFICATION_EMAIL_SERVER=smtp.gmail.com
WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER=mail@gmail.com
WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=clave
WATCHTOWER_NOTIFICATION_EMAIL_DELAY=2
WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT=587
TZ=America/Argentina/Buenos_Aires
# en moodle si la db no esta levantada y funcionando se muere.
# Así que levanto primero db y espero a que labure
docker-compose -d db
# una vez levantada la db levanto lo demas
docker-compose -d
# para que funcione el envio de mail hay que habilitar el acceso a aplicaciones menos seguras, sino no anda.
ftp
cat docker-compose.yaml
version: '3.3'
services:
ftps-server:
volumes:
- './data:/home/usuario'
environment:
- USER=usuario
- PASSWORD=clave
ports:
- '21:21'
- '3000-3010:3000-3010'
image: mikatux/ftps-server
restart: always
un ejemplo de wordpress en ubuntu 2004 simplificado
# Me baso en esta guía, pero solo hago una parte. Para ver la guía completa anda a la url que sigue
# https://www.howtoforge.com/how-to-install-wordpress-with-docker-compose/
# Esto es la instalación de docker en ubuntu 2004
sudo apt update
sudo apt install wget curl nano software-properties-common dirmngr apt-transport-https gnupg gnupg2 ca-certificates lsb-release ubuntu-keyring unzip -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo systemctl status docker
sudo usermod -aG docker $(whoami)
su - ${USER}
groups
# Aca viene ya montar el wordpress
mkdir wordpress
cd wordpress
vi docker-compose.yml
version: '3.9'
services:
wp:
image: wordpress:latest
container_name: wordpress-app
restart: always
ports:
- "80:80"
volumes:
- ./config/php.conf.ini:/usr/local/etc/php/conf.d/conf.ini
- ./html:/var/www/html
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: "${DB_NAME}"
WORDPRESS_DB_USER: "${DB_USER_NAME}"
WORDPRESS_DB_PASSWORD: "${DB_USER_PASSWORD}"
depends_on:
- db
links:
- db
db:
image: mysql:latest
container_name: wordpressdb
restart: always
command: [
'--default_authentication_plugin=mysql_native_password',
'--character-set-server=utf8mb4',
'--collation-server=utf8mb4_unicode_ci'
]
volumes:
- ./db_data:/var/lib/mysql
environment:
MYSQL_DATABASE: "${DB_NAME}"
MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD}"
MYSQL_USER: "${DB_USER_NAME}"
MYSQL_PASSWORD: "${DB_USER_PASSWORD}"
vi .env
DB_NAME=wordpress
DB_USER_NAME=username
DB_USER_PASSWORD=userpassword
DB_ROOT_PASSWORD=password
mkdir config
vi config/php.conf.ini
file_uploads = On
memory_limit = 500M
upload_max_filesize = 3000M
post_max_size = 3000M
max_execution_time = 600
# Levantarlo
docker compose up -d
# Y luego ver como va con lo siguiente y esperar a que levante la conexion la db
docker compose ps
docker composr logs -f
Mantener el horario del SO en un contenedor
Para que el contenedor mantenga el horario del SO es necesario agregar lo siguiente en el volumen del mismo.
- "/etc/timezone:/etc/timezone:ro"
- "/etc/localtime:/etc/localtime:ro"
En este ejemplo vemos la forma de hacerlo en un docker-compose. Obviamente el SO tiene que tener bien configurado el horario.
proteger vistas en tu wordpress
Un buen plugin de wordpress cuando tenes un sitio publico en donde estas trabajando y no queres que cualquiera lo pueda visualizar.
https://github.com/wpexpertsio/password-protected
ip estatica en ubuntu 2004
# Me guio de
# https://www.linuxtechi.com/assign-static-ip-address-ubuntu-20-04-lts/
# Reviso el siguiente archivo viendo que aparesca lo siguiente
cat /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg
network: {config: disabled}
# Verifico la ip y que se tome dinamicamente
ip add show
# edito lo siguiente
sudo vi /etc/netplan/00-installer-config.yaml
network:
ethernets:
enp0s3:
addresses: [192.168.0.152/24]
gateway4: 192.168.0.1
nameservers:
addresses: [192.168.0.1, 4.2.2.2, 8.8.8.8]
version: 2
# Aplico el cambio
sudo netplan apply
Comentarios recientes