Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't install deployment dependencies in app VM #1357

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,20 @@ Note that if there is an existing build Graph.obj in `otp_data`, vagrant provisi

Building AMIs
------------------------
1. Configure an AWS profile with `aws configure --profile gophillygo` if you haven't already
1. Make a production group_vars file (similarly to how is described above with development). Make sure production is set to true, and also specify an app_username, which should be set to: ubuntu
2. If building the `otp` machine, make sure the latest GTFS are in `otp_data`, then build a graph when them in the development environment provisioning. This will result in a new `Graph.obj` file being written to `otp_data`.
3. In the project directory within the app VM, run: `deployment/cac-stack.py create-ami --aws-access-key-id YOUR_ACCESS_KEY --aws-secret-access-key YOUR_SECRET_KEY --aws-role-arn YOUR_ASSUMED_ROLE_ARN`
4. The previous command builds all AMIs. To only build a single AMI, run the same command, but also specify the `--machine-type` parameter, which may be set to one of: `bastion`, `otp`, or `app`.
3. Install the deployment dependencies, ideally in a virtualenv: `python3 -m venv .venv && source .venv/bin/activate && pip install -r python/cac_tripplanner/deployment_requirements.txt`
4. Build AMIs by running (within the virtualenv): `AWS_PROFILE=gophillygo deployment/cac-stack.py create-ami`
5. The previous command builds all AMIs. To only build a single AMI, run the same command, but also specify the `--machine-type` parameter, which may be set to one of: `bastion`, `otp`, or `app`.


Launching AWS Stacks
------------------------
1. Copy `deployment/default_template.yaml` to `deployment/default.yaml` and edit variables
2. In the project directory, for a set of `Blue` stacks in the `Production` environment, run: `deployment/cac-stack.py launch-stacks --stack-type prod --stack-color blue --aws-access-key-id YOUR_ACCESS_KEY --aws-secret-access-key YOUR_SECRET_KEY --aws-role-arn YOUR_ASSUMED_ROLE_ARN`
1. Configure an AWS profile with `aws configure --profile gophillygo` if you haven't already
1. Create a virtualenv with the deployment dependencies if you haven't already (see Building AMIs, above).
2. In the project directory, for a set of `Blue` stacks in the `Production` environment, run: `AWS_PROFILE=gophillygo deployment/cac-stack.py launch-stacks --stack-color blue --stack-type prod`
3. The previous command will do the following:
* Ensure the `VPC` stack is up in Production -- it will be launched if it isn't already running
* Ensure the `DataPlane` stack is up in Production -- it will be launched if it isn't already running
Expand Down
3 changes: 0 additions & 3 deletions deployment/ansible/roles/cac-tripplanner.app/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
- libproj-dev
- libjpeg-dev

- name: Install pip packages for deployment
pip: requirements={{ root_app_dir }}/deployment_requirements.txt executable=/usr/bin/pip3

- name: Install pip packages for app
pip: requirements={{ root_app_dir }}/requirements.txt executable=/usr/bin/pip3

Expand Down
4 changes: 2 additions & 2 deletions deployment/cloudformation/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ def set_up_stack(self):
if not self.INPUTS or not self.STACK_NAME_PREFIX or not self.HEALTH_ENDPOINT:
raise MKInputError('Must define INPUTS, STACK_NAME_PREFIX, and HEALTH_ENDPOINT')

super(AppServerStack, self).set_up_stack()
self.set_version()

tags = self.get_input('Tags').copy()
self.add_description('{} App Server Stack for Cac'.format(self.STACK_NAME_PREFIX))
self.set_description('{} App Server Stack for Cac'.format(self.STACK_NAME_PREFIX))

assert isinstance(tags, dict), 'tags must be a dictionary'

Expand Down
4 changes: 2 additions & 2 deletions deployment/cloudformation/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ class DataPlaneGenerator(StackNode):

def set_up_stack(self):
"""Sets up the stack"""
super(DataPlaneGenerator, self).set_up_stack()
self.add_description('Data Plane Stack for Cac')
self.set_version()
self.set_description('Data Plane Stack for Cac')
self.rds_stack = RDSFactory()
self.rds_stack.populate_template(self)
for key in self.parameters:
Expand Down
4 changes: 2 additions & 2 deletions deployment/cloudformation/vpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class VPC(StackNode):

def set_up_stack(self):
"""Sets up the stack"""
super(VPC, self).set_up_stack()
self.set_version()

"""Creates a VPC object. See Class docstring for description of class

Expand All @@ -92,7 +92,7 @@ def set_up_stack(self):
tags (dict): Arbitrary tags to add to all resources that accept tags
"""
tags = self.get_input('Tags').copy()
self.add_description('VPC Stack for Cac')
self.set_description('VPC Stack for Cac')

assert isinstance(tags, dict), 'tags must be a dictionary'

Expand Down
2 changes: 1 addition & 1 deletion python/cac_tripplanner/deployment_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ boto==2.49.0
PyYAML==5.3.1
majorkirby==1.0.0
requests==2.24.0
troposphere==2.6.2
troposphere==3.2.2
1 change: 1 addition & 0 deletions python/cac_tripplanner/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
base58==2.0.1
boto3==1.15.9
boto==2.49.0
Django==3.2.13
django-ckeditor==6.0.0
django-image-cropping==1.5.0
Expand Down