Copy the environment configuration file:
cp .env.example .envEdit .env and set your passwords and API keys:
POSTGRES_PASSWORD=your_password_here
STRIPE_SECRET_KEY=your_key_here
STRIPE_PUBLISHABLE_KEY=your_key_here
MAILGUN_API_KEY=your_key_here
Run:
docker compose up --buildThis will boot up everything that Modernomad needs to run, and stay running in the terminal.
In another console, run these commands to set up the database and set up a user:
docker compose run django ./manage.py migrateYour docker image is now running with your local development code. Browse to
http://localhost:8000/ to access your running image. You can run any of the other
manage.py commands in the same way. E.g., to run the test suite:
docker compose run django ./manage.py testThe first time you get this going, you will want to generate some test data:
docker compose run django ./manage.py generate_test_dataThis will create a superuser with the credentials admin and password.
You only need to run these commands once. Wen you want to work on the development
environment in the future, just run docker compose up --build. (Note: --build is
optional, but means that the Python and Node dependencies will always remain up-to-date.)
You can configure environment variables using the .env.example file.
Copy the example:
cp .env.example .envAnd then edit .env at will.
To learn about what can be configured, see the configuration documentation.
You can access a Django shell using:
docker compose run --rm django python manage.py shell--rm means that the container will be deleted after exit.
You can add a breakpoint() in your Python code and step into the code. To do this
you need to attach to the django docker container.
Run this and get the first column, the container ID:
docker ps|grep modernomad-djangoThen, run this in a separate terminal:
docker attach <container-id>
# eg. docker attach ee8e1887e766Now, this new terminal will give you input if the code encounters a breakpoint.
If you want to reset everything (and delete all local database data), run:
# stop containers
docker compose stop
# remove containers
docker compose down
# remove volume -- THIS WILL DELETE ALL LOCAL DATA
docker volume rm modernomad_pgdata