This is a take-home project assigned to Siddharth.
- Dockerize the Caching service app
Prerequisites:
- I prefer Ubuntu 16.04
- Docker
- Redis Cluster
- PEM key for Ec2 instances
- Create a docker repository on Docker Hub. (You should already have an account)
- Login into your docker account from the local machine
docker login
- Insert your credentials
- Create a GitHub public repository and clone it on the local system.
- Create a DockerFile (Please refer to the Dockerfile on this repository)
- Add the python file
- Build the docker image
docker build -t <username>/caching-service
- Check the images by running
docker image ls
- Run the docker container by running this command
docker run -p 3000:3000 -e PORT=3000 -e REDIS_URL=http://34.208.xxx.49 <username>/caching-service
REDIS_URL
andPORT
are declared as env variables.- Check the container name & status by running this command
docker ps
- Tag the docker service by
docker latest caching-service:latest caching-service:latest
- Finally, push your image to the docker hub repository by running this command
docker push <username>/caching-service
- Deploy your service to Heroku
- Install Heroku on the local machine using
snap install --classic heroku
heroku login
not required as opposed using an API key- Store your API key in
~/.netrc
file - Create a
heroku.yml
file with all required dependencies - heroku.yml - Install Heroku container registry plugin by using
heroku plugins:install @heroku-cli/plugin-container-registry
- Change the login mode to Heroku container by typing
heroku container : login
- Create a Heroku container app by using
heroku create -a <appname>
- Push the container by hitting
heroku container:push web -a <imagename>
- Release the container by using
heroku container:release web -a <imagename>
- Open the created app by using
heroku open
- All the above steps are automated on shell script- gumgum.sh
- Build a Drone deployment pipeline
- Create a Drone CI account and authenticate with your GitHub account.
- Create a Git Webhook and add the Drone CI authentication token and payload URL
https://cloud.drone.io
(grab token from the user settings page on Drone CI) and create the action triggers. The below image describes the process. - Create a .drone.yml file for all running dependencies to trigger a build step.
- Multi-key support Script was improved by closely matching the requirement - extended.py
Slack Channel Alert
- The drone.yml file has this code appended at the bottom
- Grab the Slack webhook from the Administration -> Applications -> Webhooks page on your Slack Admin Workspace
- Attach the webhook to a channel of your choice
- Insert these details on the script above
steps:
- name: slack
image: plugins/slack
settings:
webhook: <https://hooks.slack.com/services/...>
channel: <your channel>
link_names: true
template: >
{{#success build.status}}
build {{build.number}} succeeded. Good job. <your email>
{{else}}
build {{build.number}} failed. Please fix this <@channelname> <@someone>
{{/success}}