Code Monkey home page Code Monkey logo

hello-app-runner's Introduction

Hello App Runner

This is a example web service for AWS App Runner. You can use this repo to automatically build and deploy or use pre-built images at ECR Public.

You can read about AWS App Runner in the launch blog

Deploy to App Runner

If you want to deploy this container make sure you have the latest release of the awscli and run

SERVICE_NAME=hello-app-runner

cat > hello-app-runner.json <<EOF
{
    "ImageRepository": {
        "ImageIdentifier": "public.ecr.aws/aws-containers/hello-app-runner:latest",
        "ImageConfiguration": {
            "Port": "8000"
        },
        "ImageRepositoryType": "ECR_PUBLIC"
    },
    "AutoDeploymentsEnabled": false
}
EOF

aws apprunner create-service --service-name ${SERVICE_NAME} \
    --source-configuration file://hello-app-runner.json

If you want to deploy and manage this container using AWS CloudFormation just run

SERVICE_NAME=hello-app-runner

aws cloudformation create-stack --template-body file://cf.yaml --stack-name ${SERVICE_NAME} --parameters "ParameterKey=ServiceName,ParameterValue=${SERVICE_NAME}"

Features

The service exposes a basic splash page with links to relevant App Runner content. It has two unique features which benefit from running it in App Runner.

Upon first request it generates a unique avatar for each service which is saved in ./static/social.png. This image is used for social preview images when shared online and will be the same across different all of your container instances. It is an example of using a local disk for small assets in an application.

The service also provides a /metrics endpoint so you can see some of the long running metrics of requests coming into the service. This is an example of global state stored on a per container basis. It can be used for state management, in memory cache, or other application needs.

There also might be an easter egg or two if you read the code. ;)

Development

To run this application locally you can use pipenv

pipenv install
pipenv run python app.py

To run the application locally in a container you can use docker

docker build -t hello-app-runner .
docker run -it -p 8000:8000 hello-app-runner

hello-app-runner's People

Contributors

branst avatar rothgar avatar toricls avatar

Watchers

 avatar

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.