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.git
The 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/secrets
folder, create new files for each of the files ending in.example
by copying the.example
file 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/secrets
folder, create new files for each of the files ending in.example
by copying the.example
file 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 thefrontend
folder at the root of theportal-wp
repo 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-react
repo, 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/frontend
in the next stepnpm link
-
Run
npm link -g
, if you see@nasapds/wds-react
in the list, it was published locally successfully (note the path on your machine will point to the location of thewds-react
repo on your machine):% npm list -g /Users/<username>/.nvm/versions/node/v18.18.2/lib ├── @nasapds/wds-react@0.1.0 -> ./../../../../../Projects/PDS/Engineering Node/Repos/wds-react ├── corepack@0.19.0 └── npm@9.8.1npm link -g
-
If you installed
nvm
, open a new terminal window, navigate to thefrontend
folder at the root of theportal-wp
repo and set up Node.js:nvm use
-
Reference the locally published instance of the
wds-react
packagenpm link @nasapds/wds-react
Note: Anytime
npm install
is run inportal-wp/frontend
, you'll have to rerun thenpm link @nasapds/wds-react
command 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
wds
repository and switch to thedevelop
branch — https://github.com/NASA-PDS/wds -
If you installed
nvm
, open a new terminal window, navigate to the folder containing thewds
repo, 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 install
andnpm clean-install
) -
Run
npm run build:css
-
Run
npm run build:icons
-
Run
npm link
to add the@nasapds/wds
package to your local list of packages. -
Run
npm list -g
, if you see@nasapds/wds
in the list, it was published locally successfully (note the path on your machine will point to the location of thewds
repo on your machine):wds % npm list -g /Users/<your_username>/.nvm/versions/node/v20.16.0/lib ├── @nasapds/wds@0.0.1 -> ./../../../../../Projects/PDS/Engineering Node/Repos/wds-clean ├── corepack@0.28.2 └── npm@10.8.1
-
Using Git, clone the
wds-react
repository and switch to thedevelop
branch — https://github.com/NASA-PDS/wds-react -
If you installed
nvm
, open a new terminal window, navigate to the folder containing thewds-react
repo, 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 install
andnpm clean-install
) -
Run
npm link @nasapds/wds
to link to thewds
package we previously published locally. -
Run
npm run build-lib
-
Run
npm run build-icons
-
Run
npm link
to add the@nasapds/wds-react
package to your local list of packages. -
Run
npm list -g
, if you see@nasapds/wds-react
in the list, it was published locally successfully (note the path on your machine will point to the location of thewds-react
repo on your machine):wds-react % npm list -g /Users/<your_username>/.nvm/versions/node/v20.16.0/lib ├── @nasapds/wds-react@0.1.0 -> ./../../../../../Projects/PDS/Engineering Node/Repos/wds-react ├── @nasapds/wds@0.0.1 -> ./../../../../../Projects/PDS/Engineering Node/Repos/wds ├── corepack@0.28.2 └── npm@10.8.1
-
Using Git, clone the
portal-wp
repository and switch to thedevelop
branch — https://github.com/NASA-PDS/portal-wp -
If you installed
nvm
, open a new terminal window, navigate to the folder containing theportal-wp
repo, and from there navigate toapps/frontend
and 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 install
andnpm clean-install
) -
Run
npm link @nasapds/wds-react
to link to thewds-react
package we previously published locally. -
Run
npm run build
to create a build of the portal-wp code -
Upload the contents of
apps/frontend/dist
to the S3 bucket mentioned in the wiki.
TBD