commit
42513a6b5c
@ -0,0 +1,45 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
mysql:
|
||||
container_name: "seminariodb"
|
||||
image: mysql:5.7
|
||||
restart: always
|
||||
environment:
|
||||
MYSQL_DATABASE: ${MYSQL_DB}
|
||||
MYSQL_USER: ${MYSQL_USER}
|
||||
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
|
||||
MYSQL_RANDOM_ROOT_PASSWORD: "1"
|
||||
ports:
|
||||
- "3308:3306"
|
||||
volumes:
|
||||
- ./docker/mysql:/var/lib/mysql
|
||||
- ./db/init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
|
||||
|
||||
|
||||
directus:
|
||||
container_name: directus_seminario
|
||||
image: directus/directus:v8-apache
|
||||
restart: always
|
||||
ports:
|
||||
- "13000:80"
|
||||
environment:
|
||||
DIRECTUS_APP_ENV: "production"
|
||||
DIRECTUS_AUTH_PUBLICKEY: ${DIRECTUS_AUTH_PUBLICKEY}
|
||||
DIRECTUS_AUTH_SECRETKEY: ${DIRECTUS_AUTH_SECRETKEY}
|
||||
DIRECTUS_DATABASE_HOST: "seminariodb"
|
||||
DIRECTUS_DATABASE_PORT: "3306"
|
||||
DIRECTUS_DATABASE_NAME: ${MYSQL_DB}
|
||||
DIRECTUS_DATABASE_USERNAME: ${MYSQL_USER}
|
||||
DIRECTUS_DATABASE_PASSWORD: ${MYSQL_PASSWORD}
|
||||
DIRECTUS_INSTALL_TITLE: "Seminario CMS"
|
||||
volumes:
|
||||
- ./docker/directus/config:/var/directus/config
|
||||
- ./docker/directus/uploads:/var/directus/public/uploads
|
||||
|
||||
adminer:
|
||||
container_name: adminer_seminario
|
||||
image: adminer
|
||||
ports:
|
||||
- "8090:8080"
|
@ -0,0 +1,6 @@
|
||||
MYSQL_HOST=mysql
|
||||
MYSQL_DB=directus
|
||||
MYSQL_PASSWORD=directus
|
||||
MYSQL_USER=directus
|
||||
DIRECTUS_AUTH_PUBLICKEY=
|
||||
DIRECTUS_AUTH_SECRETKEY=
|
@ -0,0 +1,68 @@
|
||||
#!/bin/sh
|
||||
set -Eeo pipefail
|
||||
|
||||
# This script asumes postgres container_name is "mysql", and the user and db are "directus"
|
||||
|
||||
# get $MYSQL_PASSWORD from .env
|
||||
source ./.env
|
||||
|
||||
backup() {
|
||||
if [ -z "$FILENAME" ]; then
|
||||
FILENAME="dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql"
|
||||
fi
|
||||
|
||||
sudo docker-compose exec -T mysql /usr/bin/mysqldump -udirectus -p$MYSQL_PASSWORD directus > $FILENAME
|
||||
echo "$FILENAME written"
|
||||
exit 0
|
||||
}
|
||||
|
||||
restore() {
|
||||
if [ -z "$FILENAME" ]; then
|
||||
help
|
||||
exit 1
|
||||
elif [ -f "$FILENAME" ]; then
|
||||
cat "$FILENAME" | sudo docker-compose exec -T /bin/bash -c 'mysql -uroot -proot'
|
||||
echo "backup $FILENAME restored"
|
||||
exit 0
|
||||
else
|
||||
echo "Error while opening $FILENAME"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
help() {
|
||||
cat <<EOF
|
||||
|
||||
Usage: $(basename $0) command
|
||||
|
||||
Commands:
|
||||
backup [filename]
|
||||
restore filename
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
main() {
|
||||
if [ -z "$COMMAND" ]; then
|
||||
help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$COMMAND" in
|
||||
"backup")
|
||||
backup
|
||||
;;
|
||||
"restore")
|
||||
restore
|
||||
;;
|
||||
*)
|
||||
help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
COMMAND=$1
|
||||
FILENAME=$2
|
||||
|
||||
main
|
Loading…
Reference in new issue