Skip to content

Modular logistics and supply chain operating system (LSOS)

Improvements to docker setups

Ronald A. Richardson86da1bd09558
diff --git a/api/EXPECTED_HASH b/api/EXPECTED_HASH
new file mode 100644
index 00000000..506cea38
--- /dev/null
+++ b/api/EXPECTED_HASH
@@ -0,0 +1 @@
+ae89600ae6433349b62a31a80d8738faf771d0b0
diff --git a/docker-bake.hcl b/docker-bake.hcl
index 349b363d..0275c3a5 100644
--- a/docker-bake.hcl
+++ b/docker-bake.hcl
@@ -68,6 +68,7 @@ target "fleetbase-console" {
target "fleetbase-api" {
context = "./"
dockerfile = "docker/Dockerfile"
+ target = "app-release"
platforms = ["linux/amd64"]
tags = notequal("", REGISTRY) ? formatlist(
diff --git a/docker-compose.yml b/docker-compose.yml
index 7ec71bd7..7037dfce 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -31,13 +31,20 @@ services:
SOCKETCLUSTER_WORKERS: 10
SOCKETCLUSTER_BROKERS: 10
+ scheduler:
+ image: fleetbase/fleetbase-api:v0.7.0
+ command: ["go-crond", "--verbose", "root:./crontab"]
+ environment:
+ DATABASE_URL: "mysql://root@database/fleetbase"
+ QUEUE_CONNECTION: redis
+ CACHE_DRIVER: redis
+ CACHE_PATH: /fleetbase/api/storage/framework/cache
+ CACHE_URL: tcp://cache
+ REDIS_URL: tcp://cache
+
queue:
- build:
- context: .
- dockerfile: docker/Dockerfile
- target: events-dev
- args:
- ENVIRONMENT: development
+ image: fleetbase/fleetbase-api:v0.7.0
+ command: ["php", "artisan", "queue:work"]
healthcheck:
test: ["CMD", "php", "artisan", "queue:status"]
interval: 30s
@@ -52,21 +59,14 @@ services:
REDIS_URL: tcp://cache
console:
- build:
- context: ./console
- dockerfile: Dockerfile
- args:
- ENVIRONMENT: development
+ image: fleetbase/fleetbase-console:v0.7.0
ports:
- "4200:4200"
+ volumes:
+ - ./docker/fleetbase.config.json:/usr/share/nginx/html/fleetbase.config.json
application:
- build:
- context: .
- dockerfile: docker/Dockerfile
- target: app-dev
- args:
- ENVIRONMENT: development
+ image: fleetbase/fleetbase-api:v0.7.0
environment:
ENVIRONMENT: development
DATABASE_URL: "mysql://root@database/fleetbase"
diff --git a/docker/Dockerfile b/docker/Dockerfile
index a8f7c31c..2c431eaf 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -75,6 +75,7 @@ ENV QUEUE_CONNECTION=redis
ENV CADDYFILE_PATH=/fleetbase/Caddyfile
ENV CONSOLE_PATH=/fleetbase/console
ENV OCTANE_SERVER=frankenphp
+ENV FLEETBASE_VERSION=0.7.1
# Set environment
ARG ENVIRONMENT=production
@@ -89,6 +90,16 @@ COPY --chown=www-data:www-data ./Caddyfile $CADDYFILE_PATH
# Create /fleetbase directory and set correct permissions
RUN mkdir -p /fleetbase/api && mkdir -p /fleetbase/console && chown -R www-data:www-data /fleetbase
+# Generate and store a UUID in .fleetbase-id
+RUN uuidgen > /fleetbase/api/.fleetbase-id
+
+# Export the same ID as an environment variable for use in the container
+RUN export FLEETBASE_INSTANCE_ID=$(cat /fleetbase/api/.fleetbase-id) && \
+ echo "FLEETBASE_INSTANCE_ID=$FLEETBASE_INSTANCE_ID" >> /etc/environment
+
+# Track commit hash
+RUN git rev-parse HEAD > /fleetbase/CURRENT_HASH
+
# Set working directory
WORKDIR /fleetbase/api
@@ -153,7 +164,12 @@ CMD ["php", "artisan", "queue:work"]
# Application dev stage
FROM base AS app-dev
ENTRYPOINT ["docker-php-entrypoint"]
-CMD ["sh", "-c", "php artisan octane:frankenphp --max-requests=250 --port=8000 --host=0.0.0.0 --watch"]
+CMD ["sh", "-c", "php artisan octane:frankenphp --max-requests=250 --port=8000 --host=0.0.0.0 --watch"]
+
+# Application release stage
+FROM base AS app-release
+ENTRYPOINT ["docker-php-entrypoint"]
+CMD ["sh", "-c", "php artisan octane:frankenphp --max-requests=250 --port=8000 --host=0.0.0.0"]
# Application stage
FROM base AS app
diff --git a/scripts/pre-commit-hook.sh b/scripts/pre-commit-hook.sh
new file mode 100644
index 00000000..51e3f0e6
--- /dev/null
+++ b/scripts/pre-commit-hook.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+CURRENT_HASH_FILE="./EXPECTED_HASH"
+CURRENT_HASH=$(git rev-parse HEAD)
+EXISTING_HASH=$(cat "$CURRENT_HASH_FILE" 2>/dev/null || echo "")
+
+if [ "$CURRENT_HASH" = "$EXISTING_HASH" ]; then
+ echo "✅ EXPECTED_HASH is already up to date."
+ exit 0
+fi
+
+echo "⚙️ Writing current commit hash to CURRENT_HASH..."
+echo "$CURRENT_HASH" > "$CURRENT_HASH_FILE"
+git add "$CURRENT_HASH_FILE"
\ No newline at end of file
diff --git a/scripts/setup-hooks.sh b/scripts/setup-hooks.sh
new file mode 100644
index 00000000..8ca29a2f
--- /dev/null
+++ b/scripts/setup-hooks.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+cp ./scripts/pre-commit-hook.sh .git/hooks/pre-commit
+chmod +x .git/hooks/pre-commit
+echo "✅ Git hook installed."
\ No newline at end of file