This chapter covers getting started with Ichnaea using Docker for a local development environment.
Install required software: Docker, docker-compose (1.10+), make, and git.
Use your package manager.
Clone the repository so you have a copy on your host machine.
Instructions for cloning are on the Ichnaea page in GitHub.
(Optional/Advanced) Set UID and GID for Docker container user.
If you’re on Linux, you will need to set the UID/GID of the app user that runs in the Docker containers to match your UID/GID. Run:
$ make my.env
idto get your UID/GID. edit the file and set the
ICHNAEA_GIDvariables. These will get used when creating the app user in the base image.
If you ever want different values, change them in
Build Docker images for Ichnaea services.
From the root of this repository, run:
$ make build
That will build the app Docker image required for development.
Initialize Redis and MySQL.
Then you need to set up services. To do that, run:
$ make runservices
This starts service containers. Then run:
$ make setup
This creates the MySQL database and sets up tables and things.
You can run
make setupany time you want to wipe any data and start fresh.
At this point, you should have a basic functional Ichnaea development environment that has no geo data in it.
To see what else you can do, run:
Any time you want to update the code in the repostory, run something like this from the main branch:
$ git pull
It depends on what you’re working on and the state of things.
After you do that, you’ll need to update other things.
If there were changes to the requirements files or setup scripts, you’ll need to build new images:
$ make build
If there were changes to the database tables, you’ll need to wipe the MySQL database and Redis:
$ make setup
Configuration is pulled from these sources:
ENV files located in
docker-compose.ymlfor which ENV files are used in which containers, and their precedence.
Configuration defaults defined in the code.
The sources above are ordered by precedence, i.e. configuration values defined
my.env file will override values in the ENV files or defaults.
The following ENV files can be found in
This holds secrets and environment-specific configuration required to get services to work in a Docker-based local development environment.
This should NOT be used for server environments, but you could base configuration for a server environment on this file.
This holds configuration specific to running the tests. It has some configuration value overrides because the tests are “interesting”.
This file lets you override any environment variables set in other ENV files as well as set variables that are specific to your instance.
It is your personal file for your specific development environment–it doesn’t get checked into version control.
The template for this is in
In this way:
environmental configuration which covers secrets, hosts, ports, and infrastructure-specific things can be set up for every environment
behavioral configuration which covers how the code behaves and which classes it uses is versioned alongside the code making it easy to deploy and revert behavioral changes with the code depending on them
my.envlets you set configuration specific to your development environment as well as override any configuration and is not checked into version control
See Configuration for configuration settings.
There are some variables you need to set that are specific to your local dev
environment. Put them in
Ichnaea uses Alembic.
To create a new database migration, do this:
$ make shell app@blahblahblah:/app$ alembic revision -m "SHORT DESCRIPTION"
Then you can edit the file.
To build CSS files:
$ make buildcss
To build JS files:
$ make buildjs
You can run the test suite like this:
$ make test
If you want to pass different arguments to pytest or specify specific tests to run, open up a test shell first:
$ make testshell app@blahblahblah:/app$ pytest [ARGS]
You can build the docs like this:
$ make docs
This will create an application container with a volume mount to the
docs/build/html directory and update the documentation so
it is available in that local directory.
To view the documentation open
with a web brower.
The development environment uses a test MaxMind GeoIP database, and the Ichnaea test suite will fail if this is more than 1000 days old. To update this database and confirm tests pass, run:
$ make update-vendored test
Commit the refreshed files.
This command can also be used to updated
libmaxmindb and the
docker.make for the desired versions, and run:
$ make update-vendored build test
Commit the updated source tarballs.