This is a demo application for a bookstore, built with PHP and MySQL, and containerized using Docker and Docker Compose.
- Docker
- Docker Compose
-
Clone the repository:
git clone [email protected]:filipkojic/BookStore.git cd BookStore
-
Create a
.env
file in the root directory with the following content:DB_HOST=db DB_PORT=3306 DB_DATABASE=Bookstore DB_USERNAME=root DB_PASSWORD=123
Note: You can change
DB_DATABASE
andDB_PASSWORD
to fit your requirements, butDB_USERNAME
should remain asroot
unless you plan to create additional users in the MySQL container. -
Pull the Docker image from Docker Hub:
docker pull filipkojic99/bookstore_app_v2:latest
-
Update the
docker-compose.yml
file to use the pulled image:version: '3.8' services: app: image: filipkojic99/bookstore_app_v2:latest ports: - "8081:80" depends_on: - db environment: - DB_HOST=${DB_HOST} - DB_PORT=${DB_PORT} - DB_DATABASE=${DB_DATABASE} - DB_USERNAME=${DB_USERNAME} - DB_PASSWORD=${DB_PASSWORD} volumes: - /var/www/html/vendor - .:/var/www/html db: image: mysql:5.7 environment: MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} MYSQL_DATABASE: ${DB_DATABASE} ports: - "3307:3306" volumes: - db_data:/var/lib/mysql - ./init.sql:/docker-entrypoint-initdb.d/init.sql volumes: db_data:
-
Build and start the Docker containers:
docker-compose up -d --build
-
Access the application in your web browser at http://localhost:8081.