To start server at 8080: stack run
.
API endpoints:
GET /
-- gives HTML form for testing /shorten endpoint using browserPOST /shorten
-- shortens an url given as form fieldurl
or request body withplain/text
content type with default encoding (ASCII) orcharset=utf-8
GET /...
-- shortened URLs redirection
Using latest AWS CLI and AWS AppRunner.
-
Need following variables:
- AWS
USERID
-- this number is attached to each AWS account - AWS
REGION
-- very few regions currently support AppRunner, includingeu-west-1
andus-east-1
- AWS ECR repository name -- you may pick your own, yet unused in your account
- AWS
-
Create AWS ECR repository within ${REGION}:
aws ecr create-repository --name ${ECR_REPOSITORY_NAME} --region ${REGION}
-
Create AppRunner service within ${REGION} with private ECR ImageRepository source. (This is the best documented, running from AWS CLI still seems to want JSON template.) I also suggest to automatically redeploy service on push. All other options may be left at their default values.
-
Logging to AWS ECR repo with AWS access key:
aws ecr get-login-password --region ${REGION} | docker login --username AWS --password-stdin ${USERID}.dkr.ecr.${REGION}.amazonaws.com/apprunner
-
Build and push latest image (which should automatically deploy it as indicated in 3):
docker build . -f Dockerfile -t my-demo docker tag my-demo:latest ${USERID}.dkr.ecr.${REGION}.amazonaws.com/apprunner docker push ${USERID}.dkr.ecr.${REGION}.amazonaws.com/apprunner