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

Docker Update and Continuous Deployment #19

Merged
merged 19 commits into from
Mar 15, 2016
Merged

Docker Update and Continuous Deployment #19

merged 19 commits into from
Mar 15, 2016

Conversation

rowanmanning
Copy link
Member

Outline

This PR contains the work required to get the build service continuously deploying, addressing #7. In order to do this we've had to overhaul the way that Docker is used, moving to Heroku's improved Docker support (which is currently in private beta). Here's what's been done:

  • Improved Docker support: Deployment is now done by pushing a built Docker image to Heroku's registry. I've simplified the commands required to do this:
    • Local development: docker-compose build and docker-compose up
    • Deploy: npm run build and npm run deploy
  • Continuous deployment: The above build/deploy commands no longer need to be run manually as they'll be run in CircleCI. Any push to the master branch will be deployed to QA once the tests have passed. Production is not deployed to through CI (see pipelines).
  • Pipelines: We're using a Heroku pipeline to deploy from QA to production. This makes a production deploy a simple button press, and the image that gets pushed into production is the exact same code that is running successfully in QA.
  • Cleanup: Removal of any files which are no longer necessary, and a cleanup of documentation/environment variables which are no longer used.

What Needs Doing Before/After Merge

First we need to agree that this is approach to continuous deployment that we'd like to take. I can demo everything to the team and we can have a chat about it.

Code-wise, everything is currently deploying happily to origami-buildservice-rowan-qa and origami-buildservice-rowan. We need to do a few things before this is ready to merge:

  1. In circle.yml, change the deployment branch to master.
  2. Change references in package.json from origami-buildservice-rowan-qa to origami-buildservice-qa.
  3. Merge this PR.
  4. Tag a new version on master and push it (wait for the deploy to work).
  5. Verify that the new version is on QA and everything works.
  6. Create a Heroku pipeline from origami-buildservice-qa to origami-buildservice-eu.
  7. Promote the QA deploy to production.
  8. Verify that the new version is on production and everything works.

Next Steps

These are things that I'd like to get done after this has been merged, but don't need to be done to get continuous deployment up-and-running:

@rowanmanning
Copy link
Member Author

@JakeChampion, @AlbertoElias, @alicebartlett, @onishiweb, @j-mes, would be good to get your thoughts/feedback on this. We can discuss in-person as a group if it's easier.

insert_final_newline = true
charset = utf-8

[**{.js,.scss,.html,.mustache,.md,.yml}]
Copy link
Contributor

Choose a reason for hiding this comment

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

.yml forbids tabs

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, I got that wrong, and preventing yml from having tabs is the entire reason I added this file 😂

@@ -1,44 +1,22 @@
FROM heroku/cedar:14
FROM mhart/alpine-node:4
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not mentioned anywhere in this PR why the change from cedar to alpine was made.

Below is the explanation given in the heroku-docker-node-alpine-example repository

Heroku's Cedar base image is based upon Ubuntu, which was not developed with the idea of being run inside a container, incidentally making the image size rather large. Heroku's Cedar also installs a lot of packages to cover the needs of most Heroku developers' applications.

Alpine Linux is built around musl libc and busybox. This makes it smaller and more resource efficient than traditional GNU/Linux distributions. An Alpine Linux image requires no more than 8 MB.

A smaller base image with fewer dependencies gives benefits such as a faster build/deploy time, smaller artifacts created for each build, and a smaller surface area to check for security vulnerabilities.

Choose a reason for hiding this comment

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

Is alpine likely to continue to be maintained? Is that a concern?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not a major concern, the community around Alpine is large.


To SSH into the web container, you first need to SSH into the Docker VM, and then into the container you want:
```sh
open "http://$(docker-machine ip dev):8080/"
Copy link
Contributor

Choose a reason for hiding this comment

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

remove dev

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

production:
branch: docker
commands:
- 'echo "machine api.heroku.com login rowan.manning@ft.com password ${HEROKU_AUTH_TOKEN}" >> ${HOME}/.netrc; chmod 0600 /home/ubuntu/.netrc;'
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: This application will fail to deploy from CI is @rowanmanning ever renews his Heroku authentication token.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could maybe do with an Origami Heroku account for this kind of thing? It would also fail if I ever get removed from the Heroku org.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this is not something the Heroku Working Group within the FT advocate people to do.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, we'll just need to keep an eye on it then

Choose a reason for hiding this comment

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

Yeah, this kind of sucks. I'm using my account for browser tests with nightwatch

Choose a reason for hiding this comment

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

in Next we use my HEROKU_AUTH_TOKEN and push it out to all our CircleCI configs. I can setup origami-build-service with this if you like and then Next can manage this for you ^^

Choose a reason for hiding this comment

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

For the unitiated, what does the machine command do and how is it available in the circle environment?

Choose a reason for hiding this comment

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

@triblondon run this on your mac cat ~/.netrc

Copy link
Contributor

Choose a reason for hiding this comment

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

You can create an Origami heroku account by the way, I spoke with the Heroku Working Group and they verified this is a good approach for Origami to take with it's deployments.

@alicebartlett
Copy link
Member

this is a huge improvement to our deployment process, and this PR explains your changes really well too.


[**{.yml}]
indent_style = space
indent_size = 2

Choose a reason for hiding this comment

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

should me move this stuff into obt?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could have a copy in there, yes, but the editorconfig plugins rely on there being a .editorconfig file in the project root.

Choose a reason for hiding this comment

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

Do you mean the IDE plugins? We should probably discuss what's the best way
to use editorconfig


This email was sent by a company owned by Financial Times Group Limited
("FT Group http://aboutus.ft.com/corporate-information/#axzz3rajCSIAt"),
registered office at Number One Southwark Bridge, London SE1 9HL.
Registered in England and Wales with company number 879531. This e-mail may
contain confidential information. If you are not the intended recipient,
please notify the sender immediately, delete all copies and do not
distribute it further. It could also contain personal views which are not
necessarily those of the FT Group. We may monitor outgoing or
incoming emails as permitted by law.

@triblondon
Copy link

Very nice.

@rowanmanning rowanmanning changed the title [do not merge] Docker Update and Continuous Deployment Docker Update and Continuous Deployment Mar 15, 2016
rowanmanning added a commit that referenced this pull request Mar 15, 2016
Docker Update and Continuous Deployment
@rowanmanning rowanmanning merged commit 97cd304 into master Mar 15, 2016
@rowanmanning rowanmanning deleted the docker branch March 15, 2016 09:56
"build": "touch ./appversion; docker-compose build; rm -f ./appversion"

"build": "docker build -t registry.heroku.com/origami-buildservice-qa/web .",
"deploy": "docker push registry.heroku.com/origami-buildservice-qa/web"

Choose a reason for hiding this comment

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

Just been thinking a bit more about this. It seems like these scripts are a mixture of tasks run inside the container and tasks run outside the container. Maybe we should follow Next and use Make to standardise outside-container-tasks like building the container and deploying it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure thing, these dont depend on node modules so I see no issue extracting into a makefile.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm definitely up for adding a Makefile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants