implements:
ruby on rails
devise user authentication
graphql/graphiql/apollo graphql
styled components
material ui
formik
redux
redux-persist
and more
(extra dependencies made need to be installed):
- Clone the git repository
$ git clone [email protected]:APysnack/live-rap-center.git
- Change directory into the live rap center folder
$ cd live-rap-center
- Generate a secret hash
$rake secret
copy the output (if the output you get is longer than 32 characters, only copy the first 32 characters.)
4.Generate rails credentials and add your secret in a text editor (I use vim in this example, use whatever editor you're comfortable with)
$EDITOR=vim rails credentials:edit
paste the secret as shown below. Do not modify the secret_key_base
. Note there are exactly 2 spaces of indentation before jwt_secret_key
:
- Be sure to store this secret somewhere secure in case you need access to it in the future
- Install rails gems
$bundle install
- Run the rails migrations
$bundle exec rake db:migrate
- You should now be able to run $
rails s
and see a blank page atlocalhost:3000
with the word "main" on it. Keep the server terminal open.
- Open a new terminal, cd to the
live-rap-center/client
folder
- Install yarn dependencies
$yarn install
- Start the client
$yarn start
This should start up the client on localhost:4000
Deploy Steps
- Get AWS credentials and set ecr login
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 655948565243.dkr.ecr.us-east-1.amazonaws.com
- Build and push server container image
docker build --platform linux/amd64 --tag 655948565243.dkr.ecr.us-east-1.amazonaws.com/lrc_server .
docker push 655948565243.dkr.ecr.us-east-1.amazonaws.com/lrc_server:latest
- Build and push sidekiq container image
docker build --platform linux/amd64 --tag 655948565243.dkr.ecr.us-east-1.amazonaws.com/sidekiq_jobs -f SidekiqDockerfile .
docker push 655948565243.dkr.ecr.us-east-1.amazonaws.com/sidekiq_jobs:latest
-
Use Cloudformation template to create CFN Stack
-
Update development.rb and database.yml, respectively
config.active_storage.service = :amazon
development:
<<: *default
host: <%= ENV.fetch('AWS_RDS_HOST') %>
username: <%= ENV.fetch('AWS_RDS_USERNAME') %>
password: <%= ENV.fetch('AWS_RDS_PASSWORD') %>
database: <%= ENV.fetch('AWS_RDS_NAME') %>
port: <%= ENV.fetch('AWS_RDS_PORT') %>
- initialize the RDS DB
SEED_FILE=production rake db:reset
- Ensure that your client .env file has the new cloudfront distribution id and correct server url
cd client
yarn update
- Update sidekiq AWS service to desired tasks: 1