diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3274dbd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM php:8.3-apache + +# Install dependencies and PHP extensions +RUN apt-get update && apt-get install -y \ + libpq-dev \ + curl \ + && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \ + && apt-get install -y nodejs \ + && docker-php-ext-install pdo pdo_pgsql pcntl + +# Enable Apache mod_rewrite +RUN a2enmod rewrite + +# Set working directory +WORKDIR /var/www/html + +# Install composer +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer \ No newline at end of file diff --git a/README.md b/README.md index 0165a77..2f98d50 100644 --- a/README.md +++ b/README.md @@ -1,59 +1,64 @@ -

Laravel Logo

+# E-Waste Backend -

-Build Status -Total Downloads -Latest Stable Version -License -

+## Installation -## About Laravel +Clone the repo. -Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: +### 1a. Docker (Recommended) -- [Simple, fast routing engine](https://laravel.com/docs/routing). -- [Powerful dependency injection container](https://laravel.com/docs/container). -- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. -- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). -- Database agnostic [schema migrations](https://laravel.com/docs/migrations). -- [Robust background job processing](https://laravel.com/docs/queues). -- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). +It's recommended to use Docker to set up the development environment. It's literally one command: -Laravel is accessible, powerful, and provides tools required for large, robust applications. +```bash +docker compose up -d +``` -## Learning Laravel +From this point onward, run all shell commands inside the `ewaste-backend-laravel-1` container. The easiest way to do this is through your IDE's Docker extension, but the manual way is: -Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. You can also check out [Laravel Learn](https://laravel.com/learn), where you will be guided through building a modern Laravel application. +```bash +docker exec -it ewaste-backend-laravel-1 /bin/bash +``` -If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. +### 1b. Manual -## Laravel Sponsors +Alternatively, you can install PHP 8 (with the relevant extensions), PHP Composer, and Postgres on your system, then go into this directory and run: -We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com). +```bash +composer install +``` -### Premium Partners +### 2. Migrations -- **[Vehikl](https://vehikl.com)** -- **[Tighten Co.](https://tighten.co)** -- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** -- **[64 Robots](https://64robots.com)** -- **[Curotec](https://www.curotec.com/services/technologies/laravel)** -- **[DevSquad](https://devsquad.com/hire-laravel-developers)** -- **[Redberry](https://redberry.international/laravel-development)** -- **[Active Logic](https://activelogic.com)** +Apply all migrations to the database: -## Contributing +```bash +php artisan migrate +``` -Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). +**Note:** this step has to be redone every time a new database migration is written. -## Code of Conduct +## Development -In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). -## Security Vulnerabilities +### Dev Server -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. +To start the Laravel dev server, run this *inside* the Docker container: -## License +```bash +composer run dev +``` -The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). +Then you can go to http://localhost:8000 in your browser, like it says. The site will live update any time you make changes. + +### Changing Docker Configs + +If you change the Dockerfile, run this *outside* the Docker container: + +```bash +docker compose up --build -d +``` + +If you change the docker-compose.yml file, run this *outside* the Docker container: + +```bash +docker compose restart +``` \ No newline at end of file diff --git a/composer.json b/composer.json index 7c7a9fd..2c38b11 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ ], "dev": [ "Composer\\Config::disableProcessTimeout", - "npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others" + "npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve --host=0.0.0.0\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others" ], "test": [ "@php artisan config:clear --ansi", diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7b7b6e4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,47 @@ +version: '3.8' + +services: + laravel: + build: + context: . + dockerfile: Dockerfile + volumes: + - .:/var/www/html + environment: + DB_CONNECTION: pgsql + DB_HOST: db + DB_PORT: 5432 + DB_DATABASE: laravel + DB_USERNAME: laravel + DB_PASSWORD: secret + ports: + - "5173:5173" + - "8000:8000" + networks: + - laravel-network + depends_on: + db: + condition: service_healthy + + db: + image: postgres:16 + volumes: + - postgres_data:/var/lib/postgresql/data + environment: + POSTGRES_USER: laravel + POSTGRES_PASSWORD: secret + POSTGRES_DB: laravel + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"] + interval: 5s + timeout: 5s + retries: 5 + networks: + - laravel-network + +volumes: + postgres_data: + +networks: + laravel-network: + driver: bridge \ No newline at end of file diff --git a/package.json b/package.json index af0db45..cbda71a 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type": "module", "scripts": { "build": "vite build", - "dev": "vite" + "dev": "vite --host=0.0.0.0" }, "devDependencies": { "@tailwindcss/vite": "^4.0.0",