From ee1ad57c7f9fd3672d3385899fbb2626cd4c5fb1 Mon Sep 17 00:00:00 2001 From: Pipo Bimbo Date: Fri, 25 Nov 2022 12:07:00 +0100 Subject: [PATCH 01/10] add docker build and seed scripts for windows --- docker/build-log.bat | 9 +++++++++ docker/build.bat | 9 +++++++++ docker/seed.bat | 25 +++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 docker/build-log.bat create mode 100644 docker/build.bat create mode 100644 docker/seed.bat diff --git a/docker/build-log.bat b/docker/build-log.bat new file mode 100644 index 0000000000..2a8b01bd8d --- /dev/null +++ b/docker/build-log.bat @@ -0,0 +1,9 @@ +START /B /WAIT docker-compose down -v --remove-orphans +echo '###########################' +echo 'BEGIN: docker-compose build' +echo 'Set up the Docker containers' +echo '###########################' +docker-compose build +echo '##############################' +echo 'FINISHED: docker-compose build' +echo '##############################' \ No newline at end of file diff --git a/docker/build.bat b/docker/build.bat new file mode 100644 index 0000000000..4e71b807c4 --- /dev/null +++ b/docker/build.bat @@ -0,0 +1,9 @@ +rem This script builds the Docker container, seeds the app with sample data, and logs the screen output. + +REM get DateTime var in a "YYYYMMDD-HHmmSS" format +FOR /f %%a IN ('WMIC OS GET LocalDateTime ^| FIND "."') DO SET DTS=%%a +SET DateTime=%DTS:~0,8%-%DTS:~8,6% + +REM Launches docker build and database seed +docker/build-log.bat > log/build-%DateTime%.log 2>&1 +docker/seed.bat > log/seed-%DateTime%.log 2>&1 diff --git a/docker/seed.bat b/docker/seed.bat new file mode 100644 index 0000000000..4519867ee4 --- /dev/null +++ b/docker/seed.bat @@ -0,0 +1,25 @@ +rem This is the data seeding script. + +echo '-------------------------------------------------------' +echo 'BEGIN: docker-compose run web bundle exec rake db:reset' +echo '-------------------------------------------------------' +docker-compose run web bundle exec rake db:reset +echo '-----------------------------------------------------' +echo 'END: docker-compose run web bundle exec rake db:reset' +echo '-----------------------------------------------------' + +echo '--------------------------------------------------------------' +echo 'BEGIN: docker-compose run web bundle exec rake db:test:prepare' +echo '--------------------------------------------------------------' +docker-compose run web bundle exec rake db:test:prepare +echo '------------------------------------------------------------' +echo 'END: docker-compose run web bundle exec rake db:test:prepare' +echo '------------------------------------------------------------' + +echo '--------------------------------------------------------------' +echo 'BEGIN: docker-compose run web bundle exec rake ofn:sample_data' +echo '--------------------------------------------------------------' +docker-compose run web bundle exec rake ofn:sample_data +echo '------------------------------------------------------------' +echo 'END: docker-compose run web bundle exec rake ofn:sample_data' +echo '------------------------------------------------------------' From 38fe572943d9ad70072a6b083c5d35863f76ba66 Mon Sep 17 00:00:00 2001 From: Pipo Bimbo Date: Fri, 25 Nov 2022 13:55:07 +0100 Subject: [PATCH 02/10] Avoid spaces and line return around ruby version, especially for windows --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1bfc0535b4..c25f6705b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,7 +35,10 @@ ENV BUNDLE_PATH /bundles ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so WORKDIR /usr/src/app -COPY .ruby-version . + +# trim spaces and line return from .ruby-version file +COPY .ruby-version .ruby-version.raw +RUN cat .ruby-version.raw | tr -d '\r\t ' > .ruby-version # Install Rbenv & Ruby RUN git clone --depth 1 https://github.com/rbenv/rbenv.git ${RBENV_ROOT} && \ From d153adca9bebdf11b48ae675d6a351db153553f6 Mon Sep 17 00:00:00 2001 From: Pipo Bimbo Date: Fri, 25 Nov 2022 16:57:51 +0100 Subject: [PATCH 03/10] docker server.bat files for use of docker on windows environment + documentation --- docker/README.md | 34 ++++++++++++++++++++++++++++++++-- docker/server-log.bat | 6 ++++++ docker/server.bat | 7 +++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 docker/server-log.bat create mode 100644 docker/server.bat diff --git a/docker/README.md b/docker/README.md index 4fac4fc22b..a101b4ffb1 100644 --- a/docker/README.md +++ b/docker/README.md @@ -25,6 +25,7 @@ $ sudo apt install docker-compose * You may have to deselect the option to use Docker Compose V2 in Docker settings to make our scripts work. ## Getting Started +### Linux * Open a terminal with a shell. * Clone the repository. If you're planning on contributing code to the project (which we [LOVE](CONTRIBUTING.md)), begin by forking this repo with the Fork button in the top-right corner of this screen. * Use git clone to copy your fork onto your local machine. @@ -52,6 +53,35 @@ $ docker/server * You will then get the trace of the containers in the terminal. You can stop the containers using Ctrl-C in the terminal. * You can find some useful tips and commands [here](https://github.com/openfoodfoundation/openfoodnetwork/wiki/Docker:-useful-tips-and-commands). +### Windows and Mac (untested) +* Open a terminal with a shell command. +* Clone the repository. If you're planning on contributing code to the project (which we [LOVE](CONTRIBUTING.md)), begin by forking this repo with the Fork button in the top-right corner of this screen. +* Use git clone to copy your fork onto your local machine. +```command +$ git clone https://github.com/YOUR_GITHUB_USERNAME_HERE/openfoodnetwork +``` +* Otherwise, if you just want to get things running, clone from the OFN main repo: +```command +$ git clone git@github.com:openfoodfoundation/openfoodnetwork.git +``` +* Go at the root of the app: +```command +$ cd openfoodnetwork +``` +* Download the Docker images, build the Docker containers, seed the database with sample data, AND log the screen output from these tasks: +```command +$ docker/build.bat +``` +* Run the Rails server and its required Docker containers: +```command +$ docker/server.bat +``` +* The default admin user is 'ofn@example.com' with the password 'ofn123'. +* View the app in the browser at `http://localhost:3000`. +* You will then get the trace of the containers in the terminal. You can stop the containers using Ctrl-C in the terminal. +* You can find some useful tips and commands [here](https://github.com/openfoodfoundation/openfoodnetwork/wiki/Docker:-useful-tips-and-commands). + + ### Troubleshooting * If you are using Windows and having issues related to the ruby-build not finding a definition for the ruby version, you may need to follow these commands [here](https://stackoverflow.com/questions/2517190/how-do-i-force-git-to-use-lf-instead-of-crlf-under-windows/33424884#33424884) to fix your local git config related to line breaks. * If you’re getting the following error: @@ -93,8 +123,8 @@ To fix this error on server startup, you need to bump `mini-racer` gem from `0.4 Based on [spree/spree_starter #984](https://github.com/spree/spree_starter/issues/984) ## Script Summary -* docker/build: This script builds the Docker containers specified for this app, seeds the database, and logs the screen output for these operations. After you use "git clone" to download this repository, run the docker/build script to start the setup process. -* docker/server: Use this script to run this app in the Rails server. This script executes the "docker-compose up" command and logs the results. If all goes well, you will be able to view this app on your local browser at http://localhost:3000/. +* docker/build(.bat): This script builds the Docker containers specified for this app, seeds the database, and logs the screen output for these operations. After you use "git clone" to download this repository, run the docker/build script to start the setup process. +* docker/server(.bat): Use this script to run this app in the Rails server. This script executes the "docker-compose up" command and logs the results. If all goes well, you will be able to view this app on your local browser at http://localhost:3000/. * docker/test: Use this script to run the entire test suite. * docker/qtest: Use this script to run the entire test suite in quiet mode. The deprecation warnings are removed to make the test results easier to read. * docker/run: Use this script to run commands within the Docker container. If you want shell access, enter "docker/run bash". To execute "ls -l" within the Docker container, enter "docker/run ls -l". diff --git a/docker/server-log.bat b/docker/server-log.bat new file mode 100644 index 0000000000..c571539725 --- /dev/null +++ b/docker/server-log.bat @@ -0,0 +1,6 @@ +echo '########################' +echo 'BEGIN: docker-compose up' +echo '########################' +echo 'View this app in your web browser at' +echo 'http://localhost:3000/' +docker-compose up \ No newline at end of file diff --git a/docker/server.bat b/docker/server.bat new file mode 100644 index 0000000000..4a15884581 --- /dev/null +++ b/docker/server.bat @@ -0,0 +1,7 @@ +rem This script runs the Rails server and logs the screen output. + +REM get DateTime var in a "YYYYMMDD-HHmmSS" format +FOR /f %%a IN ('WMIC OS GET LocalDateTime ^| FIND "."') DO SET DTS=%%a +SET DateTime=%DTS:~0,8%-%DTS:~8,6% + +docker/server-log.bat > log/server-%DateTime%.log 2>&1 \ No newline at end of file From d413a39c3c75d7dfab36f039d01a7e78795f42a2 Mon Sep 17 00:00:00 2001 From: Pipo Bimbo Date: Fri, 25 Nov 2022 16:40:54 +0100 Subject: [PATCH 04/10] grep option -x does not work on windows installation due to EOL characters --- script/install-bundler | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/install-bundler b/script/install-bundler index f018f7c734..1fb3e7d945 100755 --- a/script/install-bundler +++ b/script/install-bundler @@ -16,10 +16,10 @@ set -e # `grep`: find the occurrences of "BUNDLED WITH" (-m is unnecessary and behaves different on macOS) # `-A`: print the next line after "BUNDLED WITH" as well -# `-x -F`: find exactly that string without interpreting regex +# `-F`: find exactly that string # `tail -n 1`: take the last line, the version line # `tr -d`: delete all spaces, the indent before the version -version="$(grep -A 1 -x -F "BUNDLED WITH" Gemfile.lock | tail -n 1 | tr -d '[:space:]')" +version="$(grep -A 1 -F "BUNDLED WITH" Gemfile.lock | tail -n 1 | tr -d '[:space:]')" # if the length of $version is zero if [ -z "$version" ]; then From e1b79db65e3274fe3d2c6119635c5ce102226c5b Mon Sep 17 00:00:00 2001 From: Pipo Bimbo Date: Mon, 28 Nov 2022 14:35:10 +0100 Subject: [PATCH 05/10] Set line endings to LF, even on Windows, for Shell scripts. Otherwise, execution within Docker fails. --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..0907b04cb6 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Set line endings to LF, even on Windows. Otherwise, execution within Docker fails. +# See https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings#per-repository-settings +*.sh text eol=lf \ No newline at end of file From 4bae28bbad4a0c4a4ea12173eb1b8f1472f23c67 Mon Sep 17 00:00:00 2001 From: Pipo Bimbo Date: Mon, 28 Nov 2022 17:24:34 +0100 Subject: [PATCH 06/10] removed node_modules folder mounting on docker because it is not possible to have node_modules files on Windows host used by yarn/npm process on docker container --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index fe7cd13957..d1a556d040 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,4 @@ .gitignore log/* tmp/* +node_modules/ From fa4ff7534bf7f280d3c8df107473102a89a43a2b Mon Sep 17 00:00:00 2001 From: Pipo Bimbo Date: Mon, 28 Nov 2022 17:25:37 +0100 Subject: [PATCH 07/10] for windows and docker usage compatibilities, force certain files to use LF line endings, even on Windows --- .gitattributes | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 0907b04cb6..dc15ed793c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,11 @@ +# Set default behavior to automatically normalize line endings. +* text=auto + # Set line endings to LF, even on Windows. Otherwise, execution within Docker fails. # See https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings#per-repository-settings -*.sh text eol=lf \ No newline at end of file +*.sh text eol=lf + +# Same thing for following files, but they don't have an sh extension +pre-commit eol=lf +webpack-dev-server eol=lf +install-bundler eol=lf \ No newline at end of file From 5708fb04a54c9b1eac95c3ac0e186962d542725c Mon Sep 17 00:00:00 2001 From: Pipo Bimbo Date: Mon, 16 Jan 2023 18:31:05 +0100 Subject: [PATCH 08/10] switch from command scripts to powershell scripts --- docker/build-log.bat | 9 --------- docker/build-log.ps1 | 5 +++++ docker/build.bat | 9 --------- docker/build.ps1 | 8 ++++++++ docker/cop.ps1 | 4 ++++ docker/seed.bat | 25 ------------------------- docker/seed.ps1 | 13 +++++++++++++ docker/server-log.bat | 6 ------ docker/server.bat | 7 ------- docker/server.ps1 | 6 ++++++ docker/test.ps1 | 9 +++++++++ 11 files changed, 45 insertions(+), 56 deletions(-) delete mode 100644 docker/build-log.bat create mode 100644 docker/build-log.ps1 delete mode 100644 docker/build.bat create mode 100644 docker/build.ps1 create mode 100644 docker/cop.ps1 delete mode 100644 docker/seed.bat create mode 100644 docker/seed.ps1 delete mode 100644 docker/server-log.bat delete mode 100644 docker/server.bat create mode 100644 docker/server.ps1 create mode 100644 docker/test.ps1 diff --git a/docker/build-log.bat b/docker/build-log.bat deleted file mode 100644 index 2a8b01bd8d..0000000000 --- a/docker/build-log.bat +++ /dev/null @@ -1,9 +0,0 @@ -START /B /WAIT docker-compose down -v --remove-orphans -echo '###########################' -echo 'BEGIN: docker-compose build' -echo 'Set up the Docker containers' -echo '###########################' -docker-compose build -echo '##############################' -echo 'FINISHED: docker-compose build' -echo '##############################' \ No newline at end of file diff --git a/docker/build-log.ps1 b/docker/build-log.ps1 new file mode 100644 index 0000000000..d3eed93e3a --- /dev/null +++ b/docker/build-log.ps1 @@ -0,0 +1,5 @@ +Write-Host "Docker cleaning: remove old containers" -ForegroundColor Blue +docker-compose.exe down -v --remove-orphans +Write-Host "Docker build: set up the docker containers" -ForegroundColor Blue +docker-compose.exe build +Write-Host "Docker build finished" \ No newline at end of file diff --git a/docker/build.bat b/docker/build.bat deleted file mode 100644 index 4e71b807c4..0000000000 --- a/docker/build.bat +++ /dev/null @@ -1,9 +0,0 @@ -rem This script builds the Docker container, seeds the app with sample data, and logs the screen output. - -REM get DateTime var in a "YYYYMMDD-HHmmSS" format -FOR /f %%a IN ('WMIC OS GET LocalDateTime ^| FIND "."') DO SET DTS=%%a -SET DateTime=%DTS:~0,8%-%DTS:~8,6% - -REM Launches docker build and database seed -docker/build-log.bat > log/build-%DateTime%.log 2>&1 -docker/seed.bat > log/seed-%DateTime%.log 2>&1 diff --git a/docker/build.ps1 b/docker/build.ps1 new file mode 100644 index 0000000000..3032d86b32 --- /dev/null +++ b/docker/build.ps1 @@ -0,0 +1,8 @@ +# This script does : +# - build the Docker container and log the output of several containers in a unique "build-yyyyMMdd-HHmmss.log" file +# - seed the app with sample data and log the output in "seed-yyyyMMdd-HHmmss.log" file + +$DateTime=Get-Date -Format "yyyyMMdd-HHmmss" + +docker/build-log.ps1 > log/build-$DateTime.log 2>&1 +docker/seed.ps1 > log/seed-$DateTime.log 2>&1 diff --git a/docker/cop.ps1 b/docker/cop.ps1 new file mode 100644 index 0000000000..497db04d33 --- /dev/null +++ b/docker/cop.ps1 @@ -0,0 +1,4 @@ +# This script runs RuboCop + +Write-Host "bundle exec rubocop : runs rubocop" -ForegroundColor Blue +docker-compose.exe run web bundle exec rubocop \ No newline at end of file diff --git a/docker/seed.bat b/docker/seed.bat deleted file mode 100644 index 4519867ee4..0000000000 --- a/docker/seed.bat +++ /dev/null @@ -1,25 +0,0 @@ -rem This is the data seeding script. - -echo '-------------------------------------------------------' -echo 'BEGIN: docker-compose run web bundle exec rake db:reset' -echo '-------------------------------------------------------' -docker-compose run web bundle exec rake db:reset -echo '-----------------------------------------------------' -echo 'END: docker-compose run web bundle exec rake db:reset' -echo '-----------------------------------------------------' - -echo '--------------------------------------------------------------' -echo 'BEGIN: docker-compose run web bundle exec rake db:test:prepare' -echo '--------------------------------------------------------------' -docker-compose run web bundle exec rake db:test:prepare -echo '------------------------------------------------------------' -echo 'END: docker-compose run web bundle exec rake db:test:prepare' -echo '------------------------------------------------------------' - -echo '--------------------------------------------------------------' -echo 'BEGIN: docker-compose run web bundle exec rake ofn:sample_data' -echo '--------------------------------------------------------------' -docker-compose run web bundle exec rake ofn:sample_data -echo '------------------------------------------------------------' -echo 'END: docker-compose run web bundle exec rake ofn:sample_data' -echo '------------------------------------------------------------' diff --git a/docker/seed.ps1 b/docker/seed.ps1 new file mode 100644 index 0000000000..edd67aaa63 --- /dev/null +++ b/docker/seed.ps1 @@ -0,0 +1,13 @@ +# This is the data seeding script : +# - reset the database +# - prepare the database +# - seed the database with sample data + +Write-Host "bundle exec rake db:reset : reset the dev and test databases" -ForegroundColor Blue +docker-compose.exe run web bundle exec rake db:reset + +Write-Host "bundle exec rake db:test:prepare : prepare the database" -ForegroundColor Blue +docker-compose.exe run web bundle exec rake db:test:prepare + +Write-Host "bundle exec rake ofn:sample_data : seed the database with sample data" -ForegroundColor Blue +docker-compose.exe run web bundle exec rake ofn:sample_data \ No newline at end of file diff --git a/docker/server-log.bat b/docker/server-log.bat deleted file mode 100644 index c571539725..0000000000 --- a/docker/server-log.bat +++ /dev/null @@ -1,6 +0,0 @@ -echo '########################' -echo 'BEGIN: docker-compose up' -echo '########################' -echo 'View this app in your web browser at' -echo 'http://localhost:3000/' -docker-compose up \ No newline at end of file diff --git a/docker/server.bat b/docker/server.bat deleted file mode 100644 index 4a15884581..0000000000 --- a/docker/server.bat +++ /dev/null @@ -1,7 +0,0 @@ -rem This script runs the Rails server and logs the screen output. - -REM get DateTime var in a "YYYYMMDD-HHmmSS" format -FOR /f %%a IN ('WMIC OS GET LocalDateTime ^| FIND "."') DO SET DTS=%%a -SET DateTime=%DTS:~0,8%-%DTS:~8,6% - -docker/server-log.bat > log/server-%DateTime%.log 2>&1 \ No newline at end of file diff --git a/docker/server.ps1 b/docker/server.ps1 new file mode 100644 index 0000000000..40c6f7a546 --- /dev/null +++ b/docker/server.ps1 @@ -0,0 +1,6 @@ +# This script launches the whole stack of containers (web server, database, webpack, redis, etc.) +$DateTime=Get-Date -Format "yyyyMMdd-HHmmss" + +Write-Host "Docker-compose up: launches the whole stack of containers" -ForegroundColor Blue +docker-compose.exe up -d > log/server-$DateTime.log 2>&1 +Write-Host "Docker-compose up finished : View this app in your web browser at http://localhost:3000/" -ForegroundColor Blue \ No newline at end of file diff --git a/docker/test.ps1 b/docker/test.ps1 new file mode 100644 index 0000000000..f5a1bf958c --- /dev/null +++ b/docker/test.ps1 @@ -0,0 +1,9 @@ +# This test script : +# - prepares the database for rspec tests +# - launches the rspec tests +$DateTime=Get-Date -Format "yyyyMMdd-HHmmss" + +Write-Host "bundle exec rake db:test:prepare : prepare the database for rspec tests" -ForegroundColor Blue +docker-compose.exe run web bundle exec rake db:test:prepare > log/test-prepare-$DateTime.log 2>&1 +Write-Host "bundle exec rspec spec : launch the rspec tests" -ForegroundColor Blue +docker-compose.exe run web bundle exec rspec spec > log/test-rspec-$DateTime.log 2>&1 \ No newline at end of file From 54acfbf7f21b418a97757b4394659dec7a865ada Mon Sep 17 00:00:00 2001 From: Pipo Bimbo Date: Mon, 23 Jan 2023 15:08:18 +0100 Subject: [PATCH 09/10] documentation for docker on windows --- docker/README.md | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/docker/README.md b/docker/README.md index a101b4ffb1..b927c420e9 100644 --- a/docker/README.md +++ b/docker/README.md @@ -20,7 +20,7 @@ $ sudo apt install docker-compose ``` * To run Docker commands as a regular user instead of as root (with sudo), follow the instructions at https://docs.docker.com/engine/install/linux-postinstall/. -#### Windows and Mac (untested) +#### Windows * Docker installation instructions are at https://docs.docker.com/get-docker/. * You may have to deselect the option to use Docker Compose V2 in Docker settings to make our scripts work. @@ -53,7 +53,8 @@ $ docker/server * You will then get the trace of the containers in the terminal. You can stop the containers using Ctrl-C in the terminal. * You can find some useful tips and commands [here](https://github.com/openfoodfoundation/openfoodnetwork/wiki/Docker:-useful-tips-and-commands). -### Windows and Mac (untested) +### Windows +* Prerequisite : don't forget to activate the execution of powershell scripts following the instruction on [this page chosing "Using RemoteSigned Execution Policy"](https://shellgeek.com/powershell-fix-running-scripts-is-disabled-on-this-system/) * Open a terminal with a shell command. * Clone the repository. If you're planning on contributing code to the project (which we [LOVE](CONTRIBUTING.md)), begin by forking this repo with the Fork button in the top-right corner of this screen. * Use git clone to copy your fork onto your local machine. @@ -70,12 +71,13 @@ $ cd openfoodnetwork ``` * Download the Docker images, build the Docker containers, seed the database with sample data, AND log the screen output from these tasks: ```command -$ docker/build.bat +$ docker/build.ps1 ``` * Run the Rails server and its required Docker containers: ```command -$ docker/server.bat +$ docker/server.ps1 ``` +You may need to wait several minutes before getting the server up and running properly. * The default admin user is 'ofn@example.com' with the password 'ofn123'. * View the app in the browser at `http://localhost:3000`. * You will then get the trace of the containers in the terminal. You can stop the containers using Ctrl-C in the terminal. @@ -83,6 +85,7 @@ $ docker/server.bat ### Troubleshooting +* If you get a PowerShell error saying that "execution of scripts is disabled on this system.", you may need to [activate the powershell script execution](https://shellgeek.com/powershell-fix-running-scripts-is-disabled-on-this-system/) on your Windows machine. * If you are using Windows and having issues related to the ruby-build not finding a definition for the ruby version, you may need to follow these commands [here](https://stackoverflow.com/questions/2517190/how-do-i-force-git-to-use-lf-instead-of-crlf-under-windows/33424884#33424884) to fix your local git config related to line breaks. * If you’re getting the following error: ```sh @@ -123,14 +126,14 @@ To fix this error on server startup, you need to bump `mini-racer` gem from `0.4 Based on [spree/spree_starter #984](https://github.com/spree/spree_starter/issues/984) ## Script Summary -* docker/build(.bat): This script builds the Docker containers specified for this app, seeds the database, and logs the screen output for these operations. After you use "git clone" to download this repository, run the docker/build script to start the setup process. -* docker/server(.bat): Use this script to run this app in the Rails server. This script executes the "docker-compose up" command and logs the results. If all goes well, you will be able to view this app on your local browser at http://localhost:3000/. -* docker/test: Use this script to run the entire test suite. +* docker/build(.ps1): This script builds the Docker containers specified for this app, seeds the database, and logs the screen output for these operations. After you use "git clone" to download this repository, run the docker/build script to start the setup process. +* docker/server(.ps1): Use this script to run this app in the Rails server. This script executes the "docker-compose up" command and logs the results. If all goes well, you will be able to view this app on your local browser at http://localhost:3000/. +* docker/test(.ps1): Use this script to run the entire test suite. * docker/qtest: Use this script to run the entire test suite in quiet mode. The deprecation warnings are removed to make the test results easier to read. * docker/run: Use this script to run commands within the Docker container. If you want shell access, enter "docker/run bash". To execute "ls -l" within the Docker container, enter "docker/run ls -l". -* docker/seed: Use this script to seed the database. Please note that this process is not compatible with simultaneously running the Rails server or tests. +* docker/seed(.ps1): Use this script to seed the database. Please note that this process is not compatible with simultaneously running the Rails server or tests. * docker/nuke: Use this script to delete all Docker images and containers. This fully resets your Docker setup and is useful for making sure that the setup procedure specified for this app is complete. -* docker/cop: This script runs RuboCop. +* docker/cop(.ps1): This script runs RuboCop. From 118d3a9d8ec4e32dec6a91bbaea93d5e14562e42 Mon Sep 17 00:00:00 2001 From: Pipo Bimbo Date: Tue, 24 Jan 2023 08:50:33 +0100 Subject: [PATCH 10/10] separate log file for both steps of the tests --- docker/test | 22 +++++++++++++++++++--- docker/test-log | 17 ----------------- 2 files changed, 19 insertions(+), 20 deletions(-) delete mode 100755 docker/test-log diff --git a/docker/test b/docker/test index 3420c7595b..212df0f277 100755 --- a/docker/test +++ b/docker/test @@ -1,7 +1,23 @@ #!/bin/bash set -e -# This script runs the entire test suite AND logs the screen output. - +# This test script : +# - prepares the database for rspec tests +# - launches the rspec tests DATE=`date +%Y%m%d-%H%M%S-%3N` -docker/test-log 2>&1 | tee log/test-$DATE.log + +echo '--------------------------------------------------------------' +echo 'BEGIN: docker-compose run web bundle exec rake db:test:prepare' +echo '--------------------------------------------------------------' +docker-compose run web bundle exec rake db:test:prepare 2>&1 | tee log/test-prepare-$DATE.log +echo '------------------------------------------------------------' +echo 'END: docker-compose run web bundle exec rake db:test:prepare' +echo '------------------------------------------------------------' + +echo '----------------------------------------------------' +echo 'BEGIN: docker-compose run web bundle exec rspec spec' +echo '----------------------------------------------------' +docker-compose run web bundle exec rspec --no-color spec 2>&1 | tee log/test-rspec-$DATE.log +echo '--------------------------------------------------' +echo 'END: docker-compose run web bundle exec rspec spec' +echo '--------------------------------------------------' \ No newline at end of file diff --git a/docker/test-log b/docker/test-log deleted file mode 100755 index 4769212968..0000000000 --- a/docker/test-log +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -echo '--------------------------------------------------------------' -echo 'BEGIN: docker-compose run web bundle exec rake db:test:prepare' -echo '--------------------------------------------------------------' -docker-compose run web bundle exec rake db:test:prepare -echo '------------------------------------------------------------' -echo 'END: docker-compose run web bundle exec rake db:test:prepare' -echo '------------------------------------------------------------' - -echo '----------------------------------------------------' -echo 'BEGIN: docker-compose run web bundle exec rspec spec' -echo '----------------------------------------------------' -docker-compose run web bundle exec rspec spec -echo '--------------------------------------------------' -echo 'END: docker-compose run web bundle exec rspec spec' -echo '--------------------------------------------------'