How to Setup Your Local Machine
Setting up your development environment on Docker is a straightforward, but multi-step process. My hope is to eventually make this as simple as 1 command.
Before you get started
Install Docker for Mac, or Docker for Linux, or Docker for Windows from https://docs.docker.com/. This should install docker, as well as Kitematic.
Get the VPN key and config environment folder from your manager. You will need this to download data from production for your development server. It has keys in it, so it's not included in the repo.
Get and validate Github repo access. Ensure you have Github access to the OMAlab repos. You should have access to oma, oma-models, oma-processors, audienti, backend, front, and some others.
Generate a Github Oauth Token, that will be used for pushing repos. This token can be generated on the Github website at: https://github.com/settings/tokens/new
For pushing to production, and CI you'll need in your developer.yml file:
Ensure Rancher access. Can you access http://rancher.audienti.com:8080/. You can login with your Github account. From Rancher, get your developer tokens.
Install rancher-compose and the rancher CLI and ensure these are operational. This can either be downloaded from the rancher server, or you can download from the public repos. Your environment will need to be setup for these to work.
Drone keys and tokens
Your administrator has given you bastion access (access to the production VLAN).
You should be able to answer everything in this list. This is a .yml file that will be placed in your setup to configure it for development.
Machine Setup
Change into your main developer_root folder. This is the folder where you keep projects and check out new code. This should be on your machine
~/projects/
folder to follow OMAlab conventions.Go to Github.com, and navigate to the
omalab/audienti
project. Clone the "audienti" project to this folder. Ensure the folder name is called "audienti". This project has all the configuration data and scripts needed to deploy our back end application on Docker.Type $>
bundle install
to bundle your gems that are required for development setup.Put your
developer.yml
in theconfig/developer
folder of the audienti folder you just cloned. This file will be read to prime/setup the system.From the root of the audienti proejct, type
bin/setup
. This command will read yourdeveloper.yml
file and place a file calledcustom_aliases.sh
into the root of the audienti project folder. This should be placed into our .profile or bashrc or other config so that it is read every time you open a new terminal window. This will be unique to your local development environment, so it's outside the scope of this guide as to how to do it.When loaded correctly, you should be able to type $>
audi
and change to the directory of your /audienti development environment. If you are not, then you are not setup correctly.The
bin/cli
is a command line for utilities for the audienti project. The ENV modifications you installed wrap the ruby ./cli.rb x to use the simpler cli command. On Mac, this can be entered as simply "cli". But, on other systems, you might need to enter ./cli.rb to run. You should see a help screen for the command line with a list of commands for use in managing your configuration. If you don't see this, then you're not setup correctly.Type $>
bin/clone_config
. This will clone the configuration files needed for accessing the system in various environments.Go into .
/config/environments/dc1/front
and ./config/environments/dc1/back
and modify the config files to match your local development hostname. If you follow OMAlab convention, you have added a www.omaengine.dev to point to your localhost. If you do this, these files should NOT require modification.Type $>
bin/clone_repos
. This will clone the repos into the correct folders and folder locations. It copies the primary folders.Type $>
docker login
to login to Docker.Type $>
dcdr api bash
to enter the next gen Audienti repo image in development mode. This SHOULD pull a bunch of repos, start the database servers, and then land you at a bash prompt in the Rails app repo folder.Type $> ./
setup_new_container.sh
to setup a new container. This will bundle, create databases, load schema, and otherwise get you up and running. If you want to do things manually instead, follow the steps in this script.Type $>
./rd.sh
to load all the runtime dependencies.. This will run bundler, yarn, and npm.Log out. Login with your test environment and do the same thing as above.
Log out. Now, do
dcdp app bash
. This will load the app (React) front end application.Type $>
yarn
to bundle the node assets.Type $>
yarn start
to start the application. It should be serving on port 8080.
Notes about development
There are 2 main repos you deal with for the application: front and backend. In the docker-compose, they map to the "app" and the "api". You start and stop them with "app" an "api" container commands.
The legacy application front end is the "oma" repo. The legacy models for the Rails app are in the oma-models repo. The old back end processing logic was in the oma-processors repo.
Once you're up and running, in development mode, you can run dcdup and this will start all the services and push you back to your command prompt. Then, to attach to an existing, running service with a bash prompt, you can type
dattach
audienti_api or dattachaudienti_app
.You might need a static entry in your hosts file to map to the IP of your docker machine. Your development environment is no longer on localhost. This file is on /etc/hosts.
Changing running environment is done with a dc commands. They are made up of 4 commands:
dc = docker compose
{environment} = d for development, t for test, p for production
{run | run port mapped} = r to run and not map ports for your local, p to run and map ports to your local
So the command becomes dcdr (dc development in port mode) dcdp (dc development in port mapped mode), dctr (dc test in port mapped mode).
Pushing and pulling to Github should be the same inside an image. Follow our traditional instructions.
When you enter an image, it will be using the last time the image was built. So you will need to bundle install.
IF you need to do development on our crawler or other supplemental repos, you can clone them into the $AUDIENTI_ROOT folder, then add them to the docker-compose.override.yml to map them into your environment in the development environment (you can also use the cli command clone_supplemental to do this).
Notes about Docker
Docker development is different than your traditional development. Your databases are on different IP addresses. So, changes have had to be made with RSpec and tests to work with it. From any machine, you can check if your machine has access to another machine by pinging it from the command line. $>
ping db
will check if you can access postgres for example. The names used in this case, are the names listed in the docker-compose.override.yml file.If you run out of disk space, go into Kitematic and terminate some of your old images. Every time you boot your machine, you create a new image. You have to go out occasionally and clean them out. There are oma cli commands docker nuke that will wipe everything. See the cli help for more assistance on that.
Last updated