Modular logistics and supply chain operating system (LSOS)
JavaScript driver-appfleet-managementfreight-managementinfrastructureinventory-managementlast-mile-deliverylogisticsondemandopen-sourceorder-managementroute-optimizationsupply-chain-managementtracking-and-monitoringtransport-management-systemtransportationwarehouse-management
v0.7.1 ~ Fleetbase console can now read in a runtime config
Ronald A. Richardson4dc976485301
diff --git a/.github/workflows/publish_docker.yml b/.github/workflows/publish_docker.ymlnew file mode 100644index 00000000..6bad5a6b--- /dev/null+++ b/.github/workflows/publish_docker.yml@@ -0,0 +1,39 @@+name: Publish Fleetbase Docker Images++on:+ push:+ tags:+ - 'v*' # Runs on version tags like v1.2.3+ workflow_dispatch: # Allows manual run++jobs:+ docker-release:+ name: Build and Push Docker Images+ runs-on: ubuntu-latest++ env:+ REGISTRY: fleetbase+ VERSION: ${{ github.ref_name || 'manual' }}++ steps:+ - name: Checkout Repo+ uses: actions/checkout@v3++ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@v2++ - name: Log in to Docker Hub+ uses: docker/login-action@v3+ with:+ username: ${{ secrets.DOCKER_HUB_USERNAME }}+ password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}++ - name: Build and Push Console & API Images+ uses: docker/bake-action@v2+ with:+ push: true+ targets: |+ fleetbase-console+ fleetbase-api+ files: |+ ./docker-bake.hcl\ No newline at end of filediff --git a/console/Dockerfile.server-build b/console/Dockerfilesimilarity index 82%rename from console/Dockerfile.server-buildrename to console/Dockerfileindex b12919ad..3b5e1425 100644--- a/console/Dockerfile.server-build+++ b/console/Dockerfile@@ -6,19 +6,19 @@ WORKDIR /console# Create the pnpm directory and set the PNPM_HOME environment variableRUN mkdir -p ~/.pnpm-ENV PNPM_HOME /root/.pnpm+ENV PNPM_HOME=/root/.pnpm# Set environmentARG ENVIRONMENT=production# Add the pnpm global bin to the PATH-ENV PATH /root/.pnpm/bin:$PATH+ENV PATH=/root/.pnpm/bin:$PATH# Copy pnpm-lock.yaml (or package.json) into the directory /console in the container-COPY console/package.json console/pnpm-lock.yaml ./+COPY package.json pnpm-lock.yaml ./# Copy over .npmrc if applicable-COPY console/.npmr[c] ./+COPY .npmr[c] ./# Install global dependenciesRUN npm install -g ember-cli pnpm@@ -33,7 +33,7 @@ RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hostsRUN pnpm install# Copy the console directory contents into the container at /console-COPY console .+COPY . .# Build the applicationRUN pnpm build --environment $ENVIRONMENT@@ -48,7 +48,7 @@ COPY --from=builder /console/dist /usr/share/nginx/htmlEXPOSE 4200# Use custom nginx.conf-COPY console/nginx.conf /etc/nginx/conf.d/default.conf+COPY nginx.conf /etc/nginx/conf.d/default.conf# Start Nginx serverCMD ["nginx", "-g", "daemon off;"]\ No newline at end of filediff --git a/console/Dockerfile.static-build b/console/Dockerfile.static-builddeleted file mode 100644index 5822a3c6..00000000--- a/console/Dockerfile.static-build+++ /dev/null@@ -1,57 +0,0 @@-# ---- Build Stage -----FROM node:18.15.0-alpine--# Set the working directory in the container to /console-WORKDIR /console--# Create the pnpm directory and set the PNPM_HOME environment variable-RUN mkdir -p ~/.pnpm-ENV PNPM_HOME /root/.pnpm--# Set environment-ARG ENVIRONMENT=production--# Add the pnpm global bin to the PATH-ENV PATH /root/.pnpm/bin:$PATH--# Copy pnpm-lock.yaml (or package.json) into the directory /console in the container-COPY console/package.json console/pnpm-lock.yaml ./--# Copy over .npmrc if applicable-COPY console/.npmr[c] ./--# Install global dependencies-RUN npm install -g ember-cli pnpm--# Install git-RUN apk update && apk add git openssh-client--# Trust GitHub's RSA host key-RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts--# Install app dependencies-RUN pnpm install--# Copy the console directory contents into the container at /console-COPY console .--# Build the application-RUN pnpm build --environment $ENVIRONMENT--# # Make sure the build output is available in /console/dist-# RUN ls -la /console/dist--# # ---- Serve Stage -----# FROM nginx:alpine--# # Copy the built app to our served directory-# COPY --from=builder /console/dist /usr/share/nginx/html--# # Expose the port nginx is bound to-# EXPOSE 4201--# # Use custom nginx.conf-# COPY console/nginx.conf /etc/nginx/conf.d/default.conf--# # Start Nginx server-# CMD ["nginx", "-g", "daemon off;"]\ No newline at end of filediff --git a/console/app/app.js b/console/app/app.jsindex ab948fd0..f55f3c21 100644--- a/console/app/app.js+++ b/console/app/app.js@@ -4,6 +4,25 @@ import loadInitializers from 'ember-load-initializers';import config from '@fleetbase/console/config/environment';import loadExtensions from '@fleetbase/ember-core/utils/load-extensions';import mapEngines from '@fleetbase/ember-core/utils/map-engines';+import { set } from '@ember/object';+import { debug } from '@ember/debug';++async function loadRuntimeConfig() {+ try {+ const response = await fetch(`/fleetbase.config.json?_t=${Date.now()}`, { cache: 'no-cache' });+ if (!response.ok) {+ debug('No fleetbase.config.json found, using built-in config defaults');+ return;+ }++ const runtimeConfig = await response.json();+ for (const [path, value] of Object.entries(runtimeConfig)) {+ set(config, path, value);+ }+ } catch (e) {+ debug(`Failed to load runtime config : ${e.message}`);+ }+}export default class App extends Application {modulePrefix = config.modulePrefix;@@ -20,4 +39,11 @@ export default class App extends Application {}}-loadInitializers(App, config.modulePrefix);+document.addEventListener('DOMContentLoaded', async () => {+ await loadRuntimeConfig();+ loadInitializers(App, config.modulePrefix);++ let fleetbase = App.create();+ fleetbase.deferReadiness();+ fleetbase.boot();+});\ No newline at end of filediff --git a/console/config/environment.js b/console/config/environment.jsindex e8c76b0a..cea08556 100644--- a/console/config/environment.js+++ b/console/config/environment.js@@ -21,6 +21,7 @@ module.exports = function (environment) {},APP: {+ autoboot: false,extensions: asArray(getenv('EXTENSIONS')),},diff --git a/console/ember-cli-build.js b/console/ember-cli-build.jsindex 13e1c42b..14810409 100644--- a/console/ember-cli-build.js+++ b/console/ember-cli-build.js@@ -3,6 +3,7 @@/** eslint-disable node/no-unpublished-require */const EmberApp = require('ember-cli/lib/broccoli/ember-app');const FleetbaseExtensionsIndexer = require('fleetbase-extensions-indexer');+const Funnel = require('broccoli-funnel');const postcssImport = require('postcss-import');const postcssPresetEnv = require('postcss-preset-env');const postcssEach = require('postcss-each');@@ -11,6 +12,7 @@ const postcssConditionals = require('postcss-conditionals-renewed');const postcssAtRulesVariables = require('postcss-at-rules-variables');const autoprefixer = require('autoprefixer');const tailwind = require('tailwindcss');+const environment = process.env.EMBER_ENV;module.exports = function (defaults) {const app = new EmberApp(defaults, {@@ -59,19 +61,13 @@ module.exports = function (defaults) {});let extensions = new FleetbaseExtensionsIndexer();+ let config;+ if (environment === 'development') {+ config = new Funnel('.', {+ files: ['fleetbase.config.json'],+ destDir: '/',+ });+ }- // Use `app.import` to add additional libraries to the generated- // output files.- //- // If you need to use different assets in different- // environments, specify an object as the first parameter. That- // object's keys should be the environment name and the values- // should be the asset to use in that environment.- //- // If the library that you are including contains AMD or ES6- // modules that you would like to import into your application- // please specify an object with the list of modules as keys- // along with the exports of each module as its value.-- return app.toTree([extensions]);+ return app.toTree([extensions, config].filter(Boolean));};diff --git a/console/nginx.conf b/console/nginx.confindex 25d323e0..95c2064f 100644--- a/console/nginx.conf+++ b/console/nginx.conf@@ -6,4 +6,18 @@ server {root /usr/share/nginx/html;try_files $uri $uri/ /index.html =404;}++ # Serve runtime config with no cache+ location = /fleetbase.config.json {+ root /usr/share/nginx/html;+ default_type application/json;+ add_header Cache-Control "no-cache, no-store, must-revalidate";+ add_header Pragma "no-cache";+ add_header Expires 0;+ try_files /fleetbase.config.json @config_fallback;+ }++ location @config_fallback {+ return 200 '{}';+ }}diff --git a/console/package.json b/console/package.jsonindex df01bf3b..ab79cb4d 100644--- a/console/package.json+++ b/console/package.json@@ -1,6 +1,6 @@{"name": "@fleetbase/console",- "version": "0.7.0",+ "version": "0.7.1","private": true,"description": "Modular logistics and supply chain operating system (LSOS)","repository": "https://github.com/fleetbase/fleetbase",diff --git a/docker-bake.hcl b/docker-bake.hclindex 0d0848f5..349b363d 100644--- a/docker-bake.hcl+++ b/docker-bake.hcl@@ -9,6 +9,10 @@ group "default" {targets = ["app", "app-httpd"]}+group "release" {+ targets = ["fleetbase-console", "fleetbase-api"]+}+target "app" {name = "app-${tgt}"@@ -48,4 +52,26 @@ target "app-httpd" {GCP ? "${REGISTRY}/app-httpd:%s" : "${REGISTRY}:app-httpd-%s",compact(["latest", VERSION])) : []+}++target "fleetbase-console" {+ context = "./console"+ dockerfile = "Dockerfile"+ platforms = ["linux/amd64"]++ tags = notequal("", REGISTRY) ? formatlist(+ "${REGISTRY}/fleetbase-console:%s",+ compact(["latest", VERSION])+ ) : []+}++target "fleetbase-api" {+ context = "./"+ dockerfile = "docker/Dockerfile"+ platforms = ["linux/amd64"]++ tags = notequal("", REGISTRY) ? formatlist(+ "${REGISTRY}/fleetbase-api:%s",+ compact(["latest", VERSION])+ ) : []}\ No newline at end of filediff --git a/docker-compose.yml b/docker-compose.ymlindex c616f127..7ec71bd7 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -53,8 +53,8 @@ services:console:build:- context: .- dockerfile: console/Dockerfile.server-build+ context: ./console+ dockerfile: Dockerfileargs:ENVIRONMENT: developmentports:diff --git a/docker/Dockerfile b/docker/Dockerfileindex d9c95ac0..a8f7c31c 100644--- a/docker/Dockerfile+++ b/docker/Dockerfile@@ -80,6 +80,9 @@ ENV OCTANE_SERVER=frankenphpARG ENVIRONMENT=productionENV APP_ENV=$ENVIRONMENT+# Setup github auth+ARG GITHUB_AUTH_KEY+# Copy CaddyfileCOPY --chown=www-data:www-data ./Caddyfile $CADDYFILE_PATH@@ -89,6 +92,9 @@ RUN mkdir -p /fleetbase/api && mkdir -p /fleetbase/console && chown -R www-data:# Set working directoryWORKDIR /fleetbase/api+# If GITHUB_AUTH_KEY is provided, create auth.json with it+RUN if [ -n "$GITHUB_AUTH_KEY" ]; then echo "{\"github-oauth\": {\"github.com\": \"$GITHUB_AUTH_KEY\"}}" > auth.json; fi+# Prepare composer cache directoryRUN mkdir -p /var/www/.cache/composer && chown -R www-data:www-data /var/www/.cache/composer