Giter VIP home page Giter VIP logo

belly_bot's Introduction

The BellyBot Food Truck App Build Status

This app answers the question, "What's for lunch today?" by providing a list of San Francisco food trucks along with their known street locations and the types of foods they serve. The goal is to showcase a variety of options and help users discover new places to eat.


Running the Code

You can pull down the repo and run it locally:

$ git clone [email protected]:marka2g/belly_bot.git
$ cd belly_bot

# Run the server with a REPL
$ iex -S mix phx.server

And then, seed some Food Truck data:

iex> BellyBot.GlobalSetup.seed_food_trucks()

# check the food truck count
iex> BellyBot.FoodTrucks.list_food_trucks() |> Enum.count()

Running & Deploying the App

Currently, there are two ways to deploy this app to production:

  1. Continuous Delivery → Once a PR is merged into the main branch and CI checks run successfully, the composite actions/deploy/action.yaml will deploy the app to a docker swarm on AWS.
  2. Manually → The ./scripts/deploy.sh script can also be run with a key file(available upon request).
  • the script requires three environment variables to be passed in:
    • PRIVATE_KEY_PATH located in the ./environments/production directory
    • SOPS_AGE_KEY_FILE key file
    • GITHUB_USER

example:

$ PRIVATE_KEY_PATH=./environments/production/dynamic_private_key.pem \
SOPS_AGE_KEY_FILE=./environments/production/key.txt \
GITHUB_USER=marka2g \
./scripts/deploy.sh

Development Status & Time Spent

Start by checking the repo's Milestones Panel, which serves as the perfect starting point. Here, you'll discover various issues that track the project's progress.

In my overall allocation of time, the belly_bot Phoenix app received the least attention, and there are a few reasons for this. Firstly, I find the process of building an app with Elixir, Phoenix Live View and app development in general to be the most enjoyable. However, I've learned over the years that planning ahead and addressing less enjoyable tasks are crucial for the project's longevity and momentum. Taking the time to chart a clear path forward makes development more focused, and prioritizing issues via milestones enables the team to work and communicate more efficiently.

That said, I've grown fond of Terraform, particularly for greenfield projects. Besides its ability to magically assist with provisioning platform resources, I deeply appreciate the project management tools it provides. Terraform has given me the freedom and confidence to pause, think, and plan before diving into coding, ultimately enhancing the product's quality. Furthermore, it has bolstered my ability to estimate time and prioritize tasks more effectively.

As to the time I spent, the type of development proposed in this assessment, mirrors patterns and development work I've been currently engaged in. Last week was quite busy for me so I had to work when time permitted. Having a healthy set of bootstrapped issues really helped. This project was quite enjoyable; turns out, I too like too eat :-). I plan to keep developing on the idea for fun and add more features, such as:

  1. Geographical searching with the PostGIS Postgres extension
  2. Improve search by parsing days_hours and food_items data
  3. Instrumentation with Prometheus and a Grafana dashboard
  4. and well, basically develop the UI, and design.

Thank you so much for the awesome idea and the opportunity!


A Rough Sketch of the Technology Stack

→ Github Milestones & Issues, provisioned with Terraform

located in this directory ./modules/cloud/aws/compute/swarm

web: Elixir/Phoenix Live View

db: Postgres 16

→ Single-node Docker Swarm manages an AWS/EC2 Instance/Security Group/VPC/Subnet, provisioned with Terraform.

located in this directory ./modules/integrations/github

→ Packer with an Amazon Machine(Linux) Instance with Docker preinstalled, provisioned with Terraform.

located in this directory ./packer

Encrypted Secrets with SOPS, provisioned with Terraform

located in this directory ./modules/integrations/github/secrets


EC2 Production Status

Currently, an EC2 instance is running on AWS, and at the time of writing, it is live at this address: http://ec2-54-193-68-139.us-west-1.compute.amazonaws.com:4000. I submitted an issue here to investigate why the Docker Swarm EC2 instance and volume are not communicating.

belly_bot's People

Contributors

marka2g avatar

Watchers

 avatar

belly_bot's Issues

Fix Deploy Script

Error: /home/runner/work/belly_bot/belly_bot/./.github/actions/deploy/action.yaml (Line: 42, Col: 7): There's not enough info to determine what you meant. Add one of these properties: run, shell, uses, with, working-directory
Error: System.ArgumentException: Unexpected type '' encountered while reading 'steps item uses'. The type 'StringToken' was expected.
   at GitHub.DistributedTask.ObjectTemplating.Tokens.TemplateTokenExtensions.AssertString(TemplateToken value, String objectDescription)
   at GitHub.DistributedTask.Pipelines.ObjectTemplating.PipelineTemplateConverter.ConvertToStep(TemplateContext context, TemplateToken stepsItem, ReferenceNameBuilder nameBuilder)
   at GitHub.DistributedTask.Pipelines.ObjectTemplating.PipelineTemplateConverter.ConvertToSteps(TemplateContext context, TemplateToken steps)
   at GitHub.Runner.Worker.ActionManifestManager.ConvertRuns(IExecutionContext executionContext, TemplateContext templateContext, TemplateToken inputsToken, String fileRelativePath, MappingToken outputs)
   at GitHub.Runner.Worker.ActionManifestManager.Load(IExecutionContext executionContext, String manifestFile)
Error: Failed to load /home/runner/work/belly_bot/belly_bot/./.github/actions/deploy/action.yaml

Push Docker Image to GitHub Registry for CI/CD Pipeline

Automate the pushing of your Docker image to the GitHub Docker registry if
your CI pipeline passes. Authentication with the registry is required before
being able to push. You should create three tags for your Docker image: one
matching the commit it refers to, one matching the PR number (if present),
and other that is "latest".

Create a Continuous Deployment Pipeline

Add a new GitHub action to your CI/CD pipeline that automatically deploys
your Phoenix Live View application any time any code is merged into the main
branch of your repository. This action should use the build tags that are
created in the CI pipeline.

Improve the Parsing of `day_hours`

Currently, the dayshours string that s returned from SF food truck data has multiple patterns. Write a function to extract significant bits of data to improve search.

Create the EC2 AMI (Amazon Machine Image)

Use Packer to create a custom AMI for your EC2 instances and then link it
to your existing AWS Terraform infrastructure. This AMI should pre-install
Docker and netcat.

Make the Elixir App Autoscale

Adapt your AWS Terraform configuration to use an Auto Scaling Group so that
your Elixir application scales up/down depending on the average CPU usage of
the EC2 intances in that group.

Think Out Loud in Documentation

  1. Discuss -> open source project. Create a repo on Github, use git for source control, and use a Readme file to document what you built for the newcomer to your project.
  2. Document how to get started in terms of setup so EL would be able to run it.

Create Production ENV in AWS for a single-node

Add all of the AWS resources that will allow you to deploy your application
to a remote single-node to your Terraform configuration. (Making the
resources support a multi-node will be in another task). Required: an EC2
instance, a VPC, a security group, and an SSH key pair.

Connect to an EC2 Instance to Seed Food Trucks

Once the dynamic_private_key.pem key has been ssh-added and the currently running instance's IP has been written to your local known_hosts file, use the DOCKER_HOST env var to connect to an iex session.

example:

$ ssh-add ./environments/production/dynamic_private_key.pem

$ ssh-keyscan -H 54.193.68.139 >> ~/.ssh/known_hosts

connect to an iex> REPL

$ DOCKER_HOST=ssh://[email protected] iex -S mix

and seed some data

iex> BellyBot.GlobalSetup.seed_food_trucks()

# check the food truck count
iex> BellyBot.FoodTrucks.list_food_trucks() |> Enum.count()

ISSUE:
The data gets seeded but is not showing up in the application. Perhaps the docker instance and volume are not communicating? More investigation needed.

Elixir Integration Pipelines

Implement a CI pipeline that includes all of the necessary steps when
delivering an Elixir application: code compilation, dependency caching,
testing, code formatting, an unused dependency check.

Fix EC2 `GET /live/longpoll?_csrf_token=` Error on Browser's Network Panel

Once an EC2 instance is deployed and available to navigate to, ec2-54-193-68-139.us-west-1.compute.amazonaws.com:4000 -> 2500k network panel errors ensue.

GET http://ec2-54-193-68-139.us-west-1.compute.amazonaws.com:4000/live/longpoll?_csrf_token=ExEsFRwaeBU7FBAJIDsoajNCaT1vKQtRrKaDxTUpcmcALcC8Gz0_XCs8&_track_static[0]=http://ec2-54-193-68-139.us-west-1.compute.amazonaws.com:4000/assets/app-a86ae2aa16a2e20e835a380067392207.css?vsn=d&_track_static[1]=http://ec2-54-193-68-139.us-west-1.compute.amazonaws.com:4000/assets/app-a7b7a1bb2570182b93179aee6863d1bb.js?vsn=d&_mounts=0&_live_referer=undefined&vsn=2.0.0&=

Implement Basic Instrumentation

Use Loki, Promtail agent to collect the logs for your Docker containers and
Grafana to display them. Then use Prometheus/PromEx to collect the
metrics exposed by the main libraries used in an Elixir application.

Implement the Runner Stage Dockerfile

This stage copies the release built in the builder stage and uses it as the
entrypoint of your Docker image with the minimum system requirement to run
it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.