Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(scripts): update Makefile commands and script folders #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

see7e
Copy link
Contributor

@see7e see7e commented Mar 24, 2025

Summary

  • Create script folder locations for project wide usage
  • Update references at documentation files
  • Propose enviroment variables to control development and production states
  • TODO Update docusaurus/docs/howtos/docusaurus.md when chore: evaluate and port Conrado's PR #9 get's merged
    From magma/docs, run ./docusaurus/create_docusaurus_website.sh

Test Plan

Additional Information

  • This change is backwards-breaking

Security Considerations

To be discussed at scheduled security meeting

function exit_timeout() {
echo ''
docker compose logs docusaurus
docker compose logs $SERVICE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable $SERVICE not previously set. Prefer passing arguments, makes syntax easier to understand.
You may do SERVICE=${2:default_service} and use as is and call exit_timeout time some_service.

Comment on lines +47 to +56
# Select service name and port based on environment
if [[ "$ENV" == "production" ]]; then
SERVICE="docusaurus-prod"
PORT=8080
URL="http://localhost:$PORT/"
else
SERVICE="docusaurus-dev"
PORT=3000
URL="http://localhost:$PORT/docs/basics/introduction"
fi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the approach to assume a single deployment mode, or at least assume production first.
Are you comfortable to assume a "production always" deployment?
This way, we don't incur the risk of testing something in dev mode and forgetting to configure the equivalent in the production mode. We might have a dev deployment, but I would feel more comfortable if it was an extension of the production, not a different scenario.

For production:

  • the URL configured as localhost might present some issues, 0.0.0.0 is better, because listen in all configured interfaces instead of only the loopback.
  • the protocol used is HTTPS, not HTTP, HTTPS implements a layer of security and exchange of certificates.
  • the port used is the 443, the default for HTTPS.
  • you might still use the docussaurus in HTTP, but reverse proxy is needed, nginx is commonly used for that, it also adds the security layer needed for the HTTPS.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add execution permission to this file

echo 'Navigate to http://localhost:3000/ to see the docs.'

xdg-open 'http://localhost:3000/docs/next/basics/introduction.html' || true
docker compose --compatibility up -d $SERVICE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compose file is not accessible running ./scripts/create_docussaurus_website.sh

Comment on lines +47 to +74
# Select service name and port based on environment
if [[ "$ENV" == "production" ]]; then
SERVICE="docusaurus-prod"
PORT=8080
URL="http://localhost:$PORT/"
else
SERVICE="docusaurus-dev"
PORT=3000
URL="http://localhost:$PORT/docs/basics/introduction"
fi

# Run
echo "==> Starting Docusaurus in '$ENV' mode..."

docker compose down
docker build -t magma_docusaurus .
docker compose --compatibility up -d

echo ''
echo 'NOTE: README changes will live-reload. Sidebar changes require re-running this script.'
echo ''
echo 'Waiting for Docusaurus site to come up...'
echo 'If you want to follow the build logs, run docker compose logs -f docusaurus'
spin
echo 'Navigate to http://localhost:3000/ to see the docs.'

xdg-open 'http://localhost:3000/docs/next/basics/introduction.html' || true
docker compose --compatibility up -d $SERVICE

if [[ "$ENV" == "development" ]]; then
echo ''
echo 'NOTE: README changes will live-reload. Sidebar changes require re-running this script.'
echo ''
echo 'Waiting for Docusaurus site to come up...'
echo "If you want to follow the build logs: docker compose logs -f $SERVICE"
spin
fi

echo "==> Docusaurus is running at: $URL"
# xdg-open "$URL" || true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a main function is a good practice, but you could break this into more functions.
At the end, you call main.

# ==============================
# Choose environment: development | production
# Default is "development"
ENV=${ENV:-development}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Receive as argument instead of environment variable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add execution permission to this file.
Running ./scripts/check_sidebars/py returns nothing.
Script is not working, fix the execution path.

Comment on lines +3 to +12
ENV ?= development

start: ## Start Docusaurus site (default: ENV=development)
ENV=$(ENV) bash scripts/create_docusaurus_website.sh

dev: ## Alias to start in development mode
ENV=development bash scripts/create_docusaurus_website.sh

build: ## Alias to start in production mode
ENV=production bash scripts/create_docusaurus_website.sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you get the ENV from environment, you don't need to separate dev from production, call it docussaurus or leave as default, calling only make to build and run docussaurus, usually this is done in a all section in the makefile. And update documentation

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a Makefile at docussaurus/Makefile, remove that, as this file does the same thing.

@lucaaamaral lucaaamaral linked an issue Apr 2, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chore: evaluate and port Conrado's PR
2 participants