This repo aims to contains the configuration to stand up the services needed by the Planetary Data System (PDS) to establish its web presence, while also providing the means to provide support for local development.
The services in this codebase rely on docker containerization to host the various services. Locally, this can be achieved by using Docker Desktop. Other tools, like podman could be used, but would require changes to the configuration as the recipes contained in the Makefile are specific to docker.
The frontend service relies on Node.js. The minimum version of Node.js that is needed is specified in frontend/.nvmrc. For developers that work on multiple projects relying on different versions of Node.js, we recommend installing Node Version Manager (nvm). nvm helps faciliate easily switching between different versions of node for a given shell environment.
To set up your local machine, follow these instructions:
# Clone this repo using your preffered method, https is shown here
git clone https://github.com/NASA-PDS/portal-wp.gitThe goal is create a set of components that are built for React and neatly organize them into a package named wds-react. During development we can use npm link to reference this for development purposes.
# Clone this repo using your preffered method, https is shown here
git clone https://github.com/NASA-PDS/wds-react.git
To store and retrieve values needed by the db and wordpress services, we rely on docker secrets. The files you are about to create, should never be committed to the repository. Our .gitignore is already configured to ignore these secret files, but if new services are added, the .gitignore will need to be updated to ignore new folders containing docker secrets.
Here are instructions to configure the docker secrets:
- Within the
db/secretsfolder, create new files for each of the files ending in.exampleby copying the.examplefile and renaming it so it doesn't end with.example. - Update the seceret file contents:
MYSQL_DATABASE.txt: store the name of the database you wish to use for the Wordpress Service, this will be needed later.MYSQL_PASSWORD.txt: create a unique password and store it in this file, this will be needed later.MYSQL_ROOT_PASSWORD.txt: This password is for root access to your local database, create a unique password and store it in this file.MYSQL_USER.txt: select the name of the database user account that the wordpress service will use when connecting to the database, this will be needed later.
- Within the
wordpress/secretsfolder, create new files for each of the files ending in.exampleby copying the.examplefile and renaming it so it doesn't end with.example. - Update the seceret file contents:
WORDPRESS_DB_NAME.txt: reuse the value stored indb/secrets/MYSQL_DATABASE.txt.WORDPRESS_DB_PASSWORD.txt: reuse the value stored indb/secrets/MYSQL_PASSWORD.txt.WORDPRESS_DB_USER.txt: reuse the value stored indb/secrets/MYSQL_USER.txt.
All of the services needed for the platform are specified in the docker-compose.yml file except for the frontend service.
To run these services locally, ensure Docker Desktop is installed and running.
First build the containers, as needed:
docker-compose build
And then start the containers:
docker-compose up
To generate the Detect Secrets baseline for this repo, numerous directories need to be ignored.
detect-secrets scan . \
--all-files \
--disable-plugin AbsolutePathDetectorExperimental \
--exclude-files '\.secrets..*' \
--exclude-files '\.git.*' \
--exclude-files '\.pre-commit-config\.yaml' \
--exclude-files 'target' \
--exclude-files 'wordpress/data/wp-includes/' \
--exclude-files 'wordpress/data/wp-admin/js/' \
--exclude-files 'wordpress/data/wp-content/plugins/' \
--exclude-files 'wordpress/data/wp-content/themes/' > .secrets.baseline
Depending on the version of docker compose you have installed, it can be invoked differently. Docker Compose V1 uses docker-compose; whereas the newer V2 uses docker compose, note the missing dash. Reference: https://docs.docker.com/compose/migrate/#docker-compose-vs-docker-compose
Many of the commands often used for local development are captured in the Makefile. Review this file for other helpful recipes to delete images, restart services, etc. For example:
make build-images # Builds all images specified in docker-compose.yml
make start # Starts all services specified in docker-compose.yml
Additional configuration is needed to standup a containerized frontend service due to an integration issue with npm link. Until then, the frontend service needs to be run separately.
To run the frontend service, follow these steps:
-
If you installed
nvm, open a new terminal window, navigate to thefrontendfolder at the root of theportal-wprepo and set up Node.js:nvm use -
Install dependencies
npm clean-install
-
If you installed
nvm, open a new terminal window, navigate to the folder containing thewds-reactrepo, and set up Node.js:nvm use -
Install the dependencies needed by
wds-react:npm clean-install -
Build the package (rerun as you make updates to
wds-react):npm build-lib -
Publish the package locally, so it can be referenced by
portal-wp/frontendin the next stepnpm link -
Run
npm link -g, if you see@nasapds/wds-reactin the list, it was published locally successfully (note the path on your machine will point to the location of thewds-reactrepo on your machine):% npm list -g /Users/<username>/.nvm/versions/node/v18.18.2/lib ├── @nasapds/[email protected] -> ./../../../../../Projects/PDS/Engineering Node/Repos/wds-react ├── [email protected] └── [email protected] link -g
-
If you installed
nvm, open a new terminal window, navigate to thefrontendfolder at the root of theportal-wprepo and set up Node.js:nvm use -
Reference the locally published instance of the
wds-reactpackagenpm link @nasapds/wds-reactNote: Anytime
npm installis run inportal-wp/frontend, you'll have to rerun thenpm link @nasapds/wds-reactcommand to relink the package.
npm run dev
Open a browser and navigate to, https://localhost:5173
To create a build to be deployed to AWS, follow the steps below.
The frontend service relies on Node.js. The minimum version of Node.js that is needed is specified in apps/frontend/.nvmrc. For developers that work on multiple projects relying on different versions of Node.js, we recommend installing Node Version Manager (nvm). nvm helps faciliate easily switching between different versions of node for a given shell environment.
-
Using Git, clone the
wdsrepository and switch to thedevelopbranch — https://github.com/NASA-PDS/wds -
If you installed
nvm, open a new terminal window, navigate to the folder containing thewdsrepo, and set up Node.js for this terminal session:wds % nvm use Found '/Users/<your_username>/Projects/PDS/Engineering Node/Repos/wds/.nvmrc' with version <lts/iron> Now using node v20.16.0 (npm v10.8.1) -
Run
npm clean-install(See notes about differences betweennpm installandnpm clean-install) -
Run
npm run build:css -
Run
npm run build:icons -
Run
npm linkto add the@nasapds/wdspackage to your local list of packages. -
Run
npm list -g, if you see@nasapds/wdsin the list, it was published locally successfully (note the path on your machine will point to the location of thewdsrepo on your machine):wds % npm list -g /Users/<your_username>/.nvm/versions/node/v20.16.0/lib ├── @nasapds/[email protected] -> ./../../../../../Projects/PDS/Engineering Node/Repos/wds-clean ├── [email protected] └── [email protected]
-
Using Git, clone the
wds-reactrepository and switch to thedevelopbranch — https://github.com/NASA-PDS/wds-react -
If you installed
nvm, open a new terminal window, navigate to the folder containing thewds-reactrepo, and set up Node.js for this terminal session:wds-react % nvm use Found '/Users/<your_username>/Projects/PDS/Engineering Node/Repos/wds-react/.nvmrc' with version <lts/iron> Now using node v20.16.0 (npm v10.8.1) -
Run
npm clean-install(See notes about differences betweennpm installandnpm clean-install) -
Run
npm link @nasapds/wdsto link to thewdspackage we previously published locally. -
Run
npm run build-lib -
Run
npm run build-icons -
Run
npm linkto add the@nasapds/wds-reactpackage to your local list of packages. -
Run
npm list -g, if you see@nasapds/wds-reactin the list, it was published locally successfully (note the path on your machine will point to the location of thewds-reactrepo on your machine):wds-react % npm list -g /Users/<your_username>/.nvm/versions/node/v20.16.0/lib ├── @nasapds/[email protected] -> ./../../../../../Projects/PDS/Engineering Node/Repos/wds-react ├── @nasapds/[email protected] -> ./../../../../../Projects/PDS/Engineering Node/Repos/wds ├── [email protected] └── [email protected]
-
Using Git, clone the
portal-wprepository and switch to thedevelopbranch — https://github.com/NASA-PDS/portal-wp -
If you installed
nvm, open a new terminal window, navigate to the folder containing theportal-wprepo, and from there navigate toapps/frontendand set up Node.js for this terminal session:frontend % nvm use Found '/Users/<your_username>/Projects/PDS/Engineering Node/Repos/portal-wp/apps/frontend/.nvmrc' with version <lts/iron> Now using node v20.16.0 (npm v10.8.1) -
Run
npm clean-install(See notes about differences betweennpm installandnpm clean-install) -
Run
npm link @nasapds/wds-reactto link to thewds-reactpackage we previously published locally. -
Run
npm run buildto create a build of the portal-wp code -
Upload the contents of
apps/frontend/distto the S3 bucket mentioned in the wiki.
TBD