Skip to content

Commit

Permalink
Update docker compose to use v2 syntax (no hyphen) because v1 syntax …
Browse files Browse the repository at this point in the history
…has lost support (#942)
  • Loading branch information
stevejalim committed Aug 5, 2024
1 parent 1731cfe commit e3fac0c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
52 changes: 25 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,46 @@ The publication platform for Mozilla's marketing websites.
Docker for development
----------------------

Make sure you have [docker](https://www.docker.com/products/docker-desktop) and
[docker-compose](https://github.com/docker/compose). After those are setup and running
Make sure you have [docker](https://www.docker.com/products/docker-desktop) and
[docker compose](https://github.com/docker/compose). After those are setup and running
you can use the following commands:

```bash
$ # 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 web
# 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 web
```

If 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:

```bash
$ docker-compose build web
docker compose build web
```

Then to run the app you run the `docker-compose up web` command again, or for running tests against your local changes you run:
Then to run the app you run the `docker compose up web` command again, or for running tests against your local changes you run:

```bash
$ docker-compose run --rm test
docker compose run --rm test
```

We 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:

```bash
$ docker-compose run --rm test py.test nucleus/base/tests.py
docker compose run --rm test py.test nucleus/base/tests.py
```

And if you need to debug a running container, you can open another terminal to your nucleus code and run the following:

```bash
$ docker-compose exec web bash
$ # or
$ docker-compose exec web python manage.py shell
docker compose exec web bash
# or
docker compose exec web python manage.py shell
```

Managing Python dependencies
Expand All @@ -58,7 +58,7 @@ If you add a new Python dependency (e.g. to `requirements/prod.in` or `requireme
addition to our requirements files by running:

```bash
$ make compile-requirements
make compile-requirements
```

and committing any changes that are made. Please re-build your docker image and test it with `make build test` to be sure the dependency
Expand All @@ -69,7 +69,7 @@ Similarly, if you *upgrade* a pinned dependency in an `*.in` file, run `make com
To check for stale Python dependencies (basically `pip list -o` but in the Docker container):

```bash
$ make check-requirements
make check-requirements
```

Install Python requirements locally
Expand All @@ -78,7 +78,7 @@ Install Python requirements locally
Ideally, do this in a virtual environment (eg a `venv` or `virtualenv`)

```bash
$ make install-local-python-deps
make install-local-python-deps
```

Docker for deploying to production
Expand All @@ -89,34 +89,32 @@ Docker for deploying to production
3. Run the image:

```bash
$ docker run --env-file env -p 80:8000 mozilla/nucleus
docker run --env-file env -p 80:8000 mozilla/nucleus
```

Heroku
------

1. heroku create
2. heroku config:set DEBUG=False ALLOWED_HOSTS=<foobar>.herokuapp.com, SECRET_KEY=something_secret
DATABASE_URL gets populated by heroku once you setup a database.
3. git push heroku master


NewRelic Monitoring
-------------------

A newrelic.ini file is already included. To enable NewRelic monitoring
add two environment variables:

- NEW_RELIC_LICENSE_KEY
- NEW_RELIC_APP_NAME
- NEW_RELIC_LICENSE_KEY
- NEW_RELIC_APP_NAME

See the [full list of supported environment variables](https://docs.newrelic.com/docs/agents/python-agent/installation-configuration/python-agent-configuration#environment-variables).


## Kubernetes

https://github.com/mozmeao/nucleus-config/ has public examples of deployments in k8s clusters in AWS & GCP.

<https://github.com/mozmeao/nucleus-config/> has public examples of deployments in k8s clusters in AWS & GCP.

## Gitlab CI/CD

We have https://gitlab.com/mozmeao/nucleus/pipelines [set up as CI/CD for](https://gitlab.com/mozmeao/infra/blob/master/docs/gitlab_ci.md) https://github.com/mozilla/nucleus via this [.gitlab-ci.yml](https://github.com/mozilla/nucleus/blob/gitlab/.gitlab-ci.yml), which [updates the config repo](https://github.com/mozilla/nucleus/blob/gitlab/bin/update-config.sh) triggering https://gitlab.com/mozmeao/nucleus/pipelines configured by [.gitlab-ci.yml in the config repo](https://github.com/mozilla/nucleus-config/blob/master/.gitlab-ci.yml).
We have <https://gitlab.com/mozmeao/nucleus/pipelines> [set up as CI/CD for](https://gitlab.com/mozmeao/infra/blob/master/docs/gitlab_ci.md) <https://github.com/mozilla/nucleus> via this [.gitlab-ci.yml](https://github.com/mozilla/nucleus/blob/gitlab/.gitlab-ci.yml), which [updates the config repo](https://github.com/mozilla/nucleus/blob/gitlab/bin/update-config.sh) triggering <https://gitlab.com/mozmeao/nucleus/pipelines> configured by [.gitlab-ci.yml in the config repo](https://github.com/mozilla/nucleus-config/blob/master/.gitlab-ci.yml).
2 changes: 1 addition & 1 deletion bin/dc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

# Set env vars used in docker-compose.yml and other scripts
source docker/bin/set_git_env_vars.sh
docker-compose "$@"
docker compose "$@"

0 comments on commit e3fac0c

Please sign in to comment.