Coder Social home page Coder Social logo

drupal's Introduction

Deploy Drupal with PostgreSQL to AWS ECS using Docker Compose

AWS ECS (EC2 mode)

# Drupal with PostgreSQL in AWS ECS
#
# During initial Drupal setup:
# Database type: PostgreSQL
# Database name: postgres
# Database username: postgres
# Database password: [AWS Secret]
# ADVANCED OPTIONS; Database host: postgres

# x-aws-vpc: ECS VPC ID
# x-aws-cluster: ECS Cluster Name  
# Also EC2 network (Security Group ID) & AWS secret could be explicitly specified below

version: '3.1'

x-aws-vpc: "vpc-xxxxxxxxxxxxxxx"
x-aws-cluster: "your cluster name"

services:

  drupal:
    image: drupal:9.4-apache
    ports:
      - 80:80
    networks:
      - ec2_network
    volumes:
      - modules:/var/www/html/modules
      - profiles:/var/www/html/profiles
      - themes:/var/www/html/themes
      - sites:/var/www/html/sites
    restart: always

  postgres:
    image: postgres:10
    networks:
      - ec2_network
    volumes:
      - pgdata:/var/lib/postgresql/data
    secrets:
      - postgres_password
    environment:
       POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
    restart: always

networks:
  ec2_network:
    external: true
    name: "sg-xxxxxxxxxxxxxx"

volumes:
  modules:
  profiles:
  themes:
  sites:
  pgdata:

secrets:
  postgres_password:
    name: "arn:aws:secretsmanager:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    external: true

x-aws-cloudformation:
  Resources:
    DrupalTCP80TargetGroup:
      Properties:
        HealthCheckPath: /
        Matcher:
          HttpCode: 200-499

Command to deploy to AWS ECS (EC2 mode)

docker --context myecscontext compose -f ecs-ec2-docker-compose.yaml up -d

Note: Running in detached mode "-d" is needed becase of the open issue: docker-archive/compose-cli#2086


AWS ECS (Fargate mode)

# Drupal with PostgreSQL in AWS ECS
#
# During initial Drupal setup:
# Database type: PostgreSQL
# Database name: postgres
# Database username: postgres
# Database password: example
# ADVANCED OPTIONS; Database host: postgres

# x-aws-vpc: ECS VPC ID
# x-aws-cluster: ECS Cluster Name

version: '3.1'

x-aws-vpc: "vpc-xxxxxxxxxxxxxxxx"
x-aws-cluster: "your cluster name"

services:

  drupal:
    image: drupal:9.4-apache
    ports:
      - 80:80
    volumes:
      - modules:/var/www/html/modules
      - profiles:/var/www/html/profiles
      - themes:/var/www/html/themes
      - sites:/var/www/html/sites
    restart: always

  postgres:
    image: postgres:10
    volumes:
      - pgdata:/var/lib/postgresql/data
    environment:
       POSTGRES_PASSWORD: "example"
    restart: always

volumes:
  modules:
  profiles:
  themes:
  sites:
  pgdata:

Command to deploy to AWS ECS (Fargate mode)

docker --context myecscontext compose -f ecs-fargate-docker-compose.yaml up -d

Note: Running in detached mode "-d" is needed becase of the open issue: docker-archive/compose-cli#2086


Local deployment

# Drupal with PostgreSQL
#
# Access via "http://localhost:8080"
#   (or "http://$(docker-machine ip):8080" if using docker-machine)
#
# During initial Drupal setup,
# Database type: PostgreSQL
# Database name: postgres
# Database username: postgres
# Database password: example
# ADVANCED OPTIONS; Database host: postgres

version: '3.1'

services:

  drupal:
    image: drupal:9.4-apache
    ports:
      - 80:80
    volumes:
      - modules:/var/www/html/modules
      - profiles:/var/www/html/profiles
      - themes:/var/www/html/themes
      - sites:/var/www/html/sites
    restart: always

  postgres:
    image: postgres:10
    volumes:
      - pgdata:/var/lib/postgresql/data
    environment:
       POSTGRES_PASSWORD: example
    restart: always

volumes:
  modules:
  profiles:
  themes:
  sites:
  pgdata:

Command to deploy locally

docker compose -f local-docker-compose.yaml up

Note: Running in detached mode "-d" is needed becase of the open issue: docker-archive/compose-cli#2086

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.