From 275607131e07cc9babed58b26f21c3547947d840 Mon Sep 17 00:00:00 2001 From: George Daneke Date: Wed, 19 Jun 2024 23:25:47 +0300 Subject: [PATCH] added docker --- .env.example | 6 ++-- Dockerfile | 18 +++++++++++ README.md | 57 +++++++++++++++++++++++++++++---- docker-compose.wip.yml | 63 ++++++++++++++++++++++++++++++++++++ docker-compose.yml | 72 ++++++------------------------------------ phpunit.xml | 1 + 6 files changed, 146 insertions(+), 71 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.wip.yml diff --git a/.env.example b/.env.example index 7b49625..ff16355 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,7 @@ -APP_NAME=Laravel +APP_NAME=Inventory APP_ENV=local -APP_KEY= -APP_DEBUG=true +APP_KEY=base64:osYDLJr0A9kWYU+Qfut/BPUdXc8QSoGWtdbQIZx8id8= +APP_DEBUG=false APP_TIMEZONE=UTC APP_URL=http://localhost diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c64ce98 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM dunglas/frankenphp + +ENV APP_ENV=production + +RUN install-php-extensions \ + pdo_mysql \ + gd \ + intl \ + zip \ + opcache + +COPY . /app + +#WORKDIR /app +# +#HEALTHCHECK CMD curl --fail http://localhost:80/login || exit 1 +# +#ENTRYPOINT ["php", "artisan", "octane:frankenphp"] diff --git a/README.md b/README.md index b075df0..1fd09f1 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,45 @@

-## How to run locally if you have PHP 8.3 and composer installed +## How to run with Docker + +**Command list** + +In order to run the project with Docker you need to have Docker installed on your machine. If you don't have Docker installed you can follow the instructions on the official Docker website: https://docs.docker.com/get-docker/ + +The following commands will clone the repository + + git clone https://github.com/flatroy/stupid-inventory-laravel.git + +Go to the project directory + + cd stupid-inventory-laravel + +Copy the .env.example file to .env file with the following command or manually copy the file and rename it to .env + + cp .env.example .env + +Run the following command to install the dependencies for PHP + + docker run --rm -it -v $PWD:/app composer:latest install --ignore-platform-req=ext-intl + +Run the following command to install the dependencies for Node.js (only to build the frontend, you can skip this step if you don't want to build the frontend with Docker) + + docker run --rm -it -v $PWD:/app node:latest /bin/sh -c "cd /app && npm install -g bun && bun install && bun run build" + +Run the following command to build the Docker image or if you want to use docker compose you can skip this steps + + docker build -t stupid-inventory . + docker run -v $PWD:/app -p 4431:443 -it --rm --name my-stupid-inventory stupid-inventory + +If you want to use docker compose you can run the following command + + docker-compose up -d + + +Still some part are in WIP status: I need to add queue worker to docker-compose.yml as well as building the frontend within docker + +## How to run locally (if you have PHP 8.3 and composer installed) **Command list** @@ -22,15 +60,21 @@ npm run build php artisan serve -## How to run with Docker - -WIP ## TODO list - [x] Items - add/edit/delete/import/export - [x] Locations - add/edit/delete - [x] Users/Teams/Invite to team/Registration/Login - via Laravel Jetstream -- [ ] Add Dockerfile and docker-compose.yml - https://serversideup.net/open-source/docker-php/ +- [ ] Add Dockerfile and docker-compose.yml - https://serversideup.net/open-source/docker-php/ or dunglas/frankenphp + - [x] Add Dockerfile + - [ ] Add docker-compose.yml + - [ ] Add queue worker to docker-compose.yml + - [ ] Add building frontend with docker + - [ ] Add docker-compose.yml for production + - [ ] Add docker-compose.yml for development + - [ ] Add docker-compose.yml for testing + - [ ] Add docker-compose.yml for CI/CD + - [ ] Add mounting volumes for sqlite database file and storage - [ ] Add more features - [ ] Add tags to items - https://filamentphp.com/plugins/filament-spatie-tags - [ ] Add attachments to items - https://filamentphp.com/plugins/filament-spatie-media-library @@ -38,8 +82,9 @@ WIP - [ ] Add QR code to items - [x] Add multi-tenancy support - https://filamentphp.com/docs/3.x/panels/tenancy - [ ] Add better import/export of items with relation to locations - - [ ] Add Laravel Octane + - [x] Add Laravel Octane - [ ] Add Laravel Pulse + - [x] Add nice Dashboard for home-screen ## Contributing diff --git a/docker-compose.wip.yml b/docker-compose.wip.yml new file mode 100644 index 0000000..421dec2 --- /dev/null +++ b/docker-compose.wip.yml @@ -0,0 +1,63 @@ +services: + php: + image: serversideup/php:8.3-fpm-nginx + ports: + - '9000:8000' + - '8080:8080' + - '8443:8443' + environment: + PHP_FPM_POOL_NAME: "easy-inventory_php" + PHP_OPCACHE_ENABLE: 1 + SSL_MODE: "mix" + AUTORUN_ENABLED: "false" + volumes: + - .:/var/www/html +# networks: +# - sail +# depends_on: +# - mysql +# mysql: +# image: 'mysql/mysql-server:8.0' +# ports: +# - '${FORWARD_DB_PORT:-3306}:3306' +# environment: +# MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' +# MYSQL_ROOT_HOST: '%' +# MYSQL_DATABASE: '${DB_DATABASE}' +# MYSQL_USER: '${DB_USERNAME}' +# MYSQL_PASSWORD: '${DB_PASSWORD}' +# MYSQL_ALLOW_EMPTY_PASSWORD: 1 +# volumes: +# - 'sail-mysql:/var/lib/mysql' +# networks: +# - sail +# healthcheck: +# test: ['CMD', 'mysqladmin', 'ping', '-p${DB_PASSWORD}'] +# retries: 3 +# timeout: 5s +# +# queue: +# image: serversideup/php:8.3-fpm-nginx +# command: ["php", "/var/www/html/artisan", "queue:work", "--tries=3"] +# environment: +# PHP_FPM_POOL_NAME: "my-app_queue" +# volumes: +# - .:/var/www/html +# +# task: +# image: serversideup/php:8.3-fpm-nginx +# command: ["php", "/var/www/html/artisan", "schedule:work"] +# environment: +# PHP_FPM_POOL_NAME: "my-app_task" +# volumes: +# - .:/var/www/html + + +# +#networks: +# sail: +# driver: bridge +#volumes: +# sail-mysql: +# driver: local + diff --git a/docker-compose.yml b/docker-compose.yml index 120e7f7..0dbf2a7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,63 +1,11 @@ services: - php: - image: serversideup/php:8.3-fpm-nginx - ports: - - '9000:8000' - - '8080:8080' - - '8443:8443' - environment: - PHP_FPM_POOL_NAME: "easy-inventory_php" - PHP_OPCACHE_ENABLE: 1 - SSL_MODE: "mix" - AUTORUN_ENABLED: "false" - volumes: - - .:/var/www/html -# networks: -# - sail -# depends_on: -# - mysql -# mysql: -# image: 'mysql/mysql-server:8.0' -# ports: -# - '${FORWARD_DB_PORT:-3306}:3306' -# environment: -# MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' -# MYSQL_ROOT_HOST: '%' -# MYSQL_DATABASE: '${DB_DATABASE}' -# MYSQL_USER: '${DB_USERNAME}' -# MYSQL_PASSWORD: '${DB_PASSWORD}' -# MYSQL_ALLOW_EMPTY_PASSWORD: 1 -# volumes: -# - 'sail-mysql:/var/lib/mysql' -# networks: -# - sail -# healthcheck: -# test: ['CMD', 'mysqladmin', 'ping', '-p${DB_PASSWORD}'] -# retries: 3 -# timeout: 5s -# -# queue: -# image: serversideup/php:7.4-fpm -# command: ["php", "/var/www/html/artisan", "queue:work", "--tries=3"] -# environment: -# PHP_FPM_POOL_NAME: "my-app_queue" -# volumes: -# - .:/var/www/html -# -# task: -# image: serversideup/php:7.4-fpm -# command: ["php", "/var/www/html/artisan", "schedule:work"] -# environment: -# PHP_FPM_POOL_NAME: "my-app_task" -# volumes: -# - .:/var/www/html - - -# -#networks: -# sail: -# driver: bridge -#volumes: -# sail-mysql: -# driver: local - + frankenphp: + build: + context: . + dockerfile: Dockerfile + ports: + - "4431:443" + - "4431:443/udp" + - "801:80" + volumes: + - .:/app diff --git a/phpunit.xml b/phpunit.xml index 506b9a3..095232e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -29,5 +29,6 @@ +