Search code examples
dockeraws-fargatefusionauth

Creating app and search containers to run in AWS ECS/Fargate


In our situation we want to run an app container and a search container as separate services on our ECS cluster.

I need to create a search container to run under ECS/Fargate and linked to a load balancer.

I need to create an app container which is able to talk to our PostgreSQL RDS instance, which already has the fusionauth tables setup, and talk to the search container through the load balancer.

I started with the docker-compose.yaml and deleted the db service. I changed the values in the fusionauth section to

  fusionauth:
    image: fusionauth/fusionauth-app:latest
    depends_on:
      - search
    environment:
      DATABASE_URL: jdbc:postgresql://mypostgre-rds-endpoint:5432/fusionauth
      DATABASE_ROOT_USER: root_user_account
      DATABASE_ROOT_PASSWORD: root_user_password
      DATABASE_USER: fusionauth
      DATABASE_PASSWORD: fusionauth_user_password
      FUSIONAUTH_MEMORY: ${FUSIONAUTH_MEMORY}
      FUSIONAUTH_SEARCH_SERVERS: http://search:9200
      FUSIONAUTH_URL: http://load-balancer-url:9011
    networks:
     - db
     - search
    restart: unless-stopped
    ports:
      - 9011:9011
    volumes:
      - fa_config:/usr/local/fusionauth/config

The first issue is that when i run this container, it goes into maintenance mode and tries to create the database. I get a locale error. I don't need maintenance mode, I just need it to connect to the database. So I think I must have the database url defined incorrectly.

The second problem, is I need to be able to do the same thing for search: create a container that runs under ECS/Fargate and accessed through the load balancer.

I am no docker expert (yet). But I can't find any specific documentation to help me figure out how to configure and deploy the search and the app containers.

Any pointers to existing docs, or help is appreciated to get this running.

I know i have to change the search section in the docker-compose file (posted entirely below) but I don't yet know what to change, or how to build the container for search yet.

Entire docker-compose file as it stands right now.

version: '3'

services:

  search:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.3.1
    environment:
      - cluster.name=fusionauth
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=${ES_JAVA_OPTS}"
    ports:
      - 9200:9200
      - 9300:9300
    networks:
      - search
    restart: unless-stopped
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - es_data:/usr/share/elasticsearch/data

  fusionauth:
    image: fusionauth/fusionauth-app:latest
    depends_on:
      - search
    environment:
      DATABASE_URL: jdbc:postgresql://mypostgre-rds-endpoint:5432/fusionauth
      DATABASE_ROOT_USER: root_user_account
      DATABASE_ROOT_PASSWORD: root_user_password
      DATABASE_USER: fusionauth
      DATABASE_PASSWORD: fusionauth_user_password
      FUSIONAUTH_MEMORY: ${FUSIONAUTH_MEMORY}
      FUSIONAUTH_SEARCH_SERVERS: http://search:9200
      FUSIONAUTH_URL: http://load-balancer-url:9011
    networks:
     - db
     - search
    restart: unless-stopped
    ports:
      - 9011:9011
    volumes:
      - fa_config:/usr/local/fusionauth/config

networks:
  db:
    driver: bridge
  search:
    driver: bridge

volumes:
  db_data:
  es_data:
  fa_config:

Solution

  • AFAICT there is no reason you should be using DATABASE_ROOT_USER and DATABASE_USER if the db is already setup

    I would suggest you could start by removing that but other than that it looks pretty similar to a docker-compose setup I've been using for a while

    The only other thing I'd add is this problem has nothing to do with ECS or Fargate at all as it sits, its really just a docker compose file you are having trouble getting running from what I can tell