-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate use of process.env for runtime config
- Replace process.env with window.env - Move env variables into a config.js file - Rework docker build to use file - Rework docker build to use static built files - Rework docker compose to load a config file - Add makefile utility matching station-data-portal - Add healthcheck to docker file
- Loading branch information
Showing
30 changed files
with
177 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.git | ||
build | ||
node_modules | ||
.idea | ||
|
||
**/*.env* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
REACT_APP_TILECACHE_URL=https://services.pacificclimate.org/mapproxy/service | ||
REACT_APP_NCWMS_URL=https://beehive.pacificclimate.org/ncwms | ||
REACT_APP_CE_ENSEMBLE_NAME=ce_files | ||
REACT_APP_MAP_LAYER_ID_TYPE=dynamic | ||
REACT_APP_MAP_LAYER_ID_PREFIX=x | ||
REACT_APP_VARIABLE_OPTIONS=variable-options.yaml | ||
REACT_APP_EXTERNAL_TEXT=external-text/default.yaml | ||
PUBLIC_URL=%REPLACE_PUBLIC_URL% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
REACT_APP_CE_BACKEND_URL=https://beehive.pacificclimate.org/pcex/api | ||
REACT_APP_CE_BASE_PATH= | ||
PUBLIC_URL=http://localhost:3001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
REACT_APP_CE_BACKEND_URL=https://services.pacificclimate.org/pcex/api | ||
REACT_APP_CE_BASE_PATH=/pcex/app | ||
PUBLIC_URL=%REPLACE_PUBLIC_URL% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# These variables are set to make it convenient to run the docker image locally. | ||
tag = $(shell git rev-parse --abbrev-ref HEAD) | ||
port = 30504 | ||
public_url = http://localhost:${port} | ||
|
||
image: | ||
@npm run build | ||
@PCEX_TAG=$(tag) PCEX_PORT=$(port) docker compose -f docker/docker-compose.yaml build | ||
|
||
up: | ||
@PCEX_TAG=$(tag) PCEX_PORT=$(port) docker compose -f docker/docker-compose.yaml up --force-recreate | ||
@echo "Station Data Portal running on $(port)" | ||
@docker logs -f station-data-portal-frontend | ||
|
||
down: | ||
@PCEX_TAG=$(tag) PCEX_PORT=$(port) docker compose -f docker/docker-compose.yaml down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM node:22-bookworm-slim | ||
|
||
RUN apt-get -y update && \ | ||
apt-get install --no-install-recommends \ | ||
-y curl rpl && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN npm install -g serve | ||
|
||
COPY --chown=node build /app | ||
COPY --chown=node docker/entrypoint.sh /app/docker/entrypoint.sh | ||
WORKDIR /app | ||
|
||
USER node | ||
EXPOSE 8080 | ||
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "curl", "-f", "http://localhost:8080/healthcheck.js" ] | ||
|
||
ENTRYPOINT ["docker/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
window.env = { | ||
PUBLIC_URL: "http://localhost:30504", | ||
REACT_APP_TILECACHE_URL: | ||
"https://beehive.pacificclimate.org/mapproxy/service", | ||
REACT_APP_NCWMS_URL: "https://beehive.pacificclimate.org/ncwms", | ||
REACT_APP_CE_BACKEND_URL: "https://beehive.pacificclimate.org/pcex/api", | ||
REACT_APP_CE_ENSEMBLE_NAME: "ce_files", | ||
REACT_APP_MAP_LAYER_ID_TYPE: "dynamic", | ||
REACT_APP_MAP_LAYER_ID_PREFIX: "x", | ||
REACT_APP_VARIABLE_OPTIONS: "variable-options.yaml", | ||
REACT_APP_EXTERNAL_TEXT: "external-text/default.yaml", | ||
REACT_APP_CE_BASE_PATH: "/", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# This docker-compose uses the following shell environment variables: | ||
# | ||
# `PCEX_TAG`: Image tag | ||
# `PCEX_PORT`: External port to map to | ||
# Note: These values are set as part of the makefile, initialize the container | ||
# Using it. | ||
# | ||
# Their values are set appropriately in the Makefile for use on a workstation. | ||
# For use in a production setting, either set the shell | ||
# variables appropriately when invoking docker-compose, or modify (a copy of) | ||
# this file with the desired values. | ||
|
||
version: "3.2" | ||
services: | ||
frontend: | ||
build: | ||
context: .. | ||
dockerfile: ./docker/Dockerfile | ||
#image: pcic/station-data-portal-frontend:${PCEX_TAG} | ||
container_name: station-data-portal-frontend | ||
volumes: | ||
- ./config.js:/app/config.js | ||
ports: | ||
- "${PCEX_PORT}:8080" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
# Note: this pulls the public url by a combination of grep and cut and relies on | ||
# PUBLIC_URL to be on its own line with the value and in the format of PUBLIC_URL="http://localhost:8080" | ||
# Fragile to additional quotes due to us looking for index 2 | ||
PUBLIC_URL=$(grep PUBLIC_URL config.js | cut -d'"' -f 2) | ||
|
||
# update static files with the public url | ||
rpl -iR \ | ||
-x **/*.js \ | ||
-x **/*.html \ | ||
-x **/*.css \ | ||
-x **/*.json \ | ||
"%REPLACE_PUBLIC_URL%" $PUBLIC_URL . | ||
|
||
# It is possible that the above could be replaced by a node.js based | ||
# script which may prove more resillient long term | ||
|
||
serve -s . -l 8080 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
window.env = { | ||
PUBLIC_URL: "http://localhost:3001", | ||
REACT_APP_TILECACHE_URL: | ||
"https://beehive.pacificclimate.org/mapproxy/service", | ||
REACT_APP_NCWMS_URL: "https://beehive.pacificclimate.org/ncwms", | ||
REACT_APP_CE_BACKEND_URL: "https://beehive.pacificclimate.org/pcex/api", | ||
REACT_APP_CE_ENSEMBLE_NAME: "ce_files", | ||
REACT_APP_MAP_LAYER_ID_TYPE: "dynamic", | ||
REACT_APP_MAP_LAYER_ID_PREFIX: "x", | ||
REACT_APP_VARIABLE_OPTIONS: "variable-options.yaml", | ||
REACT_APP_EXTERNAL_TEXT: "external-text/default.yaml", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// app is serving |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.