Skip to content

Commit

Permalink
feat: readme and script to start docker environment
Browse files Browse the repository at this point in the history
  • Loading branch information
noahdurbin committed Aug 26, 2024
1 parent 7200e1f commit 811e89d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 15 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,28 @@ This is the backend API repository for TurLink. TurLink is a link shortener app

## Setup and Testing
- clone this repo

### traditional setup
- run `bundle install`
- run `rails db:{drop,create,migrate,seed}`
- for the test suite, run `bundle exec rspec`
- to use endpoints in development enivronment, run `rails s` and use `http://localhost:5000` as your base url

### setup with docker
- ensure you have docker installed on your local machine
- run `chmod +x docker_start.sh` to make script executable
- run `./docker_start.sh`
- builds docker images
- starts containers
- creates database
- runs migrations
- seeds database
- application should now be live at `http://localhost:3001`
- to stop the application run `docker-compose down`

- Rails container: `docker-compose exec web bash`
- Rails console: `docker-compose run web rails c`

## API Endpoints

### User Registration
Expand Down
30 changes: 15 additions & 15 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions docker_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Exit immediately if a command exits with a non-zero status.
set -e

echo "Starting Docker environment for turlink-be..."

# Build Docker images
echo "Building Docker images..."
docker-compose build

# Start the containers
echo "Starting Docker containers..."
docker-compose up -d

# Wait for the database to be ready
echo "Waiting for database to be ready..."
sleep 10

# Run database setup
echo "Setting up the database..."
docker-compose run web rails db:create
docker-compose run web rails db:migrate

# seed database
echo "Seeding the database..."
docker-compose run web rails db:seed

echo "Setup complete! Your application should be running at http://localhost:3001"

0 comments on commit 811e89d

Please sign in to comment.