Compare commits

...

6 Commits

19 changed files with 293 additions and 115 deletions

3
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,3 @@
# These are supported funding model platforms
github: fleetbase

View File

@@ -0,0 +1,2 @@
#!/bin/bash
mv composer.json composer.prod.json && mv composer.dev.json composer.json && composer install && mv composer.json composer.dev.json && mv composer.prod.json composer.json

108
api/composer.dev.json Normal file
View File

@@ -0,0 +1,108 @@
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"fleetbase/core-api": "^1.0.9-alpha",
"fleetbase/fleetops-api": "^1.0.3-alpha",
"fleetbase/storefront-api": "^1.0.3-alpha",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.75",
"laravel/sanctum": "^2.11",
"laravel/tinker": "^2.5",
"league/flysystem-aws-s3-v3": "^1.0",
"maatwebsite/excel": "^3.1",
"phpoffice/phpspreadsheet": "^1.28",
"predis/predis": "^2.1",
"psr/http-factory-implementation": "*",
"textalk/websocket": "^1.6"
},
"require-dev": {
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"kitloong/laravel-migrations-generator": "^6.10",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^5.10",
"phpunit/phpunit": "^9.5.10"
},
"repositories": [
{
"type": "path",
"url": "../packages/core-api"
},
{
"type": "path",
"url": "../packages/fleetops-api"
},
{
"type": "path",
"url": "../packages/storefront-api"
}
],
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
],
"clear-logs": [
"rm -rf storage/logs/*.log",
"composer dump-autoload",
"chmod -R 777 storage",
"chmod -R 777 bootstrap/cache",
"chmod -R 777 resources"
],
"clean-logs": [
"composer run-script clear-logs"
],
"dock": [
"docker exec -it fleetbase_os_application_1 /usr/bin/tmux -u new"
],
"dock-server": [
"docker exec -it fleetbase_os_httpd_1 /bin/sh"
],
"tunnel": [
"ngrok http --region=ap --hostname=fleetbase.ap.ngrok.io 8000"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"php-http/discovery": true
}
},
"minimum-stability": "dev",
"prefer-stable": true
}

View File

@@ -6,9 +6,9 @@
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"fleetbase/core-api": "^1.0.6-alpha",
"fleetbase/fleetops-api": "^1.0.2-alpha",
"fleetbase/storefront-api": "^1.0.1-alpha",
"fleetbase/core-api": "^1.0.9-alpha",
"fleetbase/fleetops-api": "^1.0.3-alpha",
"fleetbase/storefront-api": "^1.0.3-alpha",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.75",

119
api/composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0c48f488648424e57133c3479ecf9d2b",
"content-hash": "9e942b73a0335025ddaace9e4a68b836",
"packages": [
{
"name": "aloha/twilio",
@@ -192,16 +192,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.272.0",
"version": "3.272.2",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "2448f5c4ffd0125fa86df6aa12d0a41aa2de68da"
"reference": "0c4cba74c79f9b44393c27721fa1fa9138c95387"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/2448f5c4ffd0125fa86df6aa12d0a41aa2de68da",
"reference": "2448f5c4ffd0125fa86df6aa12d0a41aa2de68da",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/0c4cba74c79f9b44393c27721fa1fa9138c95387",
"reference": "0c4cba74c79f9b44393c27721fa1fa9138c95387",
"shasum": ""
},
"require": {
@@ -281,9 +281,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.272.0"
"source": "https://github.com/aws/aws-sdk-php/tree/3.272.2"
},
"time": "2023-06-08T18:21:03+00:00"
"time": "2023-06-12T18:21:59+00:00"
},
{
"name": "aws/aws-sdk-php-laravel",
@@ -2002,16 +2002,16 @@
},
{
"name": "fleetbase/core-api",
"version": "1.0.6-alpha",
"version": "1.0.9-alpha",
"source": {
"type": "git",
"url": "https://github.com/fleetbase/core-api.git",
"reference": "20890b9623c0ea8aa416d711fb45c15738025b6f"
"reference": "c08873f3b43f969039c6b9694c313057fe1eba46"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fleetbase/core-api/zipball/20890b9623c0ea8aa416d711fb45c15738025b6f",
"reference": "20890b9623c0ea8aa416d711fb45c15738025b6f",
"url": "https://api.github.com/repos/fleetbase/core-api/zipball/c08873f3b43f969039c6b9694c313057fe1eba46",
"reference": "c08873f3b43f969039c6b9694c313057fe1eba46",
"shasum": ""
},
"require": {
@@ -2085,35 +2085,29 @@
],
"support": {
"issues": "https://github.com/fleetbase/core-api/issues",
"source": "https://github.com/fleetbase/core-api/tree/v1.0.6-alpha"
"source": "https://github.com/fleetbase/core-api/tree/v1.0.9-alpha"
},
"funding": [
{
"url": "https://github.com/fleetbase",
"type": "github"
}
],
"time": "2023-06-09T04:36:21+00:00"
"time": "2023-06-13T15:43:51+00:00"
},
{
"name": "fleetbase/fleetops-api",
"version": "1.0.2-alpha",
"version": "1.0.3-alpha",
"source": {
"type": "git",
"url": "https://github.com/fleetbase/fleetops-api.git",
"reference": "a6a9eab63eb651f8833874c2ee34739c4b8f1d9b"
"reference": "92f468d6e62bac2672b7a339f2053428fe997ea6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fleetbase/fleetops-api/zipball/a6a9eab63eb651f8833874c2ee34739c4b8f1d9b",
"reference": "a6a9eab63eb651f8833874c2ee34739c4b8f1d9b",
"url": "https://api.github.com/repos/fleetbase/fleetops-api/zipball/92f468d6e62bac2672b7a339f2053428fe997ea6",
"reference": "92f468d6e62bac2672b7a339f2053428fe997ea6",
"shasum": ""
},
"require": {
"barryvdh/laravel-dompdf": "^2.0",
"brick/geo": "0.7.2",
"cknow/laravel-money": "^7.1",
"fleetbase/core-api": "^1.0.0-alpha",
"fleetbase/core-api": "^1.0.9-alpha",
"geocoder-php/google-maps-places-provider": "^1.4",
"giggsey/libphonenumber-for-php": "^8.13",
"league/geotools": "^1.1.0",
@@ -2167,33 +2161,27 @@
],
"support": {
"issues": "https://github.com/fleetbase/fleetops-api/issues",
"source": "https://github.com/fleetbase/fleetops-api/tree/v1.0.2-alpha"
"source": "https://github.com/fleetbase/fleetops-api/tree/v1.0.3-alpha"
},
"funding": [
{
"url": "https://github.com/fleetbase",
"type": "github"
}
],
"time": "2023-06-08T10:35:17+00:00"
"time": "2023-06-13T15:46:57+00:00"
},
{
"name": "fleetbase/storefront-api",
"version": "1.0.1-alpha",
"version": "1.0.3-alpha",
"source": {
"type": "git",
"url": "https://github.com/fleetbase/storefront-api.git",
"reference": "0d0dee2b8a173757e0f4e5c4e12c98d6d6dda37e"
"reference": "249923de7168805de25012032fb0ef5120fb6fea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fleetbase/storefront-api/zipball/0d0dee2b8a173757e0f4e5c4e12c98d6d6dda37e",
"reference": "0d0dee2b8a173757e0f4e5c4e12c98d6d6dda37e",
"url": "https://api.github.com/repos/fleetbase/storefront-api/zipball/249923de7168805de25012032fb0ef5120fb6fea",
"reference": "249923de7168805de25012032fb0ef5120fb6fea",
"shasum": ""
},
"require": {
"fleetbase/core-api": "^1.0.0-alpha",
"fleetbase/fleetops-api": "^1.0.0-alpha",
"fleetbase/core-api": "^1.0.9-alpha",
"fleetbase/fleetops-api": "^1.0.3-alpha",
"geocoder-php/google-maps-places-provider": "^1.4",
"laravel-notification-channels/apn": "^3.8",
"laravel-notification-channels/fcm": "^2.7",
@@ -2251,15 +2239,9 @@
],
"support": {
"issues": "https://github.com/fleetbase/storefront-api/issues",
"source": "https://github.com/fleetbase/storefront-api/tree/v1.0.1-alpha"
"source": "https://github.com/fleetbase/storefront-api/tree/v1.0.3-alpha"
},
"funding": [
{
"url": "https://github.com/fleetbase",
"type": "github"
}
],
"time": "2023-05-26T04:39:13+00:00"
"time": "2023-06-13T15:50:51+00:00"
},
{
"name": "fruitcake/laravel-cors",
@@ -2741,16 +2723,16 @@
},
{
"name": "giggsey/libphonenumber-for-php",
"version": "8.13.13",
"version": "8.13.14",
"source": {
"type": "git",
"url": "https://github.com/giggsey/libphonenumber-for-php.git",
"reference": "a8996558d694b1437678d27de80e37620367b8de"
"reference": "31b94ef2aa349b76bb725f375e9cfa2e398a1620"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/giggsey/libphonenumber-for-php/zipball/a8996558d694b1437678d27de80e37620367b8de",
"reference": "a8996558d694b1437678d27de80e37620367b8de",
"url": "https://api.github.com/repos/giggsey/libphonenumber-for-php/zipball/31b94ef2aa349b76bb725f375e9cfa2e398a1620",
"reference": "31b94ef2aa349b76bb725f375e9cfa2e398a1620",
"shasum": ""
},
"require": {
@@ -2809,7 +2791,7 @@
"issues": "https://github.com/giggsey/libphonenumber-for-php/issues",
"source": "https://github.com/giggsey/libphonenumber-for-php"
},
"time": "2023-06-05T07:39:05+00:00"
"time": "2023-06-13T08:08:40+00:00"
},
{
"name": "giggsey/locale",
@@ -3897,16 +3879,16 @@
},
{
"name": "kreait/firebase-php",
"version": "6.9.5",
"version": "6.9.6",
"source": {
"type": "git",
"url": "https://github.com/kreait/firebase-php.git",
"reference": "e64ce87a2d3be0acef91c33aea6269bbd528b12f"
"reference": "d6592be9b27a7c0b13f484f5af494e278901e441"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/kreait/firebase-php/zipball/e64ce87a2d3be0acef91c33aea6269bbd528b12f",
"reference": "e64ce87a2d3be0acef91c33aea6269bbd528b12f",
"url": "https://api.github.com/repos/kreait/firebase-php/zipball/d6592be9b27a7c0b13f484f5af494e278901e441",
"reference": "d6592be9b27a7c0b13f484f5af494e278901e441",
"shasum": ""
},
"require": {
@@ -3926,7 +3908,6 @@
"mtdowling/jmespath.php": "^2.6.1",
"php": "^7.4|^8.0",
"psr/cache": "^1.0.1|^2.0|^3.0",
"psr/http-message": "^1.0.1",
"psr/log": "^1.1|^2.0|^3.0",
"riverline/multipart-parser": "^2.0.8",
"symfony/polyfill-php80": "^1.23",
@@ -3987,7 +3968,7 @@
"type": "github"
}
],
"time": "2023-01-27T09:30:40+00:00"
"time": "2023-06-10T06:44:56+00:00"
},
{
"name": "kreait/firebase-tokens",
@@ -14109,16 +14090,16 @@
},
{
"name": "fakerphp/faker",
"version": "v1.22.0",
"version": "v1.23.0",
"source": {
"type": "git",
"url": "https://github.com/FakerPHP/Faker.git",
"reference": "f85772abd508bd04e20bb4b1bbe260a68d0066d2"
"reference": "e3daa170d00fde61ea7719ef47bb09bb8f1d9b01"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FakerPHP/Faker/zipball/f85772abd508bd04e20bb4b1bbe260a68d0066d2",
"reference": "f85772abd508bd04e20bb4b1bbe260a68d0066d2",
"url": "https://api.github.com/repos/FakerPHP/Faker/zipball/e3daa170d00fde61ea7719ef47bb09bb8f1d9b01",
"reference": "e3daa170d00fde61ea7719ef47bb09bb8f1d9b01",
"shasum": ""
},
"require": {
@@ -14171,9 +14152,9 @@
],
"support": {
"issues": "https://github.com/FakerPHP/Faker/issues",
"source": "https://github.com/FakerPHP/Faker/tree/v1.22.0"
"source": "https://github.com/FakerPHP/Faker/tree/v1.23.0"
},
"time": "2023-05-14T12:31:37+00:00"
"time": "2023-06-12T08:44:38+00:00"
},
{
"name": "filp/whoops",
@@ -15087,16 +15068,16 @@
},
{
"name": "phpunit/phpunit",
"version": "9.6.8",
"version": "9.6.9",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "17d621b3aff84d0c8b62539e269e87d8d5baa76e"
"reference": "a9aceaf20a682aeacf28d582654a1670d8826778"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/17d621b3aff84d0c8b62539e269e87d8d5baa76e",
"reference": "17d621b3aff84d0c8b62539e269e87d8d5baa76e",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a9aceaf20a682aeacf28d582654a1670d8826778",
"reference": "a9aceaf20a682aeacf28d582654a1670d8826778",
"shasum": ""
},
"require": {
@@ -15170,7 +15151,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.8"
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.9"
},
"funding": [
{
@@ -15186,7 +15167,7 @@
"type": "tidelift"
}
],
"time": "2023-05-11T05:14:45+00:00"
"time": "2023-06-11T06:13:56+00:00"
},
{
"name": "sebastian/cli-parser",

Submodule console updated: 1c955bb8a0...60f97028c6

View File

@@ -38,14 +38,14 @@ services:
ENVIRONMENT: development
application:
volumes:
- .:/var/www/html
build:
context: .
dockerfile: docker/Dockerfile
target: app-dev
args:
ENVIRONMENT: development
ports:
- "8000:80"
environment:
DATABASE_URL: "mysql://root@database/fleetbase"
CACHE_DRIVER: redis
@@ -59,17 +59,3 @@ services:
depends_on:
- database
- cache
httpd:
volumes:
- ./api/storage:/var/www/html/api/storage
build:
context: .
dockerfile: docker/httpd/Dockerfile
ports:
- "8000:80"
depends_on:
- application
volumes:
storage:

View File

@@ -8,9 +8,9 @@ RUN mkdir -p /usr/src/php/ext \
# Install required packages and PHP extensions
RUN apt-get update \
&& apt-get install -y git unzip libzip-dev libgd-dev libfreetype6-dev libjpeg62-turbo-dev libpng-dev \
&& apt-get install -y nano git unzip libzip-dev libgd-dev libfreetype6-dev libjpeg62-turbo-dev libpng-dev \
imagemagick libmagickwand-dev --no-install-recommends libmemcached-dev libgeos-dev libgmp-dev \
default-mysql-client libicu-dev tmux \
default-mysql-client libicu-dev tmux nginx dnsutils \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& docker-php-ext-configure gd --with-external-gd \
@@ -19,6 +19,9 @@ RUN apt-get update \
&& pecl install redis-4.3.0 memcached-3.1.3 \
&& docker-php-ext-enable redis memcached opcache bcmath
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Update PHP configurations
RUN sed -e 's/^expose_php.*/expose_php = Off/' "$PHP_INI_DIR/php.ini-production" > "$PHP_INI_DIR/php.ini" \
&& sed -i -e 's/^upload_max_filesize.*/upload_max_filesize = 600M/' -e 's/^post_max_size.*/post_max_size = 0/' \
@@ -30,29 +33,41 @@ RUN curl -L https://github.com/springload/ssm-parent/releases/download/v1.4.3/ss
&& rm /tmp/ssm-parent.tar.gz
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# For development only
WORKDIR /var/www/html
COPY --chown=www-data:nogroup packages ./
# Setup application
WORKDIR /var/www/html/api
# Copy application files
COPY --chown=www-data:www-data api ./
COPY --chown=www-data:nogroup api ./
RUN chown -R www-data:www-data /var/www/html/api
RUN chown -R www-data:www-data /var/www/html/api/bootstrap/cache
RUN chmod -R 755 /var/www/html/api/storage
RUN chmod -R 755 /var/www/html/api/bootstrap/cache
RUN mkdir -p ./storage/logs/ && ln -sf /dev/stdout ./storage/logs/laravel-$(date +'%Y-%m-%d').log
USER www-data
# Install Composer dependencies
RUN composer install --no-dev --no-scripts --no-autoloader
RUN composer install
RUN composer dumpautoload
# Continue
USER root
WORKDIR /
# Copy nginx config
COPY nginx.conf /etc/nginx/sites-enabled/default
# Copy the startup script into the Docker image
COPY startup.sh /startup.sh
# Make sure the script is executable
RUN chmod +x /startup.sh
# Set environment
ARG ENVIRONMENT=production
ENV APP_ENV=$ENVIRONMENT
# Set workdir to application
WORKDIR /var/www/html/api
# Scheduler base stage
FROM base as scheduler-base
@@ -74,12 +89,13 @@ CMD ["go-crond", "--verbose", "--no-auto", "root:./crontab"]
# Application dev stage
FROM base as app-dev
ENTRYPOINT ["docker-php-entrypoint"]
CMD ["php-fpm"]
EXPOSE 80
CMD ["/startup.sh"]
# Events stage
FROM base as events
ENTRYPOINT ["/sbin/ssm-parent", "-c", ".ssm-parent.yaml", "run", "--", "docker-php-entrypoint"]
CMD ["php", "artisan", "queue:work", "events"]
CMD ["php", "artisan", "queue:work", "events"]2
# Jobs stage
FROM base as jobs
@@ -89,4 +105,5 @@ CMD ["php", "artisan", "queue:work", "sqs"]
# Application stage
FROM base as app
ENTRYPOINT ["/sbin/ssm-parent", "-c", ".ssm-parent.yaml", "run", "--", "docker-php-entrypoint"]
CMD ["php-fpm"]
EXPOSE 80
CMD ["/startup.sh"]

46
nginx.conf Normal file
View File

@@ -0,0 +1,46 @@
server {
listen 80;
server_name localhost;
root /var/www/html/api/public;
# hide nginx version for security purposes
server_tokens off;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error_log;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location /uploads {
alias /var/www/html/api/storage/app/uploads;
autoindex on;
try_files $uri $uri/ /index.php?$query_string;
}
location /storage {
alias /var/www/html/api/storage/app/public;
autoindex on;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass application:9000;
fastcgi_index index.php;
}
}

35
startup.sh Normal file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
# Start PHP-FPM in the background
php-fpm -D
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start php-fpm: $status"
exit $status
fi
# Start Nginx in the foreground
nginx -g "daemon off;"
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start nginx: $status"
exit $status
fi
# Naive check runs checks once a minute to see if either of the processes exited.
while sleep 60; do
ps aux | grep php-fpm | grep -q -v grep
PROCESS_1_STATUS=$?
ps aux |grep nginx |grep -q -v grep
PROCESS_2_STATUS=$?
if [ $PROCESS_1_STATUS -ne 0 ]; then
echo "PHP-FPM process has already exited."
exit 1
fi
if [ $PROCESS_2_STATUS -ne 0 ]; then
echo "Nginx process has already exited."
exit 1
fi
done