Skip to content

Commit a640529

Browse files
authored
Merge pull request #63 from jeffmaher/dev-setup-readme-updates
Local dev documentation updates
2 parents 5f5646e + 63cd699 commit a640529

File tree

3 files changed

+79
-8
lines changed

3 files changed

+79
-8
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ yarn-debug.log*
3636

3737
config/terraform/*/.terraform/*
3838
config/terraform/*/terraform.tfstate*
39+
40+
.DS_Store
41+
/mysql-data

README.md

+74-8
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,82 @@ The use of this portal is optional and you can easily integrate the code creatio
2222
The setup steps expect the following tools to be installed on the system:
2323

2424
- [Ruby](https://guides.rubyonrails.org/getting_started.html#installing-ruby)
25+
- [Rails](https://guides.rubyonrails.org/getting_started.html#creating-a-new-rails-project-installing-rails-installing-rails)
2526
- [MySQL](https://dev.mysql.com/doc/mysql-installation-excerpt/5.7/en/)
2627
- [Node.js](https://guides.rubyonrails.org/getting_started.html#installing-node-js-and-yarn)
27-
- [Rails](https://guides.rubyonrails.org/getting_started.html#creating-a-new-rails-project-installing-rails-installing-rails)
28-
- [COVID Shield Diagnosis Server](https://github.com/CovidShield/backend)
28+
- [Webpack](https://github.com/webpack/webpack#install)
29+
- [Yarn](https://yarnpkg.com/getting-started/install#global-install)
30+
- [COVID Shield Diagnosis Server](https://github.com/CovidShield/server)
31+
- [Docker/Docker Compose](https://docs.docker.com/get-started/#set-up-your-docker-environment)
2932

30-
### 1. Check out the repository
33+
### Check out the repository
3134

3235
```bash
3336
git clone git@github.com:CovidShield/portal.git
3437
```
3538

36-
### 2. Update database.yml file
39+
### Install dependencies
40+
41+
```bash
42+
# If you don't have the bundler gem, do this next line too:
43+
# gem install bundler
44+
45+
bundle install
46+
```
47+
48+
On MacOS, you may get issues installing the `mysql2` Gem. If you have [Homebrew](https://brew.sh/), you can install it this way:
49+
50+
```bash
51+
brew install mysql openssl
52+
gem install mysql2 -- --with-cflags=\"-I/usr/local/opt/openssl@1.1/include\" --with-ldflags=\"-L/usr/local/opt/openssl@1.1/lib\"
53+
bundle install
54+
```
55+
### (Optional) Create a new MySQL Database using Docker
56+
57+
If you don't already have a local MySQL database, you can create one easily.
58+
59+
First, create a directory for the local data storage:
60+
61+
```bash
62+
mkdir mysql-data
63+
```
64+
65+
Second, start the database using Docker:
3766

38-
Update the database.yml file with your MySQL configuration as required.
67+
```bash
68+
docker run -it --rm -p 3306:3306 --name portal-db -v $PWD/mysql-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=stayhealthy -d mysql
69+
```
70+
71+
This will create a database with the following properties:
72+
73+
- IP: `127.0.0.1`
74+
- Port: `3306`
75+
- User: `root`
76+
- Password: `stayhealthy`
77+
78+
To kill it later, use:
79+
80+
```
81+
docker kill portal-db
82+
```
3983

40-
### 3. Create and set up the database
84+
### Update database.yml file
85+
86+
Update the [database.yml](config/database.yml) file with your MySQL configuration as required.
87+
88+
If you're using the Docker-based MySQL from the above section, your `default` section will look like this:
89+
90+
```yaml
91+
default: &default
92+
adapter: mysql2
93+
encoding: utf8mb4
94+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
95+
username: root
96+
password: stayhealthy
97+
host: 127.0.0.1
98+
```
99+
100+
### Create and set up the database
41101
42102
Run the following commands to create and set up the database.
43103
@@ -47,12 +107,18 @@ bundle exec rake db:setup
47107
bundle exec rake db:seed
48108
```
49109

50-
### 4. Start the Rails server
110+
### Start the Webpack Server
111+
112+
Open a new terminal window, navigating into the base of the repo, and start the Webpack server:
113+
114+
`./bin/webpack -w`
115+
116+
### Start the Rails server
51117

52118
You can start the rails server using the command given below (replacing the KEY_CLAIM_HOST to match your running diagnosis server config).
53119

54120
```ruby
55-
KEY_CLAIM_HOST=localhost:3000 bundle exec rails s
121+
KEY_CLAIM_HOST=127.0.0.1:8000 bundle exec rails s
56122
```
57123

58124
And now you can visit the site with the URL http://localhost:3000

config/environments/development.rb

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
end
6363
Rails.application.configure do
6464
config.hosts << "portal.myshopify.io"
65+
config.hosts << "127.0.0.1"
66+
config.hosts << "localhost"
6567
end
6668

6769
Rails.application.configure do

0 commit comments

Comments
 (0)