From 06d54a3f4dfcb6c680fcc1b920ef84cc9d51a4a3 Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Wed, 23 Sep 2020 12:46:08 -0500 Subject: [PATCH 01/16] Added docker directory and scripts for resetting Docker --- docker/README.md | 3 +++ docker/nuke | 24 ++++++++++++++++++++++++ docker/nukec | 19 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 docker/README.md create mode 100755 docker/nuke create mode 100755 docker/nukec diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000000..c0eebe46c9 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,3 @@ +# Docker Scripts + +Use the scripts in this directory to execute tasks in Docker. Please note that these scripts are intended to be executed from this app's root directory. diff --git a/docker/nuke b/docker/nuke new file mode 100755 index 0000000000..65f0f7c2bc --- /dev/null +++ b/docker/nuke @@ -0,0 +1,24 @@ +#!/bin/bash + +# This script destroys all Docker containers and images. +# SOURCE: https://gist.github.com/JeffBelback/5687bb02f3618965ca8f + +docker/nukec + +echo '--------------------------------------' +echo 'Killing and removing all Docker images' +for i in $(docker images -a -q) +do + docker kill $i; wait; + docker rmi -f $i; wait; +done; + +echo '------------' +echo 'docker ps -a' +docker ps -a + +echo '----------------' +echo 'docker images -a' +docker images -a + +wait diff --git a/docker/nukec b/docker/nukec new file mode 100755 index 0000000000..c26472df79 --- /dev/null +++ b/docker/nukec @@ -0,0 +1,19 @@ +#!/bin/bash + +# This script destroys all Docker containers and networks but leaves the Docker images alone. + +echo '-----------------------' +echo 'docker network prune -f' +docker network prune -f + +echo '------------------------------------------' +echo 'Killing and removing all Docker containers' +for i in $(docker ps -a -q) +do + docker kill $i; wait; + docker rm -f $i; wait; +done; + +echo '------------' +echo 'docker ps -a' +docker ps -a From 6a6f9be18e876af471277a5f2f529cb32b0080a6 Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Wed, 23 Sep 2020 13:55:58 -0500 Subject: [PATCH 02/16] Added build and seeding scripts --- docker/build | 6 ++++++ docker/build-log | 12 ++++++++++++ docker/seed | 25 +++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100755 docker/build create mode 100755 docker/build-log create mode 100755 docker/seed diff --git a/docker/build b/docker/build new file mode 100755 index 0000000000..e6563458a0 --- /dev/null +++ b/docker/build @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +DATE=`date +%Y%m%d-%H%M%S-%3N` +docker/build-log 2>&1 | tee log/build-$DATE.log +docker/seed 2>&1 | tee log/seed-$DATE.log diff --git a/docker/build-log b/docker/build-log new file mode 100755 index 0000000000..185893ae11 --- /dev/null +++ b/docker/build-log @@ -0,0 +1,12 @@ +#!/bin/bash +set +e + +docker-compose down -v --remove-orphans +wait +echo '###########################' +echo 'BEGIN: docker-compose build' +echo '###########################' +docker-compose build +echo '##############################' +echo 'FINISHED: docker-compose build' +echo '##############################' diff --git a/docker/seed b/docker/seed new file mode 100755 index 0000000000..7799a5fb8b --- /dev/null +++ b/docker/seed @@ -0,0 +1,25 @@ +#!/bin/bash + +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 792127745a0af6749a53c54efa82c35c20b9dc75 Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Wed, 23 Sep 2020 23:22:38 -0500 Subject: [PATCH 03/16] Added docker/server scripts --- docker/server | 5 +++++ docker/server-log | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100755 docker/server create mode 100755 docker/server-log diff --git a/docker/server b/docker/server new file mode 100755 index 0000000000..b4b94ef588 --- /dev/null +++ b/docker/server @@ -0,0 +1,5 @@ +#!/bin/bash +set -e + +DATE=`date +%Y%m%d-%H%M%S-%3N` +docker/server-log 2>&1 | tee log/server-$DATE.log diff --git a/docker/server-log b/docker/server-log new file mode 100755 index 0000000000..08f0d3487e --- /dev/null +++ b/docker/server-log @@ -0,0 +1,9 @@ +#!/bin/bash +set +e + +echo '########################' +echo 'BEGIN: docker-compose up' +echo '########################' +echo 'View this app in your web browser at' +echo 'http://localhost:3000/' +docker-compose up From c6fbc1e1362ce94f2a6e873747e7e1110e247810 Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Wed, 23 Sep 2020 23:27:51 -0500 Subject: [PATCH 04/16] Added docker/cop --- docker/cop | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 docker/cop diff --git a/docker/cop b/docker/cop new file mode 100755 index 0000000000..cf29d82faf --- /dev/null +++ b/docker/cop @@ -0,0 +1,9 @@ +#!/bin/bash + +echo '----------------------------------------------------' +echo 'BEGIN: docker-compose run web bundle exec rubocop -D' +echo '----------------------------------------------------' +docker-compose run web bundle exec rubocop -D +echo '--------------------------------------------------' +echo 'END: docker-compose run web bundle exec rubocop -D' +echo '--------------------------------------------------' From 5ced17a94e3afe176df6b86738fd6566700c5bc8 Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Wed, 23 Sep 2020 23:36:13 -0500 Subject: [PATCH 05/16] Added docker/test and docker/test-log --- docker/test | 5 +++++ docker/test-log | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100755 docker/test create mode 100755 docker/test-log diff --git a/docker/test b/docker/test new file mode 100755 index 0000000000..46e6d3579a --- /dev/null +++ b/docker/test @@ -0,0 +1,5 @@ +#!/bin/bash +set -e + +DATE=`date +%Y%m%d-%H%M%S-%3N` +docker/test-log 2>&1 | tee log/test-$DATE.log diff --git a/docker/test-log b/docker/test-log new file mode 100755 index 0000000000..4769212968 --- /dev/null +++ b/docker/test-log @@ -0,0 +1,17 @@ +#!/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 '--------------------------------------------------' From 423a766463d6e048ab4b6316cb45ddff979450b6 Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Thu, 24 Sep 2020 23:42:00 -0500 Subject: [PATCH 06/16] Added docker/exec --- docker/exec | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 docker/exec diff --git a/docker/exec b/docker/exec new file mode 100755 index 0000000000..cbfafba89f --- /dev/null +++ b/docker/exec @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e + +function cleanup { + # capture exit code + code=$? + echo "cleaning up" + + # ignore errors + set +e + docker-compose down + + exit $code +} + +trap cleanup EXIT + +docker-compose run --rm web $@ From 2a902f29bbe2991fe0335388a715345573269d73 Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Fri, 25 Sep 2020 00:12:27 -0500 Subject: [PATCH 07/16] Added comments to scripts --- docker/build | 2 ++ docker/cop | 2 ++ docker/exec | 3 +++ docker/seed | 2 ++ docker/server | 2 ++ docker/test | 2 ++ 6 files changed, 13 insertions(+) diff --git a/docker/build b/docker/build index e6563458a0..f7c97d6c0e 100755 --- a/docker/build +++ b/docker/build @@ -1,6 +1,8 @@ #!/bin/bash set -e +# This script builds the Docker container, seeds the app with simulated data, and logs the screen output. + DATE=`date +%Y%m%d-%H%M%S-%3N` docker/build-log 2>&1 | tee log/build-$DATE.log docker/seed 2>&1 | tee log/seed-$DATE.log diff --git a/docker/cop b/docker/cop index cf29d82faf..1e65f1cd78 100755 --- a/docker/cop +++ b/docker/cop @@ -1,5 +1,7 @@ #!/bin/bash +# This script runs RuboCop. + echo '----------------------------------------------------' echo 'BEGIN: docker-compose run web bundle exec rubocop -D' echo '----------------------------------------------------' diff --git a/docker/exec b/docker/exec index cbfafba89f..5e606bd8cd 100755 --- a/docker/exec +++ b/docker/exec @@ -2,6 +2,9 @@ set -e +# Use this script to execute commaands in the Docker container. +# Example: To run the "ls -l" command in the Docker container, enter the command "docker/exec ls -l". + function cleanup { # capture exit code code=$? diff --git a/docker/seed b/docker/seed index 7799a5fb8b..7e02a16810 100755 --- a/docker/seed +++ b/docker/seed @@ -1,5 +1,7 @@ #!/bin/bash +# This is the data seeding script. + echo '-------------------------------------------------------' echo 'BEGIN: docker-compose run web bundle exec rake db:reset' echo '-------------------------------------------------------' diff --git a/docker/server b/docker/server index b4b94ef588..fef22b16d9 100755 --- a/docker/server +++ b/docker/server @@ -1,5 +1,7 @@ #!/bin/bash set -e +# This script runs the Rails server and logs the screen output. + DATE=`date +%Y%m%d-%H%M%S-%3N` docker/server-log 2>&1 | tee log/server-$DATE.log diff --git a/docker/test b/docker/test index 46e6d3579a..3420c7595b 100755 --- a/docker/test +++ b/docker/test @@ -1,5 +1,7 @@ #!/bin/bash set -e +# This script runs the entire test suite AND logs the screen output. + DATE=`date +%Y%m%d-%H%M%S-%3N` docker/test-log 2>&1 | tee log/test-$DATE.log From a46683ef016c786c6c1e2d7c0429c79b5b421f1e Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Fri, 25 Sep 2020 00:24:24 -0500 Subject: [PATCH 08/16] Added docker/testc --- docker/testc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 docker/testc diff --git a/docker/testc b/docker/testc new file mode 100755 index 0000000000..e42615caba --- /dev/null +++ b/docker/testc @@ -0,0 +1,19 @@ +#!/bin/bash + +# This script runs just the controller tests. + +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 spec/controllers' +echo '----------------------------------------------------------' +docker-compose run web bundle exec rspec spec/controllers +echo '--------------------------------------------------------------' +echo 'END: docker-compose run web bundle exec rspec spec/controllers' +echo '--------------------------------------------------------------' From 97a38865a228bb54d913fc418d2baefb6b4fdd67 Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Fri, 25 Sep 2020 00:30:20 -0500 Subject: [PATCH 09/16] Added docker/testm --- docker/testm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 docker/testm diff --git a/docker/testm b/docker/testm new file mode 100755 index 0000000000..ecaa66a4fd --- /dev/null +++ b/docker/testm @@ -0,0 +1,19 @@ +#!/bin/bash + +# This script runs just the model tests. + +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 spec/models' +echo '-----------------------------------------------------' +docker-compose run web bundle exec rspec spec/models +echo '---------------------------------------------------------' +echo 'END: docker-compose run web bundle exec rspec spec/models' +echo '---------------------------------------------------------' From d2523abe34ae4a001951e334bc5359b9cdf73afd Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Fri, 25 Sep 2020 00:49:44 -0500 Subject: [PATCH 10/16] Moved contents of DOCKER.md to docker/README.md; removed DOCKER.md; updated link to Docker page in GETTING_STARTED.md --- DOCKER.md | 62 ---------------------------------------------- GETTING_STARTED.md | 2 +- docker/README.md | 42 ++++++++++++++++++++++++++++++- docker/build | 2 +- docker/build-log | 2 +- 5 files changed, 44 insertions(+), 66 deletions(-) delete mode 100644 DOCKER.md diff --git a/DOCKER.md b/DOCKER.md deleted file mode 100644 index 935e62b729..0000000000 --- a/DOCKER.md +++ /dev/null @@ -1,62 +0,0 @@ -### Docker - -It is possible to setup the Open Food Network app easily with Docker and Docker Compose. -The objective is to spare configuration time, in order to help people testing the app and contribute to it. -It can also be used as documentation. It is not perfect but it is used in many other projects and many devs are used to it nowadays. - -### Install Docker - -Please check the documentation here, https://docs.docker.com/install/ to install Docker. - -For Docker Compose, information are here: https://docs.docker.com/compose/install/. - -Better to have at least 2GB free on your computer in order to download images and create containers for Open Food Network app. - - -### Use Docker with Open Food Network - -Open a terminal with a shell. - -Clone the repository. If you're planning on contributing code to the project (which we [LOVE](CONTRIBUTING.md)), it is a good idea to begin by forking this repo using the Fork button in the top-right corner of this screen. You should then be able to use git clone to copy your fork onto your local machine. - -```sh -$ 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: - -```sh -$ git clone git@github.com:openfoodfoundation/openfoodnetwork.git -``` - -Go at the root of the app: - -```sh -$ cd openfoodnetwork -``` - -Download the Docker images and build the containers: - -```sh -$ docker-compose build -``` - -Setup the database and seed it with sample data: -```sh -$ docker-compose run web bundle exec rake db:reset -$ docker-compose run web bundle exec rake db:test:prepare -$ docker-compose run web bundle exec rake ofn:sample_data -``` - -Finally, run the app with all the required containers: - -```sh -$ docker-compose up -``` - -The default admin user is 'ofn@example.com' with 'ofn123' password. -Check 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). diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index fd8dc47769..db5ed0a65b 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -4,7 +4,7 @@ This is a general guide to setting up an Open Food Network **development environ ### Requirements -The fastest way to make it work locally is to use Docker, you only need to setup git, see the [Docker setup guide](DOCKER.md). +The fastest way to make it work locally is to use Docker, you only need to setup git, see the [Docker setup guide](docker/README.md). Otherwise, for a local setup you will need: * Ruby 2.3.7 and bundler * PostgreSQL database diff --git a/docker/README.md b/docker/README.md index c0eebe46c9..df1cf68f9f 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,3 +1,43 @@ # Docker Scripts -Use the scripts in this directory to execute tasks in Docker. Please note that these scripts are intended to be executed from this app's root directory. +## What's the point? +* Setting up the Open Food Network app on your local machine is quick and easy with the aid of Docker and Docker Compose. +* Docker provides a common virtual environment available to all developers and resolves the infamous "but it works on my machine" problem. +* Use the scripts in this directory to execute tasks in Docker. Please note that these scripts are intended to be executed from this app's root directory. These scripts allow you to bypass the need to keep typing "docker-compose run --rm web". + +## Installing Docker +* You should have at least 2 GB free on your local machine to download Docker images and create Docker containers for this app. +* Docker installation instructions are at https://docs.docker.com/install/. +* Docker Compose installation instructions are at https://docs.docker.com/compose/install/. +* 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/. + +## Getting Started +* 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. +```sh +$ 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: + +```sh +$ git clone git@github.com:openfoodfoundation/openfoodnetwork.git +``` +* Go at the root of the app: + +```sh +$ cd openfoodnetwork +``` +* Download the Docker images, build the Docker containers, seed the database with sample data, AND log the screen output from these tasks: +```sh +$ docker/build +``` +* Run the Rails server and its required Docker containers: + +```sh +$ docker/server +``` +* 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). diff --git a/docker/build b/docker/build index f7c97d6c0e..f3966951f8 100755 --- a/docker/build +++ b/docker/build @@ -1,7 +1,7 @@ #!/bin/bash set -e -# This script builds the Docker container, seeds the app with simulated data, and logs the screen output. +# This script builds the Docker container, seeds the app with sample data, and logs the screen output. DATE=`date +%Y%m%d-%H%M%S-%3N` docker/build-log 2>&1 | tee log/build-$DATE.log diff --git a/docker/build-log b/docker/build-log index 185893ae11..7e7903c2a1 100755 --- a/docker/build-log +++ b/docker/build-log @@ -6,7 +6,7 @@ wait echo '###########################' echo 'BEGIN: docker-compose build' echo '###########################' -docker-compose build +docker-compose build # Set up the Docker containers echo '##############################' echo 'FINISHED: docker-compose build' echo '##############################' From 2b5a875baca71a6ec6a38647b06c54d27da224d0 Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Fri, 25 Sep 2020 11:00:54 -0500 Subject: [PATCH 11/16] Added script summary to docker/README.md --- docker/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docker/README.md b/docker/README.md index df1cf68f9f..c6587202d2 100644 --- a/docker/README.md +++ b/docker/README.md @@ -41,3 +41,14 @@ $ docker/server * 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). + +## 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/cop: This script runs RuboCop. +* docker/exec: Use this script to run commands within the Docker container. If you want shell access, enter "docker/exec bash". To execute "ls -l" within the Docker container, enter "docker/exec ls -l". +* 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/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/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/test: Use this script to run the entire test suite. +* docker/testc: Use this script to run just the controller tests. +* docker/testm: Use this script to run just the model tests. From ea9d5f7c5a3b3a1dd93ab99f34591e50b91d5712 Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Fri, 25 Sep 2020 20:35:24 -0500 Subject: [PATCH 12/16] Removed testc and testm; made the requested changes to the order of the scripts in the summary section --- docker/README.md | 12 ++++++------ docker/testc | 19 ------------------- docker/testm | 19 ------------------- 3 files changed, 6 insertions(+), 44 deletions(-) delete mode 100755 docker/testc delete mode 100755 docker/testm diff --git a/docker/README.md b/docker/README.md index c6587202d2..1c56f546d7 100644 --- a/docker/README.md +++ b/docker/README.md @@ -44,11 +44,11 @@ $ docker/server ## 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/cop: This script runs RuboCop. -* docker/exec: Use this script to run commands within the Docker container. If you want shell access, enter "docker/exec bash". To execute "ls -l" within the Docker container, enter "docker/exec ls -l". -* 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/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/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/test: Use this script to run the entire test suite. -* docker/testc: Use this script to run just the controller tests. -* docker/testm: Use this script to run just the model tests. +* docker/exec: Use this script to run commands within the Docker container. If you want shell access, enter "docker/exec bash". To execute "ls -l" within the Docker container, enter "docker/exec 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/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. + + diff --git a/docker/testc b/docker/testc deleted file mode 100755 index e42615caba..0000000000 --- a/docker/testc +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# This script runs just the controller tests. - -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 spec/controllers' -echo '----------------------------------------------------------' -docker-compose run web bundle exec rspec spec/controllers -echo '--------------------------------------------------------------' -echo 'END: docker-compose run web bundle exec rspec spec/controllers' -echo '--------------------------------------------------------------' diff --git a/docker/testm b/docker/testm deleted file mode 100755 index ecaa66a4fd..0000000000 --- a/docker/testm +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# This script runs just the model tests. - -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 spec/models' -echo '-----------------------------------------------------' -docker-compose run web bundle exec rspec spec/models -echo '---------------------------------------------------------' -echo 'END: docker-compose run web bundle exec rspec spec/models' -echo '---------------------------------------------------------' From d9476ec87dfe416a7df2900d12b0e891f47c5b67 Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Thu, 8 Oct 2020 14:38:49 -0500 Subject: [PATCH 13/16] Corrected the docker-compose commands in docker/cop, docker/seed, and docker/test-log --- docker/cop | 10 +++++----- docker/seed | 42 +++++++++++++++++++++--------------------- docker/test-log | 28 ++++++++++++++-------------- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/docker/cop b/docker/cop index 1e65f1cd78..948ea467d5 100755 --- a/docker/cop +++ b/docker/cop @@ -2,10 +2,10 @@ # This script runs RuboCop. +echo '------------------------------------------------------' +echo 'BEGIN: docker-compose run --rm web bundle exec rubocop' +echo '------------------------------------------------------' +docker-compose run --rm web bundle exec rubocop echo '----------------------------------------------------' -echo 'BEGIN: docker-compose run web bundle exec rubocop -D' +echo 'END: docker-compose run --rm web bundle exec rubocop' echo '----------------------------------------------------' -docker-compose run web bundle exec rubocop -D -echo '--------------------------------------------------' -echo 'END: docker-compose run web bundle exec rubocop -D' -echo '--------------------------------------------------' diff --git a/docker/seed b/docker/seed index 7e02a16810..c3feb3c8bb 100755 --- a/docker/seed +++ b/docker/seed @@ -2,26 +2,26 @@ # 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 --rm web bundle exec rubocop bundle exec rake db:reset' +echo '--------------------------------------------------------------------------------' +docker-compose run --rm web bundle exec rubocop bundle exec rake db:reset +echo '------------------------------------------------------------------------------' +echo 'END: docker-compose run --rm web bundle exec rubocop 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 --rm web bundle exec rubocop bundle exec rake db:test:prepare' +echo '---------------------------------------------------------------------------------------' +docker-compose run --rm web bundle exec rubocop bundle exec rake db:test:prepare +echo '-------------------------------------------------------------------------------------' +echo 'END: docker-compose run --rm web bundle exec rubocop 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 '------------------------------------------------------------' +echo '---------------------------------------------------------------------------------------' +echo 'BEGIN: docker-compose run --rm web bundle exec rubocop bundle exec rake ofn:sample_data' +echo '---------------------------------------------------------------------------------------' +docker-compose run --rm web bundle exec rubocop bundle exec rake ofn:sample_data +echo '-------------------------------------------------------------------------------------' +echo 'END: docker-compose run --rm web bundle exec rubocop bundle exec rake ofn:sample_data' +echo '-------------------------------------------------------------------------------------' diff --git a/docker/test-log b/docker/test-log index 4769212968..662747664e 100755 --- a/docker/test-log +++ b/docker/test-log @@ -1,17 +1,17 @@ #!/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 --rm web bundle exec rake db:test:prepare' +echo '-------------------------------------------------------------------' +docker-compose run --rm web bundle exec rake db:test:prepare +echo '-----------------------------------------------------------------' +echo 'END: docker-compose run --rm 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 '--------------------------------------------------' +echo '---------------------------------------------------------' +echo 'BEGIN: docker-compose run --rm web bundle exec rspec spec' +echo '---------------------------------------------------------' +docker-compose run --rm web bundle exec rspec spec +echo '-------------------------------------------------------' +echo 'END: docker-compose run --rm web bundle exec rspec spec' +echo '-------------------------------------------------------' From 71ad109f78eedf564abf325bc121b4f3bd792a54 Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Thu, 8 Oct 2020 14:43:30 -0500 Subject: [PATCH 14/16] Changed docker/exec to docker/run; updated docker/README.md to reflect this --- docker/README.md | 2 +- docker/{exec => run} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename docker/{exec => run} (89%) diff --git a/docker/README.md b/docker/README.md index 9e76f29701..d08cdd32d7 100644 --- a/docker/README.md +++ b/docker/README.md @@ -49,7 +49,7 @@ If you are using Windows and having issues related to the ruby-build not finding * 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/test: Use this script to run the entire test suite. -* docker/exec: Use this script to run commands within the Docker container. If you want shell access, enter "docker/exec bash". To execute "ls -l" within the Docker container, enter "docker/exec ls -l". +* 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/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. diff --git a/docker/exec b/docker/run similarity index 89% rename from docker/exec rename to docker/run index 5e606bd8cd..3975c87d32 100755 --- a/docker/exec +++ b/docker/run @@ -3,7 +3,7 @@ set -e # Use this script to execute commaands in the Docker container. -# Example: To run the "ls -l" command in the Docker container, enter the command "docker/exec ls -l". +# Example: To run the "ls -l" command in the Docker container, enter the command "docker/run ls -l". function cleanup { # capture exit code From e5d97e37f128fbc772c3c6972134b7f2aa31a2bb Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Thu, 8 Oct 2020 14:46:12 -0500 Subject: [PATCH 15/16] Moved docker network prune -f command from docker/nukec to docker/nuke --- docker/nuke | 6 +++++- docker/nukec | 6 +----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docker/nuke b/docker/nuke index 65f0f7c2bc..737c63b107 100755 --- a/docker/nuke +++ b/docker/nuke @@ -1,10 +1,14 @@ #!/bin/bash -# This script destroys all Docker containers and images. +# This script destroys all Docker containers, images, and networks. # SOURCE: https://gist.github.com/JeffBelback/5687bb02f3618965ca8f docker/nukec +echo '-----------------------' +echo 'docker network prune -f' +docker network prune -f + echo '--------------------------------------' echo 'Killing and removing all Docker images' for i in $(docker images -a -q) diff --git a/docker/nukec b/docker/nukec index c26472df79..cebba9db4f 100755 --- a/docker/nukec +++ b/docker/nukec @@ -1,10 +1,6 @@ #!/bin/bash -# This script destroys all Docker containers and networks but leaves the Docker images alone. - -echo '-----------------------' -echo 'docker network prune -f' -docker network prune -f +# This script destroys all Docker containers but leaves the Docker images alone. echo '------------------------------------------' echo 'Killing and removing all Docker containers' From c53d4cf8eaaa7524a56fd8f8531b078908e08db5 Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Thu, 8 Oct 2020 23:24:54 -0500 Subject: [PATCH 16/16] Corrected typos in docker/seed --- docker/seed | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/docker/seed b/docker/seed index c3feb3c8bb..f3b519146a 100755 --- a/docker/seed +++ b/docker/seed @@ -2,26 +2,26 @@ # This is the data seeding script. -echo '--------------------------------------------------------------------------------' -echo 'BEGIN: docker-compose run --rm web bundle exec rubocop bundle exec rake db:reset' -echo '--------------------------------------------------------------------------------' -docker-compose run --rm web bundle exec rubocop bundle exec rake db:reset -echo '------------------------------------------------------------------------------' -echo 'END: docker-compose run --rm web bundle exec rubocop bundle exec rake db:reset' -echo '------------------------------------------------------------------------------' +echo '------------------------------------------------------------' +echo 'BEGIN: docker-compose run --rm web bundle exec rake db:reset' +echo '------------------------------------------------------------' +docker-compose run --rm web bundle exec rake db:reset +echo '----------------------------------------------------------' +echo 'END: docker-compose run --rm web bundle exec rake db:reset' +echo '----------------------------------------------------------' -echo '---------------------------------------------------------------------------------------' -echo 'BEGIN: docker-compose run --rm web bundle exec rubocop bundle exec rake db:test:prepare' -echo '---------------------------------------------------------------------------------------' -docker-compose run --rm web bundle exec rubocop bundle exec rake db:test:prepare -echo '-------------------------------------------------------------------------------------' -echo 'END: docker-compose run --rm web bundle exec rubocop bundle exec rake db:test:prepare' -echo '-------------------------------------------------------------------------------------' +echo '-------------------------------------------------------------------' +echo 'BEGIN: docker-compose run --rm web bundle exec rake db:test:prepare' +echo '-------------------------------------------------------------------' +docker-compose run --rm web bundle exec rake db:test:prepare +echo '-----------------------------------------------------------------' +echo 'END: docker-compose run --rm web bundle exec rake db:test:prepare' +echo '-----------------------------------------------------------------' -echo '---------------------------------------------------------------------------------------' -echo 'BEGIN: docker-compose run --rm web bundle exec rubocop bundle exec rake ofn:sample_data' -echo '---------------------------------------------------------------------------------------' -docker-compose run --rm web bundle exec rubocop bundle exec rake ofn:sample_data -echo '-------------------------------------------------------------------------------------' -echo 'END: docker-compose run --rm web bundle exec rubocop bundle exec rake ofn:sample_data' -echo '-------------------------------------------------------------------------------------' +echo '-------------------------------------------------------------------' +echo 'BEGIN: docker-compose run --rm web bundle exec rake ofn:sample_data' +echo '-------------------------------------------------------------------' +docker-compose run --rm web bundle exec rake ofn:sample_data +echo '-----------------------------------------------------------------' +echo 'END: docker-compose run --rm web bundle exec rake ofn:sample_data' +echo '-----------------------------------------------------------------'