Skip to content

Commit

Permalink
Merge pull request #192 from fdhhhdjd/developer
Browse files Browse the repository at this point in the history
make file edit 20230312
  • Loading branch information
fdhhhdjd authored Mar 12, 2023
2 parents 50a2a1a + b940e9d commit a7fc185
Showing 1 changed file with 49 additions and 11 deletions.
60 changes: 49 additions & 11 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ SEND_EMAIL_FOLDER="server-send-email-student"
MEDIA_FOLDER="server-media-service"
BACKEND_FOLDER="backend-manager-student"

CONTAINER_STUDENT=server_user_api
CONTAINER_ADMIN=server_admin_api
CONTAINER_CRON=cron_job
CONTAINER_EMAIL=send_email_student
CONTAINER_MEDIA=upload-api
CONTAINER_POSGREQL=postgresql
CONTAINER_REDIS_MASTER=redis-master
CONTAINER_REDIS_SLAVE=redis-slave
CONTAINER_NGINX=nginx_libary_school


POSTGRES_VARS = PASSWORD=$$(grep -oP 'POSTGRES_PASSWORD=\K(.*)' ./${BACKEND_FOLDER}/.env); \
USER_NAME=$$(grep -oP 'POSTGRES_USER=\K(.*)' ./${BACKEND_FOLDER}/.env); \
Expand All @@ -31,44 +41,72 @@ install-dev:

# Go to volume root container
docker-root-student:
docker exec -it server_user_api sh
docker exec -it ${CONTAINER_STUDENT} sh

docker-root-admin:
docker exec -it server_admin_api sh
docker exec -it ${CONTAINER_ADMIN} sh

docker-root-email:
docker exec -it send_email_student sh
docker exec -it ${CONTAINER_EMAIL} sh

docker-root-media:
docker exec -it upload-api sh
docker exec -it ${CONTAINER_MEDIA} sh

docker-root-cron:
docker exec -it cron_job sh
docker exec -it ${CONTAINER_CRON} sh

docker-root-nginx:
docker exec -it nginx_libary_school bash
docker exec -it ${CONTAINER_NGINX} bash

docker-root-posgresql:
docker exec -it postgresql bash
docker exec -it ${CONTAINER_POSGREQL} bash

docker-root-redis-master:
docker exec -it redis-master bash
docker exec -it ${CONTAINER_REDIS_MASTER} bash

docker-root-redis-slave:
docker exec -it redis-slave bash
docker exec -it ${CONTAINER_REDIS_SLAVE} bash

# Go to logs container
docker-log-student:
docker logs -f ${CONTAINER_STUDENT} --tail 100

docker-log-admin:
docker logs -f ${CONTAINER_ADMIN} --tail 100

docker-log-email:
docker logs -f ${CONTAINER_EMAIL}--tail 100

docker-log-media:
docker logs -ft ${CONTAINER_MEDIA} --tail 100

docker-log-cron:
docker logs -f ${CONTAINER_CRON}--tail 100

docker-log-nginx:
docker logs -f ${CONTAINER_NGINX} --tail 100

docker-log-posgresql:
docker logs -f ${CONTAINER_POSGREQL} --tail 100

docker-log-redis-master:
docker logs -f ${CONTAINER_REDIS_MASTER} --tail 100

docker-log-redis-slave:
docker logs -f ${CONTAINER_REDIS_SLAVE} --tail 100

# Export DB
docker-export-db-posgresql:
$(POSTGRES_VARS) \
docker exec -it postgresql bash -c "\
docker exec -it ${CONTAINER_POSGREQL} bash -c "\
cd docker-entrypoint-initdb.d && \
rm -rf libary_school_main.sql && \
PGPASSWORD=$${PASSWORD} pg_dump -U $${USER_NAME} --format=p --file=libary_school_main.sql --dbname=$${POSTGRES_DB} --no-owner --no-privileges -w"

# import DB
docker-import-db-posgresql:
$(POSTGRES_VARS) \
docker exec -it postgresql bash -c "\
docker exec -it ${CONTAINER_POSGREQL} bash -c "\
cd docker-entrypoint-initdb.d && \
PGPASSWORD=$${PASSWORD} psql -h $${POSTGRES_HOST} -U $${USER_NAME} -d $${POSTGRES_DB} -a -f libary_school_main.sql;"

Expand Down

0 comments on commit a7fc185

Please sign in to comment.