Git Product home page Git Product logo

craftcms-aws's Introduction

Craft CMS on AWS

This project shows how to run Craft CMS on Amazon Web Services. It is deployed as Docker images to Amazon ECS using CircleCI for continuous integration. The build pipeline uses npm to generate the site's CSS from customisable Bootstrap SCSS.

Getting started

Follow these steps to create a Craft CMS site on AWS.

1. Create your project

Start by creating your own project:

  1. Fork this project to your own GitHub account
  2. Clone your repository locally

2. Configure AWS

We'll use Amazon Web Services to host your site.

  1. Create an Amazon Web Services account if you haven't already got one
  2. Create admin user
  3. Create a key pair admin-key-pair-london
  4. Create ci user
  5. Create ci group with policies:
    • AmazonEC2ContainerRegistryPowerUser
    • AmazonEC2ContainerServiceFullAccess (?)
  6. Decide on an AWS region, e.g. eu-west-2

3. Configure CircleCI

We'll use CircleCI for continuous integration.

  1. Sign up to CircleCI with your GitHub account if you haven't already done so
  2. Add your forked project
  3. Add the following environment variables to the project with your ci user credentials and chosen region:
    • AWS_ACCOUNT_ID
    • AWS_ACCESS_KEY_ID
    • AWS_SECRET_ACCESS_KEY
    • AWS_DEFAULT_REGION

4. Install AWS CLI

We'll use the Amazon CLI tools to bring up the necessary infrastructure.

  1. Install AWS CLI
  2. Configure AWS CLI using your admin user credentials and chosen region
  3. Install Amazon ECS CLI
  4. Configure Amazon ECS CLI using your admin user credentials and chosen region:
ecs-cli configure profile --profile-name default --access-key ${AWS_ACCESS_KEY_ID} --secret-key ${AWS_SECRET_ACCESS_KEY}
ecs-cli configure --cluster craftcms-aws --region ${AWS_DEFAULT_REGION} --config-name default

5. Create AWS infrastructure

To create your Amazon ECR and ECS services:

./bin/aws-up.sh

Note that you'll be charged for these services until they are destroyed.

6. Deploy site

Push a change and CircleCI will deploy the site to AWS. Once the job is complete find the site's IP address using:

ecs-cli ps

Visit http://<ip-address>/admin to run the Craft CMS installer. Once complete, visit http://<ip-address> to view your site.

Running locally

You can run the site locally as follows:

  1. npm install
  2. npm run dist
  3. docker-compose up --build
  4. Visit http://localhost/admin

To watch SCSS:

npm run watch

Destroy AWS infrastructure

To destroy the services:

./bin/aws-down.sh

Using CloudFormation (Experimental)

There's work-in-progress to use AWS CloudFormation rather than the AWS CLI to provision the infrastructure. The CloudFormation template template.yml currently deploys a vanilla CraftCMS instance to AWS ECS using RDS for the database.

To create the stack:

aws cloudformation create-stack --stack-name craftcms-aws --template-body file://template.yml --capabilities CAPABILITY_IAM

To destroy the stack:

aws cloudformation delete-stack --stack-name craftcms-aws

TODO

  • Style news templates
  • Automate CircleCI primary image build in DockerHub
  • Ensure database is private
  • Prod/dev environments
  • Fargate
  • CloudFormation (in progress)
  • RDS (in progress)
  • DNS
  • SSL
  • Local deployment (i.e. execute .circleci/config.yml locally)

craftcms-aws's People

Contributors

markhobson 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.