Git Product home page Git Product logo

laravel-ecs-demo's Introduction

Laravel on ECS Demo

Build and run with docker-compose (local)

$ docker-compose up --build

Build assets

$ docker-compose run --rm nodejs bash -c "npm install && npm run dev"

Build and push docker to AWS ECR (Elastic Container Registry)

Create ECR repository

Create 2 repositories for nginx and php-fpm. Like below.

  • laravel-ecs-demo/nginx
  • laravel-ecs-demo/php-fpm

docker login (with latest awscli)

$ pip install awscli --upgrade
$ $(aws ecr get-login --no-include-email --region ${AWS_DEFAULT_REGION})

Build nodejs and assets(js/css)

$ docker build -t nodejs -f docker/nodejs/Dockerfile .
$ docker run --rm -v $(pwd):/build -w /build nodejs npm install
$ docker run --rm -v $(pwd):/build -w /build nodejs npm run dev

Build php-fpm/nginx

$ docker build -t ${REPOSITORY_URI_PHP_FPM}:latest -f docker/php-fpm/Dockerfile .
$ docker build -t ${REPOSITORY_URI_NGINX}:latest -f docker/nginx/Dockerfile .

Add tags

$ docker tag ${REPOSITORY_URI_PHP_FPM}:latest ${REPOSITORY_URI_PHP_FPM}:$IMAGE_TAG
$ docker tag ${REPOSITORY_URI_NGINX}:latest ${REPOSITORY_URI_NGINX}:$IMAGE_TAG

Push docker image

$ docker push ${REPOSITORY_URI_PHP_FPM}:latest
$ docker push ${REPOSITORY_URI_PHP_FPM}:$IMAGE_TAG
$ docker push ${REPOSITORY_URI_NGINX}:latest
$ docker push ${REPOSITORY_URI_NGINX}:$IMAGE_TAG

Create Task definition

namelaravel-ecs-demo
Launch typeEC2

Add php-fpm container

name php-fpm
image (uri) ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/php-fpm:latest
working directory /app
memory 300

Add nginx container

name nginx
image (uri) ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/nginx:latest
port mapping tcp 80:80
memory 300
links php-fpm

Create ECS Cluster

namelaravel-ecs-demo-cluster
cluster compatibilityEC2 Linux + Networking
EC2 Instance typet2.small
Provisioning modelSpot
Number of instances2
Maximum bid price (per instance/hour)10($)

Create ALB (Application load balancer)

Availability Zone(Choose from VPC of ECS Cluster)
ListenersHTTP 80
Target instances(Choose from Availability Zone)

Create Service in ECS Cluster

Launch typeEC2
Task definitionlaravel-ecs-demo
Clusterlaravel-ecs-demo-cluster
Service namelaravel-ecs-demo
Service typeREPLICA
Load balancer typeApplication Load Balancer
Container to load balancenginx:80:80
Listener port80:HTTP
Target Group(Choose of ALB)

laravel-ecs-demo's People

Contributors

imunew avatar

Watchers

James Cloos avatar Filipe Moraes Mendes 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.