Usando AWS re:Post, accetti AWS re:Post Termini di utilizzo

Docker Compose services to Fargate tasks/services

0

Hi Everyone. I am trying to set up ERPNext on AWS ECS(Fargate). I used frappe_docker to setup locally. I want to create containers in task definition of AWS ECS Fargate according to the services in yaml file. I have mentioned the content of yaml file below. I am stuck at

  • setting depends_on property while defining
  • defining volumes as defined in the YAML file. I have given the YAML file according to which I want to define tasks in AWS ECS.

I am new to AWS services. Pardon me for any ambiguous information

name: frappe_docker
services:
  backend:
    depends_on:
      configurator:
        condition: service_completed_successfully
    image: frappe/erpnext-worker:v14.2.2
    networks:
      default: null
    volumes:
    - type: volume
      source: sites
      target: /home/frappe/frappe-bench/sites
      volume: {}
    - type: volume
      source: assets
      target: /home/frappe/frappe-bench/sites/assets
      read_only: true
      volume: {}
  configurator:
    command:
    - configure.py
    environment:
      DB_HOST: ***.rds.amazonaws.com
      DB_PORT: "3306"
      REDIS_CACHE: ***.cache.amazonaws.com:6379/0
      REDIS_QUEUE: ***.cache.amazonaws.com:6379/1
      REDIS_SOCKETIO: ***.cache.amazonaws.com:6379/2
      SOCKETIO_PORT: "9000"
    image: frappe/erpnext-worker:v14.2.2
    networks:
      default: null
    volumes:
    - type: volume
      source: sites
      target: /home/frappe/frappe-bench/sites
      volume: {}
    - type: volume
      source: assets
      target: /home/frappe/frappe-bench/sites/assets
      read_only: true
      volume: {}
  frontend:
    depends_on:
      backend:
        condition: service_started
      websocket:
        condition: service_started
    environment:
      BACKEND: backend:8000
      FRAPPE_SITE_NAME_HEADER: $$host
      SOCKETIO: websocket:9000
      UPSTREAM_REAL_IP_ADDRESS: 127.0.0.1
      UPSTREAM_REAL_IP_HEADER: X-Forwarded-For
      UPSTREAM_REAL_IP_RECURSIVE: "off"
    image: frappe/erpnext-nginx:v14.2.2
    networks:
      default: null
    volumes:
    - type: volume
      source: assets
      target: /usr/share/nginx/html/assets
      volume: {}
    - type: volume
      source: sites
      target: /usr/share/nginx/html/sites
      volume: {}
  queue-default:
    command:
    - bench
    - worker
    - --queue
    - default
    depends_on:
      configurator:
        condition: service_completed_successfully
    image: frappe/erpnext-worker:v14.2.2
    networks:
      default: null
    volumes:
    - type: volume
      source: sites
      target: /home/frappe/frappe-bench/sites
      volume: {}
    - type: volume
      source: assets
      target: /home/frappe/frappe-bench/sites/assets
      read_only: true
      volume: {}
  queue-long:
    command:
    - bench
    - worker
    - --queue
    - long
    depends_on:
      configurator:
        condition: service_completed_successfully
    image: frappe/erpnext-worker:v14.2.2
    networks:
      default: null
    volumes:
    - type: volume
      source: sites
      target: /home/frappe/frappe-bench/sites
      volume: {}
    - type: volume
      source: assets
      target: /home/frappe/frappe-bench/sites/assets
      read_only: true
      volume: {}
  queue-short:
    command:
    - bench
    - worker
    - --queue
    - short
    depends_on:
      configurator:
        condition: service_completed_successfully
    image: frappe/erpnext-worker:v14.2.2
    networks:
      default: null
    volumes:
    - type: volume
      source: sites
      target: /home/frappe/frappe-bench/sites
      volume: {}
    - type: volume
      source: assets
      target: /home/frappe/frappe-bench/sites/assets
      read_only: true
      volume: {}
  scheduler:
    command:
    - bench
    - schedule
    depends_on:
      configurator:
        condition: service_completed_successfully
    image: frappe/erpnext-worker:v14.2.2
    networks:
      default: null
    volumes:
    - type: volume
      source: sites
      target: /home/frappe/frappe-bench/sites
      volume: {}
    - type: volume
      source: assets
      target: /home/frappe/frappe-bench/sites/assets
      read_only: true
      volume: {}
  websocket:
    depends_on:
      configurator:
        condition: service_completed_successfully
    image: frappe/frappe-socketio:v14.10.0
    networks:
      default: null
    volumes:
    - type: volume
      source: sites
      target: /home/frappe/frappe-bench/sites
      volume: {}
networks:
  default:
    name: frappe_docker_default
volumes:
  assets:
    name: frappe_docker_assets
  sites:
    name: frappe_docker_sites
x-backend-defaults:
  depends_on:
    configurator:
      condition: service_completed_successfully
  image: frappe/frappe-worker:v14.10.0
  volumes:
  - sites:/home/frappe/frappe-bench/sites
  - assets:/home/frappe/frappe-bench/sites/assets:ro
x-depends-on-configurator:
  depends_on:
    configurator:
      condition: service_completed_successfully
x-erpnext-backend-image:
  image: frappe/erpnext-worker:v14.2.2
posta 2 anni fa405 visualizzazioni
1 Risposta
0

Hello. I did not know of frappe docker before, interesting to see others than me use extension fields for these things.

I'd recommend you try out ECS Compose-X which will do just exactly what you are trying to do. In ECS Compose-X, instead of using that configurator, you simply define the depends_on with the service names. The services of your docker-compose file that you want to see grouped together in the same task definition, as opposed to being their own services, you using the deploy.labels as described here. As for the success condition is ECS, you simply then use this label to define the desired outcome. Typically I use that for all my sidecars that would have to do something such as render environment configuration, test connectivity and so on, before the main application.

Compose-X will also automatically understand which containers are Essential and which ones are not (your sidecar doing the init, does not need to run forever typically).

I see that you also use RDS: you can use x-rds to lookup (via tags) your DB cluster/instance and allows you to define environment variables to your service obtained via API based discovery.

Note that there are a few other side projects to help with typically these things, such as files-composer which I now use all of the time to configure my NGINX and what not.

Checkout the labs for real-life examples.

Hope this helps, feel free to reach out if you wanted more details about ECS Compose-X.

profile picture
con risposta 2 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande