Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Update project deployment tooling, add docker-compose development environment #226

Merged
merged 4 commits into from
Sep 7, 2017

Conversation

tnation14
Copy link
Contributor

@tnation14 tnation14 commented Aug 30, 2017

Overview

This PR brings this project into alignment with our standard setup by updating the deployment tooling to use Terraform and AWS instead of the s3_website gem, and replacing the Vagrant development environment with a docker-compose based setup.

Notable Changes

  • Repace npm package manager with yarn
  • Replace Vagrant setup with docker-compose
  • Replace s3_website deployment with Terraform/AWS CLI
  • Add docker-based deployment tooling

Demo

Optional. Screenshots, curl examples, etc.

Notes

  • I couldn't verify that package-lock.json is exactly the same as yarn.lock. However, I created yarn.lock using the following steps:
$ npm install # create node_modules from package.json
$ yarn import # create yarn.lock from the contents of the node_modules folder
  • Initially, dockerized Karma tests were failing in CI (Ubuntu 16.04) with the following error:
ChromeHeadless stderr: Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted

I was able to get things working by creating a Karma custom launcher that passes --no-sandbox to Chomium. The custom launcher overrode the default launcher flags, so I had to include --disable-gpu, --headless, and --remote-debugging-port as well.

Testing Instructions

Closes #223

@tnation14 tnation14 requested a review from hectcastro August 30, 2017 19:23
@tnation14 tnation14 self-assigned this Aug 30, 2017
@tnation14
Copy link
Contributor Author

tnation14 commented Aug 30, 2017

@CloudNiner could you weigh in on the switch to yarn and my modifications to the Karma configuration? Just want to be sure that it's not going to break anything.

@tnation14 tnation14 requested a review from CloudNiner August 30, 2017 19:28
@@ -0,0 +1,75 @@
resource "aws_cloudfront_distribution" "cdn" {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder to tear down the old infrastructure once this PR is merged.

@tnation14 tnation14 force-pushed the feature/tnation/update-deployment-tooling branch from 029199b to 0e451ce Compare August 31, 2017 12:38
@CloudNiner
Copy link

Is there any significant advantage to yarn now that npm has the package-lock.json file?

I'll defer to @flibbertigibbet regarding the karma conf, she was just updating dependencies in #228 so it's probably worth rebasing this against develop once that's merged to ensure you've got the most up to date packages and the testing config here still works.

@tnation14
Copy link
Contributor Author

The main reasons for using yarn here are that it alleviates the node-sass compilation issue that was being fixed in ansible/climate-change-lab.app, and it's already installed in the node Docker image. NPM's installed as well, but it's an older version so we'd have to update it in the Dockerfile.

Re: Karma, I'll try testing again after #228 is merged. Thanks!

@CloudNiner
Copy link

👍 to yarn then.

@CloudNiner
Copy link

I built the VM and then ran ./scripts/server. The docker containers were pulled/built successfully, but then I got this error:

vagrant@app:/vagrant$ ./scripts/server
yarn run v0.24.4
warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
$ ng serve
sh: 1: ng: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

It occurs regardless of whether I use the --vm option.

@tnation14
Copy link
Contributor Author

Did you build the VM using scripts/setup, or vagrant up?

@CloudNiner
Copy link

I just rebuilt after pulling down the latest commit via ./scripts/setup. Then ran ./scripts/server in the VM. The webpack server started.

However, I can't hit localhost:4200 from my browser. Unsure if related, but I'm still seeing this yarn warning:

warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.

@tnation14
Copy link
Contributor Author

tnation14 commented Aug 31, 2017

I was able to hit localhost:4200, even with the internet connection warning. Did you run scripts/server --vm, or just scripts/server?

#
# S3 resources
#
data "template_file" "read_only_bucket_policy" {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that we have parts of this modularized in https://github.com/azavea/terraform-aws-s3-origin.

@hectcastro
Copy link

GitHub isn't letting me leave comments on these lines:

screen shot 2017-09-01 at 10 35 08

@tnation14 tnation14 force-pushed the feature/tnation/update-deployment-tooling branch from 42c454d to faae188 Compare September 1, 2017 15:26
@CloudNiner
Copy link

@tnation14 sorry if you were waiting on me for this, I was able to hit the application after reprovisioning and doing ./scripts/server --vm. Although I still see the "no internet" error that you're seeing.

Copy link

@CloudNiner CloudNiner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM once this has been rebased against current develop, tests pass and we validate that the yarn lockfile is up to date.

- Install docker-compose and NTP in the VM
- cd to /vagrant on login
- Add docker container with Node, NPM, and Karma dev dependencies
- scripts/update now installs node dependencies
@tnation14 tnation14 force-pushed the feature/tnation/update-deployment-tooling branch 2 times, most recently from e407d2f to 828e0a3 Compare September 6, 2017 12:58
@hectcastro
Copy link

I'm not super worried about the "no internet" error. We see it in all of the other Yarn + Docker projects, but it doesn't appear to have any significant negative effects.

See: yarnpkg/yarn#749

- Read-only static site bucket
- Logs bucket
- CloudFront distribution with S3 origin
- DNS entry for CloudFront distribution
- Remove s3_website gem
- Add docker-compose.ci.yml, with a terraform 0.9.11 container for deployments
- Add STRATA script to deploy terraform changes and upload files to site bucket
- Don’t run STRTA scripts in the VM
- Make linter output available outside of app container
@tnation14 tnation14 force-pushed the feature/tnation/update-deployment-tooling branch from 79d267f to 840052d Compare September 7, 2017 12:33
@tnation14 tnation14 merged commit 6067bc4 into develop Sep 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants