From d9c5e1438b1998009998c987a689be5928d60476 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 25 Mar 2024 15:27:53 +0100 Subject: [PATCH] done --- README.md | 12 ++++++++++-- script.sh | 21 +++++++++++++++++++++ script.sql | 2 +- 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 script.sh diff --git a/README.md b/README.md index e16b2a49b..cd7b26605 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ -# PHP_2023 +## Getting Started -https://otus.ru/lessons/razrabotchik-php/?utm_source=github&utm_medium=free&utm_campaign=otus +To launch the project, simply run the following command in your terminal: + +```bash +sh script.sh +``` + +This command will set up the environment, including the necessary containers, and execute any initial setup scripts. Once the setup is complete, the project will be accessible through the hostname `application.local`. + +Ensure your system's hosts file is configured to redirect `application.local` to the appropriate IP address, typically `127.0.0.1` for local development environments. diff --git a/script.sh b/script.sh new file mode 100644 index 000000000..db684720d --- /dev/null +++ b/script.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ ! -f .env ]; then + echo "Creating .env from .env.example..." + cp .env.example .env +else + echo ".env already exists." +fi + +echo "Launching containers..." +docker-compose up -d +docker-compose logs -f & + +echo "Installing Composer Dependencies..." +docker exec -it $(docker ps -qf "name=myapp_php") sh -c "composer install" + +docker cp script.sql postgresql:/script.sql + +docker exec -it postgresql psql -U ${POSTGRES_USER} -d ${POSTGRES_DB} -f /script.sql + +echo -e "\033[0;32mThe project went up successfully!\033[0m" \ No newline at end of file diff --git a/script.sql b/script.sql index bd50632ee..640cb0422 100644 --- a/script.sql +++ b/script.sql @@ -36,7 +36,7 @@ user_id INT; end_date DATE := '2024-03-19'; curr_date DATE; BEGIN -FOR user_id IN 4..6 LOOP +FOR user_id IN 1..3 LOOP FOR i IN 1..100 LOOP curr_date := start_date + (RANDOM() * (end_date - start_date))::INTEGER; INSERT INTO Transactions (user_id, transaction_date, description, amount, transaction_type)