The publication platform for Mozilla's marketing websites.
Make sure you have docker and docker compose. After those are setup and running you can use the following commands:
# This file must exist and you can customize environment variables for local dev in it
touch .env
# this pulls our latest builds from the docker hub.
# it's optional but will speed up your builds considerably.
docker compose pull
# get the site up and running
docker compose up webIf you've made changes to the Dockerfile or the requirements/*.txt files you'll need to rebuild
the image to run the app and tests:
docker compose build webThen to run the app you run the docker compose up web command again, or for running tests against your local changes you run:
docker compose run --rm testWe use pytest for running tests. So if you'd like to craft your own pytest command to run individual test files or something you can do so by passing in a command to the above:
docker compose run --rm test py.test nucleus/base/tests.pyAnd if you need to debug a running container, you can open another terminal to your nucleus code and run the following:
docker compose exec web bash
# or
docker compose exec web python manage.py shellFor Python we use pip-compile-multi to manage dependencies expressed in our requirements
files. pip-compile-multi is wrapped up in Makefile commands, to ensure we use it consistently.
If you add a new Python dependency (e.g. to requirements/prod.in or requirements/dev.in) you can generate a pinned and hash-marked
addition to our requirements files by running:
make compile-requirementsand committing any changes that are made. Please re-build your docker image and test it with make build test to be sure the dependency
does not cause a regression.
Similarly, if you upgrade a pinned dependency in an *.in file, run make compile-requirements then rebuild, test and commit the results.
To check for stale Python dependencies (basically pip list -o but in the Docker container):
make check-requirementsIdeally, do this in a virtual environment (eg a venv or virtualenv)
make install-local-python-deps- Add your project in Docker Registry as Automated Build
- Prepare a 'env' file with all the variables needed by dev, stage or production.
- Run the image:
docker run --env-file env -p 80:8000 mozilla/nucleusThis project includes a small React component embedded into the Django admin to manage release notes.
Note: Built JS is committed to the repo. No need to rebuild unless you're changing the React code.
If you need to make changes to the UI:
-
Install dependencies (only once):
npm install
-
Build the JS bundle:
npm run build
-
Run Django's
collectstaticto include the bundle:python manage.py collectstatic
Files of interest:
- React entry point:
frontend/release-notes.jsx - Compiled output:
nucleus/rna/static/js/release-notes.js - Mount point:
note-tablediv innucleus/rna/templates/admin/rna/release/change_form.html
The file can be linted by running npm run lint to check for errors using ESLint.
- heroku create
- heroku config:set DEBUG=False ALLOWED_HOSTS=.herokuapp.com, SECRET_KEY=something_secret DATABASE_URL gets populated by heroku once you setup a database.
- git push heroku master
https://github.com/mozmeao/nucleus-config/ has public examples of deployments in k8s clusters in AWS & GCP.
Unit tests are run via a GHA in the mozilla/nucleus repo https://github.com/mozilla/nucleus/actions
Deployments are handled via the (private) https://github.com/mozilla-sre-deploy/deploy-nucleus/ repo
We no longer use GitLab for CI/CD for Nucleus