Prerequisites:
Step 1: Clone the Repository
git clone https://github.com/cyrmee/BookStore
Step 2: Set Up Environment Variables
- Copy
.env.example
to.env
cp .env.example .env
- Replace the placeholder values in the
.env
file with your own values:POSTGRES_USER
: Replace with the username for the PostgreSQL database.POSTGRES_PASSWORD
: Replace with the password for the PostgreSQL database.POSTGRES_DB
: Replace with the name of the PostgreSQL database.
Step 3: Update Connection String
- In the root directory of the cloned repository, navigate to the
Presentation
folder. - Open
appsettings.json
. - Find the connection string and update the
"host"
value with the container name of the PostgreSQL database. The container name should be the same as specified in thedocker-compose.yml
file.
Here's an example of how the updated connection string might look like:
"ConnectionStrings": {
"DefaultConnection": "Server=postgres_container_name;Port=5432;Database=bookstore_db;User Id=your_username;Password=your_password;"
}
Make sure to replace "postgres_container_name" with the actual container name of your PostgreSQL database found in .env
file, "your_username" with the appropriate username, and "your_password" with the corresponding password.
Save the changes to the appsettings.json
file after making the necessary modifications.
Step 4: Build and Run the Docker Containers
- Open your terminal or command prompt.
- Change the current working directory to the root directory of the project.
- Run the following command to build and run the Docker containers:
docker compose up --build -d
This command will build and start the containers defined in the docker-compose.yml
file.
Step 5: Access the Application
- To access the application through Nginx, open your web browser and visit
http://localhost
. - To access the API directly, open your web browser and visit
http://localhost:5000
. The API is served by thewebapi
container.
That's it! You have successfully installed and set up the project.