added script to build frontend so it can add version info to the index.html file w/ burnettk
This commit is contained in:
parent
79a0505ddb
commit
f00b2e9f7d
|
@ -66,7 +66,7 @@ jobs:
|
||||||
|
|
||||||
- name: Write app version info
|
- name: Write app version info
|
||||||
working-directory: spiffworkflow-frontend
|
working-directory: spiffworkflow-frontend
|
||||||
run: echo $DOCKER_METADATA_OUTPUT_JSON | jq '.labels' > app_version.json
|
run: echo $DOCKER_METADATA_OUTPUT_JSON | jq '.labels' > version_info.json
|
||||||
- name: Build and push Frontend Docker image
|
- name: Build and push Frontend Docker image
|
||||||
uses: docker/build-push-action@v4.0.0
|
uses: docker/build-push-action@v4.0.0
|
||||||
with:
|
with:
|
||||||
|
@ -110,7 +110,7 @@ jobs:
|
||||||
|
|
||||||
- name: Write app version info
|
- name: Write app version info
|
||||||
working-directory: spiffworkflow-backend
|
working-directory: spiffworkflow-backend
|
||||||
run: echo $DOCKER_METADATA_OUTPUT_JSON | jq '.labels' > app_version.json
|
run: echo $DOCKER_METADATA_OUTPUT_JSON | jq '.labels' > version_info.json
|
||||||
- name: Build and push Backend Docker image
|
- name: Build and push Backend Docker image
|
||||||
uses: docker/build-push-action@v4.0.0
|
uses: docker/build-push-action@v4.0.0
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -4,4 +4,4 @@ t
|
||||||
*~
|
*~
|
||||||
.dccache
|
.dccache
|
||||||
*~
|
*~
|
||||||
app_version.json
|
version_info.json
|
||||||
|
|
|
@ -188,13 +188,13 @@ def create_app() -> flask.app.Flask:
|
||||||
def _setup_prometheus_metrics(app: flask.app.Flask, connexion_app: connexion.apps.flask_app.FlaskApp) -> None:
|
def _setup_prometheus_metrics(app: flask.app.Flask, connexion_app: connexion.apps.flask_app.FlaskApp) -> None:
|
||||||
metrics = ConnexionPrometheusMetrics(connexion_app)
|
metrics = ConnexionPrometheusMetrics(connexion_app)
|
||||||
app.config["PROMETHEUS_METRICS"] = metrics
|
app.config["PROMETHEUS_METRICS"] = metrics
|
||||||
if os.path.isfile("app_version.json"):
|
if os.path.isfile("version_info.json"):
|
||||||
app_version_data = {}
|
version_info_data = {}
|
||||||
with open("app_version.json") as f:
|
with open("version_info.json") as f:
|
||||||
app_version_data = json.load(f)
|
version_info_data = json.load(f)
|
||||||
# prometheus does not allow periods in key names
|
# prometheus does not allow periods in key names
|
||||||
app_version_data_normalized = {k.replace(".", "_"): v for k, v in app_version_data.items()}
|
version_info_data_normalized = {k.replace(".", "_"): v for k, v in version_info_data.items()}
|
||||||
metrics.info("app_version_info", "Application Version Info", **app_version_data_normalized)
|
metrics.info("version_info", "Application Version Info", **version_info_data_normalized)
|
||||||
|
|
||||||
|
|
||||||
def get_hacked_up_app_for_script() -> flask.app.Flask:
|
def get_hacked_up_app_for_script() -> flask.app.Flask:
|
||||||
|
|
|
@ -24,7 +24,7 @@ RUN cp /app/package.json.bak /app/package.json
|
||||||
# npx can-i-ignore-scripts can check that it's safe to ignore scripts.
|
# npx can-i-ignore-scripts can check that it's safe to ignore scripts.
|
||||||
RUN npm ci --ignore-scripts
|
RUN npm ci --ignore-scripts
|
||||||
|
|
||||||
RUN npm run build
|
RUN ./bin/build
|
||||||
|
|
||||||
# Final image without setup dependencies.
|
# Final image without setup dependencies.
|
||||||
FROM base AS final
|
FROM base AS final
|
||||||
|
@ -39,6 +39,4 @@ COPY --from=setup /app/build /app/build
|
||||||
COPY --from=setup /app/bin /app/bin
|
COPY --from=setup /app/bin /app/bin
|
||||||
COPY --from=setup /app/node_modules.justserve /app/node_modules
|
COPY --from=setup /app/node_modules.justserve /app/node_modules
|
||||||
|
|
||||||
ENV REACT_APP_VERSION_INFO="123"
|
|
||||||
|
|
||||||
ENTRYPOINT ["/app/bin/boot_server_in_docker"]
|
ENTRYPOINT ["/app/bin/boot_server_in_docker"]
|
||||||
|
|
|
@ -7,11 +7,6 @@ function error_handler() {
|
||||||
trap 'error_handler ${LINENO} $?' ERR
|
trap 'error_handler ${LINENO} $?' ERR
|
||||||
set -o errtrace -o errexit -o nounset -o pipefail
|
set -o errtrace -o errexit -o nounset -o pipefail
|
||||||
|
|
||||||
if [[ -f app_version.json ]]; then
|
|
||||||
SPIFFWORKFLOW_FRONTEND_RUNTIME_CONFIG_REACT_APP_VERSION_INFO_JSON=$(cat app_version.json)
|
|
||||||
export SPIFFWORKFLOW_FRONTEND_RUNTIME_CONFIG_REACT_APP_VERSION_INFO_JSON
|
|
||||||
fi
|
|
||||||
|
|
||||||
# sort of like https://lithic.tech/blog/2020-05/react-dynamic-config, but without golang
|
# sort of like https://lithic.tech/blog/2020-05/react-dynamic-config, but without golang
|
||||||
react_configs=$(env | grep -E "^SPIFFWORKFLOW_FRONTEND_RUNTIME_CONFIG_" || echo '')
|
react_configs=$(env | grep -E "^SPIFFWORKFLOW_FRONTEND_RUNTIME_CONFIG_" || echo '')
|
||||||
if [[ -n "$react_configs" ]]; then
|
if [[ -n "$react_configs" ]]; then
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function error_handler() {
|
||||||
|
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
|
||||||
|
exit "$2"
|
||||||
|
}
|
||||||
|
trap 'error_handler ${LINENO} $?' ERR
|
||||||
|
set -o errtrace -o errexit -o nounset -o pipefail
|
||||||
|
|
||||||
|
if [[ -f "version_info.json" ]]; then
|
||||||
|
version_info=$(cat version_info.json)
|
||||||
|
export REACT_APP_VERSION_INFO="$version_info"
|
||||||
|
fi
|
||||||
|
|
||||||
|
npm run build
|
|
@ -5,7 +5,7 @@
|
||||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<meta name="theme-color" content="#000000" />
|
<meta name="theme-color" content="#000000" />
|
||||||
<meta name="version-info" content="%REACT_APP_VERSION_INFO%" />
|
<meta name="version-info" content='%REACT_APP_VERSION_INFO%' />
|
||||||
<meta
|
<meta
|
||||||
name="description"
|
name="description"
|
||||||
content="A turnkey solution for building and executing the workflows that drive your business"
|
content="A turnkey solution for building and executing the workflows that drive your business"
|
||||||
|
|
Loading…
Reference in New Issue