This project is a Rock Paper Scissors game consisting of a Rails API backend and a Next.js frontend. The application is containerized using Docker and Docker Compose.
Before you begin, make sure you have the following installed on your machine:
-
Clone the repository:
git clone https://github.com/sikor144/rps.git cd rps
-
Copy the example environment variables file:
cp .env.example .env
-
Edit the
.env
file to configure the environment variables:DATABASE_URL=postgres://rps_api:your_password@postgres:5432/rps_api_production RPS_API_BASE_URL=https://private-anon-c0651d3e1b-curbrockpaperscissors.apiary-mock.com SECRET_KEY_BASE=your_secret_key_base
-
Build and start the Docker containers:
docker-compose up --build
This command will build and start the following services:
postgres
: PostgreSQL databaseapi
: Rails API backendweb
: Next.js frontend
-
Access the application:
- The Next.js frontend will be available at http://localhost:3000
- The Rails API will be available at http://localhost:3001
- PostgreSQL: The database service
- API: The Rails backend service
- Web: The Next.js frontend service
To stop the application, run:
docker-compose down
This command will stop and remove the containers defined in your docker-compose.yml
.
-
Running commands inside the containers:
You can run commands inside the API or Web container using
docker-compose exec
. For example, to open a bash shell inside the API container, use:docker-compose exec api bash