WSO2 API MANAGER apis data persitence in docker container

  api-manager, docker, docker-volume, wso2, wso2-am

I am currrently using 4 WSO2 modules inside my docker-compose file as shown below:

mysql:
    image: mysql:5.7.31
    container_name: mysql
    ports:
      - 3306
    environment:
      MYSQL_ROOT_PASSWORD: root
    volumes:
      - ./conf/mysql/scripts:/docker-entrypoint-initdb.d
      - ./conf/mysql/conf/my.cnf:/etc/mysql/my.cnf
    ulimits:
      nofile:
        soft: 20000
        hard: 40000
    command: --ssl=0 --max_connections=10000
    healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-uroot", "-proot"]
      interval: 30s
      timeout: 60s
      retries: 5
      start_period: 80s

  am-analytics-worker:
    image: wso2am-analytics-worker:3.2.0
    container_name: am-analytics-worker
    ports:
      - "9091"
      - "9444"
    healthcheck:
      test: ["CMD", "nc", "-z","localhost", "9444"]
      interval: 10s
      start_period: 20s
      retries: 5
    depends_on:
      mysql:
        condition: service_healthy
    volumes:
      - ./conf/apim-analytics-worker:/home/wso2carbon/wso2-config-volume

  api-manager:
    image: wso2am:3.2.0
    container_name: api-manager
    healthcheck:
      test: ["CMD", "nc", "-z","localhost", "9443"]
      interval: 10s
      start_period: 180s
      retries: 20
    depends_on:
      mysql:
        condition: service_healthy
      am-analytics-worker:
        condition: service_healthy
    volumes:
      - ./conf/apim:/home/wso2carbon/wso2-config-volume
      - ./conf/apim_artifacts:/home/wso2carbon/wso2-artifact-volume

    ports:
      - "9443:9443"
      - "8280:8280"
      - "8243:8243"
      
  am-analytics-dashboard:
    image: wso2am-analytics-dashboard:3.2.0
    container_name: am-analytics-dashboard
    ports:
      - "9643:9643"
    healthcheck:
      test: ["CMD", "nc", "-z","localhost", "9643"]
      interval: 10s
      retries: 5
      start_period: 20s
    depends_on:
      mysql:
        condition: service_healthy
      api-manager:
        condition: service_healthy
    volumes:
      - ./conf/apim-analytics-dashboard:/home/wso2carbon/wso2-config-volume

I have create somed apis in WSO2 Api Manager and the issue is that if my container reboots I loose all my APIs.

So here is what I tried in order to have some data persistence with my apis so that they remain avaible even if the Api Manager container reboots.

First, I copied the whole wso2am-3.2.0 folder from the container to my computer and then based on this link (WSO2 Runtime Artifacts) I have created a folder named "apim_artifacts" and inside I have placed the 4 runtime artifacts (<API-M_HOME>/repository/deployment/server, <API-M_HOME>/repository/tenants, <API-M_HOME>/solr, <API-M_HOME>/repository/database) as suggested by the WSO2 documentation.

Now, when I compose my project the apis are still not visible in the publisher.

localhost:9443/publisher/apis

But if I go check inside the Api Manager container I can see that all the folders I have mounted with my volume have been copied and mapped into their respective folders (I can even see all my apis inside the /home/wso2carbon/wso2am-3.2.0/repository/deployment/server/synapse-configs/default/endpoints folder).

Am I missing something or is there something I am doing wrong?

Could you please help me out?

Regards,

Source: Docker Questions

LEAVE A COMMENT