Attempting to use HBS to re-create the envoy file as needed in dev.

This commit is contained in:
mike12345567 2021-04-07 17:13:19 +01:00
parent 63135e3351
commit 482525187d
5 changed files with 22 additions and 4 deletions

1
.gitignore vendored
View File

@ -63,6 +63,7 @@ typings/
# dotenv environment variables file
.env
!hosting/.env
hosting/generated-envoy.dev.yaml
# parcel-bundler cache (https://parceljs.org/)
.cache

View File

@ -27,7 +27,7 @@ services:
restart: always
image: envoyproxy/envoy:v1.16-latest
volumes:
- ./envoy.dev.yaml:/etc/envoy/envoy.yaml
- ./generated-envoy.dev.yaml:/etc/envoy/envoy.yaml
ports:
- "${MAIN_PORT}:10000"
depends_on:

View File

@ -106,7 +106,7 @@ static_resources:
- endpoint:
address:
socket_address:
address: 172.17.0.1
address: {{ address }}
port_value: 4001
- name: builder-dev
@ -120,6 +120,6 @@ static_resources:
- endpoint:
address:
socket_address:
address: 172.17.0.1
address: {{ address }}
port_value: 3000

View File

@ -23,7 +23,9 @@
"publishdev": "lerna run publishdev",
"publishnpm": "yarn build && lerna publish --force-publish",
"restore": "npm run clean && npm run bootstrap && npm run build",
"nuke": "rimraf ~/.budibase && npm run restore && lerna run --parallel dev:stack:nuke",
"nuke": "npm run nuke:packages && npm run nuke:docker",
"nuke:packages": "npm run restore",
"nuke:docker": "lerna run --parallel dev:stack:nuke",
"clean": "lerna clean",
"kill-port": "kill-port 4001",
"dev": "yarn run kill-port && lerna link && lerna run --parallel dev:builder --concurrency 1",

View File

@ -2,6 +2,11 @@
const compose = require("docker-compose")
const path = require("path")
const fs = require("fs")
const { processStringSync } = require("@budibase/string-templates")
function isLinux() {
return process.platform !== "darwin" && process.platform !== "win32"
}
// This script wraps docker-compose allowing you to manage your dev infrastructure with simple commands.
const CONFIG = {
@ -17,6 +22,16 @@ const Commands = {
}
async function init() {
// generate envoy file, always do this incase it has changed
const hostingPath = path.join(process.cwd(), "..", "..", "hosting")
const envoyHbsPath = path.join(hostingPath, "envoy.dev.yaml.hbs")
const envoyOutputPath = path.join(hostingPath, "generated-envoy.dev.yaml")
const contents = fs.readFileSync(envoyHbsPath, "utf8")
const config = {
address: isLinux() ? "172.17.0.1" : "host.docker.internal",
}
fs.writeFileSync(envoyOutputPath, processStringSync(contents, config))
const envFilePath = path.join(process.cwd(), ".env")
if (fs.existsSync(envFilePath)) {
return