Skip to content

Narek1331/nebus-task

Repository files navigation

Project Name

This is a PHP application built with Laravel, running in Docker containers. It uses MySQL as the database and is designed for easy deployment on any machine.

===========================

  1. Prerequisites ===========================

Ensure the following software is installed on your machine:

=========================== 2. Getting Started

Follow these steps to get the application running in Docker:

=========================== Step 1: Clone the Repository

Clone the project repository to your local machine:

git clone cd

=========================== Step 2: Set Up Environment Variables

Copy the .env.example file to .env:

cp .env.example .env

Update the .env file with the following database configuration:

DB_CONNECTION=mysql DB_HOST=db DB_PORT=3306 DB_DATABASE=myapp_db DB_USERNAME=user DB_PASSWORD=user_password

Note:

  • DB_HOST=db: Refers to the MySQL container name defined in the docker-compose.yml.
  • DB_PORT=3306: The MySQL port.
  • DB_DATABASE=myapp_db: The name of the database as defined in docker-compose.yml.
  • DB_USERNAME=user & DB_PASSWORD=user_password: The MySQL user credentials.

=========================== Step 3: Build Docker Containers

Build the Docker containers:

docker-compose build

This command will create the PHP application container and the MySQL database container.

=========================== Step 4: Start Docker Containers

Start the containers:

docker-compose up -d

This will run the containers in the background (-d flag). The PHP application will be available on port 9000, and MySQL will be available on port 3306.

=========================== Step 5: Run Migrations

Once the containers are running, execute the following command to run database migrations:

docker-compose exec app php artisan migrate

This will create the necessary tables in the MySQL database.

=========================== Step 6: Seed the Database (Optional)

To populate the database with initial data, run:

docker-compose exec app php artisan db:seed

This will execute the seeders defined in the DatabaseSeeder.php file.

=========================== Step 7: Access the Application

After setting up the database, you can access the application in your browser:

http://localhost:9000

=========================== Step 8: Stop and Remove Containers

When you're done working with the containers, you can stop and remove them with:

docker-compose down

This will stop and remove all containers, networks, and volumes created by Docker Compose.

=========================== 3. Docker Configuration

Docker uses the following files to configure the environment:

  • Dockerfile: Defines the PHP environment with necessary extensions (pdo, pdo_mysql, gd) and installs Composer for dependency management.
  • docker-compose.yml: Defines the app (PHP container) and db (MySQL container) services.

=========================== 4. Troubleshooting

Error: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous

This occurs when there is ambiguity regarding the id column in your query. The solution is to explicitly define which table's id you're referring to, for example, use activities.id instead of just id.

Error: docker-compose: command not found

If you see this error, Docker Compose may not be installed. Follow the installation guide here: https://docs.docker.com/compose/install/

=========================== 5. License

This project is licensed under the MIT License - see the LICENSE file for details.

About

nebus-task

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages