- Install Docker (use Docker for Mac if you're on a Mac).
- Copy
docker-compose.override.yml.example
todocker-compose.override.yml
and fill in any placeholder settings. - Run
./quickstart.sh
. (The file has step-by-step descriptions if you'd rather run it yourself.) - Go to http://localhost:3000/ to visit Kudos!
After installing the first time, you can start kudos by running docker-compose up
.
Docker-compose starts the db container and the web container. The db container starts with a Postgres server and the web container uses foreman to run (a) the webpack build tool and (b) the rails server.
Delete the tmp/pids/server.pid
file. This is because of an improper shutdown.
Either change the port (in docker-compose.override.yml
) or make sure you don't have anything running on port 3000. Try running a docker ps
to see if you have any containers forwarded to port 3000, then docker kill [CID]
to remove them.
You have a stale cookie in your browser. Remove the _kudos_session
cookie from the domain name you're accessing.
Since we're using docker-compose, you can run docker-compose run [SERVICE] [COMMAND]
. For instance:
- To get an interactive psql session, run
docker-compose run db psql -h db -U postgres
- To get an interactive rails console, run
docker-compose run web rails c
- To drop into a shell, run
docker-compose run [SERVICE] /bin/bash
- To migrate the database, run
docker-compose run web rails db:migrate
- To restore the database using an S3 backup, run
docker-compose run web rails db:restore
- To install node packages, run
docker-compose run web npm install
(this will run the outer and innernpm install
) - To install new gems, run
docker-compose run web bundle install
- To install a new gem, run
docker-compose run web bundle install [GEM_NAME]
then commit the updatedGemfile.lock
file - To install a new node package, run
docker-compose run web npm install --save [MODULE_NAME]
then commit the updatedpackage.json
file
Since the docker-compose file mounts the working directory inside the docker container, any changes the filesystem inside the docker are reflected locally. This is for ease of developer user and does not happen in production. If you need to install anything in production, it must be in the image's Dockerfile
. (That might mean running things twice. For instance, npm install
runs in Dockercompose
and then again in quickstart: the first will affect the image's filesystem, so it can be run in production, and the second will change your locally mounted filesystem, for development.)
You can use this same idea to use any interactive tool. Byebug is an interactive ruby debugger that runs inside www.
- Start the db service in non-interactive mode with
docker-compose up -d db
- Start webpack on its own with
docker-compose run web foreman run -f Procfile.dev client
- Start rails on its own with
docker-compose run --service-ports web foreman run -f Procfile.dev web
. If you keep this open, you'll be able to use byebug in interactive mode.
You can run any docker-compose up
or docker-compose run
command with the -d
flag to start it in detached mode. You can find it again by running docker ps
, then attach using docker attach [CONTAINER_ID]
. You can disconnect by typing Ctrl+p Ctrl+q
. You can kill the docker with docker kill [CONTAINER_ID]
or all of them with docker-compose down
.
You can also use multiple terminals (windows, tabs, tmux, screen, byobu, etc.).