2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-09-19 18:49:01 +00:00

chore(lint): Run shfmt

This commit is contained in:
Lev Vereshchagin 2021-12-10 11:56:18 +03:00
parent be7c6254f8
commit 0b861de117
5 changed files with 201 additions and 201 deletions

View File

@ -4,9 +4,9 @@ set -e
set -x set -x
get_tag() { get_tag() {
tags=$(git ls-remote --refs --tags --sort='v:refname' "https://github.com/$1" "v$2.*") tags=$(git ls-remote --refs --tags --sort='v:refname' "https://github.com/$1" "v$2.*")
tag=$(echo "$tags" | tail -n1 | sed 's/.*\///') tag=$(echo "$tags" | tail -n1 | sed 's/.*\///')
echo "$tag" echo "$tag"
} }
FRAPPE_VERSION=$(get_tag frappe/frappe "$VERSION") FRAPPE_VERSION=$(get_tag frappe/frappe "$VERSION")

View File

@ -1,26 +1,26 @@
#!/bin/bash #!/bin/bash
print_group() { print_group() {
echo ::endgroup:: echo ::endgroup::
echo "::group::$*" echo "::group::$*"
} }
ping_site() { ping_site() {
print_group "Ping site $SITE_NAME" print_group "Ping site $SITE_NAME"
echo Ping version echo Ping version
ping_res=$(curl -sS "http://$SITE_NAME/api/method/version") ping_res=$(curl -sS "http://$SITE_NAME/api/method/version")
echo "$ping_res" echo "$ping_res"
if [[ -z $(echo "$ping_res" | grep "message" || echo "") ]]; then if [[ -z $(echo "$ping_res" | grep "message" || echo "") ]]; then
echo "Ping failed" echo "Ping failed"
exit 1 exit 1
fi fi
echo Check index echo Check index
index_res=$(curl -sS "http://$SITE_NAME") index_res=$(curl -sS "http://$SITE_NAME")
if [[ -n $(echo "$index_res" | grep "Internal Server Error" || echo "") ]]; then if [[ -n $(echo "$index_res" | grep "Internal Server Error" || echo "") ]]; then
echo "Index check failed" echo "Index check failed"
echo "$index_res" echo "$index_res"
exit 1 exit 1
fi fi
} }

View File

@ -7,63 +7,63 @@ source tests/functions.sh
project_name=frappe_bench_00 project_name=frappe_bench_00
docker_compose_with_args() { docker_compose_with_args() {
# shellcheck disable=SC2068 # shellcheck disable=SC2068
docker-compose \ docker-compose \
-p $project_name \ -p $project_name \
-f installation/docker-compose-common.yml \ -f installation/docker-compose-common.yml \
-f installation/docker-compose-frappe.yml \ -f installation/docker-compose-frappe.yml \
-f installation/frappe-publish.yml \ -f installation/frappe-publish.yml \
$@ $@
} }
check_migration_complete() { check_migration_complete() {
print_group Check migration print_group Check migration
container_id=$(docker_compose_with_args ps -q frappe-python) container_id=$(docker_compose_with_args ps -q frappe-python)
cmd="docker logs ${container_id} 2>&1 | grep 'Starting gunicorn' || echo ''" cmd="docker logs ${container_id} 2>&1 | grep 'Starting gunicorn' || echo ''"
worker_log=$(eval "$cmd")
INCREMENT=0
while [[ ${worker_log} != *"Starting gunicorn"* && ${INCREMENT} -lt 120 ]]; do
sleep 3
((INCREMENT = INCREMENT + 1))
echo "Wait for migration to complete..."
worker_log=$(eval "$cmd") worker_log=$(eval "$cmd")
INCREMENT=0 if [[ ${worker_log} != *"Starting gunicorn"* && ${INCREMENT} -eq 120 ]]; then
echo Migration timeout
docker logs "${container_id}"
exit 1
fi
done
while [[ ${worker_log} != *"Starting gunicorn"* && ${INCREMENT} -lt 120 ]]; do echo Migration Log
sleep 3 docker logs "${container_id}"
((INCREMENT = INCREMENT + 1))
echo "Wait for migration to complete..."
worker_log=$(eval "$cmd")
if [[ ${worker_log} != *"Starting gunicorn"* && ${INCREMENT} -eq 120 ]]; then
echo Migration timeout
docker logs "${container_id}"
exit 1
fi
done
echo Migration Log
docker logs "${container_id}"
} }
check_health() { check_health() {
print_group Loop health check print_group Loop health check
docker run --name frappe_doctor \ docker run --name frappe_doctor \
-v "${project_name}_sites-vol:/home/frappe/frappe-bench/sites" \ -v "${project_name}_sites-vol:/home/frappe/frappe-bench/sites" \
--network "${project_name}_default" \ --network "${project_name}_default" \
frappe/frappe-worker:edge doctor || true frappe/frappe-worker:edge doctor || true
cmd='docker logs frappe_doctor | grep "Health check successful" || echo ""' cmd='docker logs frappe_doctor | grep "Health check successful" || echo ""'
doctor_log=$(eval "$cmd")
INCREMENT=0
while [[ -z "${doctor_log}" && ${INCREMENT} -lt 60 ]]; do
sleep 1
((INCREMENT = INCREMENT + 1))
container=$(docker start frappe_doctor)
echo "Restarting ${container}..."
doctor_log=$(eval "$cmd") doctor_log=$(eval "$cmd")
INCREMENT=0
while [[ -z "${doctor_log}" && ${INCREMENT} -lt 60 ]]; do if [[ ${INCREMENT} -eq 60 ]]; then
sleep 1 docker logs "${container}"
((INCREMENT = INCREMENT + 1)) exit 1
container=$(docker start frappe_doctor) fi
echo "Restarting ${container}..." done
doctor_log=$(eval "$cmd")
if [[ ${INCREMENT} -eq 60 ]]; then
docker logs "${container}"
exit 1
fi
done
} }
# Initial group # Initial group
@ -81,23 +81,23 @@ docker_compose_with_args up -d --quiet-pull
echo Start postgres echo Start postgres
docker pull postgres:11.8 -q docker pull postgres:11.8 -q
docker run \ docker run \
--name postgresql \ --name postgresql \
-d \ -d \
-e POSTGRES_PASSWORD=admin \ -e POSTGRES_PASSWORD=admin \
-v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \ -v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \
--network ${project_name}_default \ --network ${project_name}_default \
postgres:11.8 postgres:11.8
check_health check_health
print_group "Create new site " print_group "Create new site "
SITE_NAME=test.localhost SITE_NAME=test.localhost
docker run \ docker run \
--rm \ --rm \
-e SITE_NAME=$SITE_NAME \ -e SITE_NAME=$SITE_NAME \
-v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \ -v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \
--network ${project_name}_default \ --network ${project_name}_default \
frappe/frappe-worker:v13 new frappe/frappe-worker:v13 new
ping_site ping_site
@ -118,25 +118,25 @@ ping_site
PG_SITE_NAME=pgsql.localhost PG_SITE_NAME=pgsql.localhost
print_group "Create new site (Postgres)" print_group "Create new site (Postgres)"
docker run \ docker run \
--rm \ --rm \
-e SITE_NAME=$PG_SITE_NAME \ -e SITE_NAME=$PG_SITE_NAME \
-e POSTGRES_HOST=postgresql \ -e POSTGRES_HOST=postgresql \
-e DB_ROOT_USER=postgres \ -e DB_ROOT_USER=postgres \
-e POSTGRES_PASSWORD=admin \ -e POSTGRES_PASSWORD=admin \
-v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \ -v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \
--network ${project_name}_default \ --network ${project_name}_default \
frappe/frappe-worker:edge new frappe/frappe-worker:edge new
check_migration_complete check_migration_complete
SITE_NAME=$PG_SITE_NAME ping_site SITE_NAME=$PG_SITE_NAME ping_site
print_group Backup site print_group Backup site
docker run \ docker run \
--rm \ --rm \
-e WITH_FILES=1 \ -e WITH_FILES=1 \
-v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \ -v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \
--network ${project_name}_default \ --network ${project_name}_default \
frappe/frappe-worker:edge backup frappe/frappe-worker:edge backup
MINIO_ACCESS_KEY="AKIAIOSFODNN7EXAMPLE" MINIO_ACCESS_KEY="AKIAIOSFODNN7EXAMPLE"
MINIO_SECRET_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" MINIO_SECRET_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
@ -144,39 +144,39 @@ MINIO_SECRET_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
print_group Prepare S3 server print_group Prepare S3 server
echo Start S3 server echo Start S3 server
docker run \ docker run \
--name minio \ --name minio \
-d \ -d \
-e "MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY" \ -e "MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY" \
-e "MINIO_SECRET_KEY=$MINIO_SECRET_KEY" \ -e "MINIO_SECRET_KEY=$MINIO_SECRET_KEY" \
--network ${project_name}_default \ --network ${project_name}_default \
minio/minio server /data minio/minio server /data
echo Create bucket echo Create bucket
docker run \ docker run \
--rm \ --rm \
--network ${project_name}_default \ --network ${project_name}_default \
vltgroup/s3cmd:latest \ vltgroup/s3cmd:latest \
s3cmd \ s3cmd \
--access_key=$MINIO_ACCESS_KEY \ --access_key=$MINIO_ACCESS_KEY \
--secret_key=$MINIO_SECRET_KEY \ --secret_key=$MINIO_SECRET_KEY \
--region=us-east-1 \ --region=us-east-1 \
--no-ssl \ --no-ssl \
--host=minio:9000 \ --host=minio:9000 \
--host-bucket=minio:9000 \ --host-bucket=minio:9000 \
mb s3://frappe mb s3://frappe
print_group Push backup print_group Push backup
docker run \ docker run \
--rm \ --rm \
-e BUCKET_NAME=frappe \ -e BUCKET_NAME=frappe \
-e REGION=us-east-1 \ -e REGION=us-east-1 \
-e BUCKET_DIR=local \ -e BUCKET_DIR=local \
-e ACCESS_KEY_ID=$MINIO_ACCESS_KEY \ -e ACCESS_KEY_ID=$MINIO_ACCESS_KEY \
-e SECRET_ACCESS_KEY=$MINIO_SECRET_KEY \ -e SECRET_ACCESS_KEY=$MINIO_SECRET_KEY \
-e ENDPOINT_URL=http://minio:9000 \ -e ENDPOINT_URL=http://minio:9000 \
-v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \ -v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \
--network ${project_name}_default \ --network ${project_name}_default \
frappe/frappe-worker:edge push-backup frappe/frappe-worker:edge push-backup
print_group Prune and restart services print_group Prune and restart services
docker_compose_with_args stop docker_compose_with_args stop
@ -187,17 +187,17 @@ check_health
print_group Restore backup from S3 print_group Restore backup from S3
docker run \ docker run \
--rm \ --rm \
-e MYSQL_ROOT_PASSWORD=admin \ -e MYSQL_ROOT_PASSWORD=admin \
-e BUCKET_NAME=frappe \ -e BUCKET_NAME=frappe \
-e BUCKET_DIR=local \ -e BUCKET_DIR=local \
-e ACCESS_KEY_ID=$MINIO_ACCESS_KEY \ -e ACCESS_KEY_ID=$MINIO_ACCESS_KEY \
-e SECRET_ACCESS_KEY=$MINIO_SECRET_KEY \ -e SECRET_ACCESS_KEY=$MINIO_SECRET_KEY \
-e ENDPOINT_URL=http://minio:9000 \ -e ENDPOINT_URL=http://minio:9000 \
-e REGION=us-east-1 \ -e REGION=us-east-1 \
-v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \ -v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \
--network ${project_name}_default \ --network ${project_name}_default \
frappe/frappe-worker:edge restore-backup frappe/frappe-worker:edge restore-backup
check_health check_health
ping_site ping_site
@ -206,78 +206,78 @@ SITE_NAME=$PG_SITE_NAME ping_site
EDGE_SITE_NAME=edge.localhost EDGE_SITE_NAME=edge.localhost
print_group "Create new site (edge)" print_group "Create new site (edge)"
docker run \ docker run \
--rm \ --rm \
-e SITE_NAME=$EDGE_SITE_NAME \ -e SITE_NAME=$EDGE_SITE_NAME \
-e INSTALL_APPS=frappe \ -e INSTALL_APPS=frappe \
-v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \ -v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \
--network ${project_name}_default \ --network ${project_name}_default \
frappe/frappe-worker:edge new frappe/frappe-worker:edge new
check_health check_health
SITE_NAME=$EDGE_SITE_NAME ping_site SITE_NAME=$EDGE_SITE_NAME ping_site
print_group Migrate edge site print_group Migrate edge site
docker run \ docker run \
--rm \ --rm \
-e MAINTENANCE_MODE=1 \ -e MAINTENANCE_MODE=1 \
-v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \ -v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \
-v ${project_name}_assets-vol:/home/frappe/frappe-bench/sites/assets \ -v ${project_name}_assets-vol:/home/frappe/frappe-bench/sites/assets \
--network ${project_name}_default \ --network ${project_name}_default \
frappe/frappe-worker:edge migrate frappe/frappe-worker:edge migrate
check_migration_complete check_migration_complete
print_group "Restore backup S3 (overwrite)" print_group "Restore backup S3 (overwrite)"
docker run \ docker run \
--rm \ --rm \
-e MYSQL_ROOT_PASSWORD=admin \ -e MYSQL_ROOT_PASSWORD=admin \
-e BUCKET_NAME=frappe \ -e BUCKET_NAME=frappe \
-e BUCKET_DIR=local \ -e BUCKET_DIR=local \
-e ACCESS_KEY_ID=$MINIO_ACCESS_KEY \ -e ACCESS_KEY_ID=$MINIO_ACCESS_KEY \
-e SECRET_ACCESS_KEY=$MINIO_SECRET_KEY \ -e SECRET_ACCESS_KEY=$MINIO_SECRET_KEY \
-e ENDPOINT_URL=http://minio:9000 \ -e ENDPOINT_URL=http://minio:9000 \
-e REGION=us-east-1 \ -e REGION=us-east-1 \
-v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \ -v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \
--network ${project_name}_default \ --network ${project_name}_default \
frappe/frappe-worker:edge restore-backup frappe/frappe-worker:edge restore-backup
check_migration_complete check_migration_complete
ping_site ping_site
print_group "Check console for $SITE_NAME" print_group "Check console for $SITE_NAME"
docker run \ docker run \
--rm \ --rm \
-v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \ -v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \
--network ${project_name}_default \ --network ${project_name}_default \
frappe/frappe-worker:edge console $SITE_NAME frappe/frappe-worker:edge console $SITE_NAME
print_group "Check console for $PG_SITE_NAME" print_group "Check console for $PG_SITE_NAME"
docker run \ docker run \
--rm \ --rm \
-v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \ -v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \
--network ${project_name}_default \ --network ${project_name}_default \
frappe/frappe-worker:edge console $PG_SITE_NAME frappe/frappe-worker:edge console $PG_SITE_NAME
print_group "Check drop site for $SITE_NAME (MariaDB)" print_group "Check drop site for $SITE_NAME (MariaDB)"
docker run \ docker run \
--rm \ --rm \
-e SITE_NAME=$SITE_NAME \ -e SITE_NAME=$SITE_NAME \
-v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \ -v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \
--network ${project_name}_default \ --network ${project_name}_default \
frappe/frappe-worker:edge drop frappe/frappe-worker:edge drop
print_group "Check drop site for $PG_SITE_NAME (Postgres)" print_group "Check drop site for $PG_SITE_NAME (Postgres)"
docker run \ docker run \
--rm \ --rm \
-e SITE_NAME=$PG_SITE_NAME \ -e SITE_NAME=$PG_SITE_NAME \
-v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \ -v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \
--network ${project_name}_default \ --network ${project_name}_default \
frappe/frappe-worker:edge drop frappe/frappe-worker:edge drop
print_group Check bench --help print_group Check bench --help
docker run \ docker run \
--rm \ --rm \
-v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \ -v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \
--network ${project_name}_default \ --network ${project_name}_default \
--user frappe \ --user frappe \
frappe/frappe-worker:edge bench --help frappe/frappe-worker:edge bench --help

View File

@ -16,29 +16,29 @@ cat .env
print_group Start services print_group Start services
docker-compose \ docker-compose \
-p $project_name \ -p $project_name \
-f installation/docker-compose-common.yml \ -f installation/docker-compose-common.yml \
-f installation/docker-compose-erpnext.yml \ -f installation/docker-compose-erpnext.yml \
-f installation/erpnext-publish.yml \ -f installation/erpnext-publish.yml \
up -d up -d
print_group Fix permissions print_group Fix permissions
docker run \ docker run \
--rm \ --rm \
--user root \ --user root \
-v ${project_name}_sites-vol:/sites \ -v ${project_name}_sites-vol:/sites \
-v ${project_name}_assets-vol:/assets \ -v ${project_name}_assets-vol:/assets \
-v ${project_name}_logs-vol:/logs \ -v ${project_name}_logs-vol:/logs \
frappe/erpnext-worker:test chown -R 1000:1000 /logs /sites /assets frappe/erpnext-worker:test chown -R 1000:1000 /logs /sites /assets
print_group Create site print_group Create site
docker run \ docker run \
--rm \ --rm \
-e "SITE_NAME=$SITE_NAME" \ -e "SITE_NAME=$SITE_NAME" \
-e "INSTALL_APPS=erpnext" \ -e "INSTALL_APPS=erpnext" \
-v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \ -v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \
--network ${project_name}_default \ --network ${project_name}_default \
frappe/erpnext-worker:test new frappe/erpnext-worker:test new
ping_site ping_site
rm .env rm .env

View File

@ -8,13 +8,13 @@ project_name="test_frappe"
SITE_NAME="test_frappe.localhost" SITE_NAME="test_frappe.localhost"
docker_compose_with_args() { docker_compose_with_args() {
# shellcheck disable=SC2068 # shellcheck disable=SC2068
docker-compose \ docker-compose \
-p $project_name \ -p $project_name \
-f installation/docker-compose-common.yml \ -f installation/docker-compose-common.yml \
-f installation/docker-compose-frappe.yml \ -f installation/docker-compose-frappe.yml \
-f installation/frappe-publish.yml \ -f installation/frappe-publish.yml \
$@ $@
} }
echo ::group::Setup env echo ::group::Setup env
@ -29,11 +29,11 @@ docker_compose_with_args up -d
print_group Create site print_group Create site
docker run \ docker run \
--rm \ --rm \
-e "SITE_NAME=$SITE_NAME" \ -e "SITE_NAME=$SITE_NAME" \
-v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \ -v ${project_name}_sites-vol:/home/frappe/frappe-bench/sites \
--network ${project_name}_default \ --network ${project_name}_default \
frappe/frappe-worker:test new frappe/frappe-worker:test new
ping_site ping_site