Docker Compose one-click deployment container

        With continuous development, more and more programs are running using containers, which will gradually increase the deployment pressure on software implementation engineers. At this time, deploying with docker compose will greatly save time.

        The following is the content of the docker-compose.yml file that I gradually wrote after spending two weeks visiting a large number of URLs:

version: '3.5' #版本号
services: #服务
  mongoDB:
    container_name: mongoDB
    image: mongo:5.0.3-focal
    restart: always
    volumes: #保存指定卷信息至创建的卷
      - mongo-data:/data/db
      - mongo-config:/data/configdb
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: Qivie20130113!
    ports:
    - 27017:27017
  postgres:
    image: postgres:14.4
    mem_limit: 512m
    container_name: postgres
    environment:
      - POSTGRES_PASSWORD=alfresco
      - POSTGRES_USER=alfresco
      - POSTGRES_DB=alfresco
    command: postgres -c max_connections=300 -c log_min_messages=LOG
    volumes: #保存指定卷信息至创建的卷
      - postgres-data:/var/lib/postgresql/data
      - ./create_database.sh:/docker-entrypoint-initdb.d/create_database.sh
    ports:
      - "5432:5432"
  mysql:
    container_name: mysql
    image: mysql:5.6.51
    restart: always
    volumes:
      - mysql-data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: Qivie20130113!
    ports:
      - 8283:3306
  keycloak:
    container_name: keycloak
    image: jboss/keycloak:7.0.0
    restart: always
    volumes:
      - keycloak-data:/opt/jboss/keycloak
    environment:
      DB_VENDOR: POSTGRES
      DB_ADDR: postgres
      DB_DATABASE: keycloak
      DB_USER: keycloak
      DB_PASSWORD: Qivie20130113!
      KEYCLOAK_USER: admin
      KEYCLOAK_PASSWORD: Qivie20130113!
      JDBC_PARAMS: 'useSSL=false'
    ports:
      - 9099:8080
    depends_on:
      - postgres
  Camunda: 
    container_name: Camunda
    image: camunda/camunda-bpm-platform:run-latest
    restart: always
    volumes:
      - camunda-data:/camunda
    environment:
      SKIP_DB_CONFIG: true
    ports:
    - 8081:8080
  minio: 
    container_name: minio
    image: minio/minio:latest
    restart: always
    volumes:
      - minio-data:/data
    command: server /data --console-address ":9001"
    ports:
    - 9000:9000
    - 9001:9001
  alfresco:
    image: alfresco/alfresco-content-repository-community:7.2.0-M2
    mem_limit: 1900m
    container_name: alfresco #容器名称
    environment:
      JAVA_TOOL_OPTIONS: "
        -Dencryption.keystore.type=JCEKS
        -Dencryption.cipherAlgorithm=DESede/CBC/PKCS5Padding
        -Dencryption.keyAlgorithm=DESede
        -Dencryption.keystore.location=/usr/local/tomcat/shared/classes/alfresco/extension/keystore/keystore
        -Dmetadata-keystore.password=mp6yc0UD9e
        -Dmetadata-keystore.aliases=metadata
        -Dmetadata-keystore.metadata.password=oKIWzVdEdA
        -Dmetadata-keystore.metadata.algorithm=DESede
        "
      JAVA_OPTS: "
        -Ddb.driver=org.postgresql.Driver
        -Ddb.username=alfresco
        -Ddb.password=alfresco
        -Ddb.url=jdbc:postgresql://postgres:5432/alfresco
        -Dsolr.host=solr6
        -Dsolr.port=8983
        -Dsolr.http.connection.timeout=1000
        -Dsolr.secureComms=secret
        -Dsolr.sharedSecret=secret
        -Dsolr.base.url=/solr
        -Dindex.subsystem.name=solr6
        -Dshare.host=127.0.0.1
        -Dshare.port=8080
        -Dalfresco.host=localhost
        -Dalfresco.port=8080
        -Daos.baseUrlOverwrite=http://localhost:8080/alfresco/aos
        -Dmessaging.broker.url=\"failover:(nio://activemq:61616)?timeout=3000&jms.useCompression=true\"
        -Ddeployment.method=DOCKER_COMPOSE
        -DlocalTransform.core-aio.url=http://transform-core-aio:8090/
        -Dcsrf.filter.enabled=false
        -XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80
        "

  transform-core-aio:
    image: alfresco/alfresco-transform-core-aio:2.5.7
    mem_limit: 1536m
    container_name: transform
    environment:
      JAVA_OPTS: " -XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80"
    ports:
      - "8090:8090"

  share:
    image: alfresco/alfresco-share:7.3.0-M2
    mem_limit: 1g
    container_name: share
    environment:
      REPO_HOST: "alfresco"
      REPO_PORT: "8080"
      JAVA_OPTS: "
        -XX:MinRAMPercentage=50
        -XX:MaxRAMPercentage=80
        -Dalfresco.host=localhost
        -Dalfresco.port=8080
        -Dalfresco.context=alfresco
        -Dalfresco.protocol=http
        "

  solr6:
    image: alfresco/alfresco-search-services:2.0.3
    mem_limit: 2g
    container_name: solr6
    environment:
      #Solr needs to know how to register itself with Alfresco
      SOLR_ALFRESCO_HOST: "alfresco"
      SOLR_ALFRESCO_PORT: "8080"
      # Alfresco needs to know how to call solr
      SOLR_SOLR_HOST: "solr6"
      SOLR_SOLR_PORT: "8983"
      # Create the default alfresco and archive cores
      SOLR_CREATE_ALFRESCO_DEFAULTS: "alfresco,archive"
      
    volumes: #保存指定卷信息至创建的卷
      - solr-data:/opt/alfresco-search-services/data
      - solr-solrhome:/opt/alfresco-search-services/solrhome
      - solr-keystores:/opt/alfresco-search-services/keystores
    ports:
      - "8083:8983"

  activemq:
    image: alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8
    mem_limit: 1g
    container_name: activemq
    volumes: #保存指定卷信息至创建的卷
      - activemq-activemq:/var/log/activemq
      - activemq-conf:/opt/activemq/conf
      - activemq-data:/opt/activemq/data
    ports:
      - "8161:8161"
  content-app:
    image: alfresco/alfresco-content-app:2.11.0
    mem_limit: 128m
    container_name: content
    environment:
      APP_BASE_SHARE_URL: "http://localhost:8080/aca/#/preview/s"

  proxy:
    image: alfresco/alfresco-acs-nginx:3.4.2
    mem_limit: 128m
    container_name: proxy
    environment:
      DISABLE_PROMETHEUS: "true"
      DISABLE_SYNCSERVICE: "true"
      DISABLE_ADW: "true"
      DISABLE_CONTROL_CENTER: "true"
      ENABLE_CONTENT_APP: "true"
    depends_on:
      - alfresco
      - content-app
    ports:
      - "8092:8080"
    links:
      - content-app
      - alfresco
      - share
volumes: #创建卷
  mongo-data:
  mongo-config:
  keycloak-data:
  mysql-data:
  camunda-data:
  minio-data:
  solr-data:
  solr-solrhome:
  solr-keystores:
  activemq-activemq:
  activemq-conf:
  activemq-data:
  postgres-data:

  Tip: The alfresco container to the final proxy container is a whole.

        Since the yml file can only create one database and super administrator user when initializing the database, by putting the create_database.sh file into the location where the database container is started, another database and super administrator user can be created when the database is initialized:

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
	CREATE USER keycloak WITH ENCRYPTED PASSWORD 'Qivie20130113!';
    CREATE DATABASE keycloak;
	GRANT ALL PRIVILEGES ON DATABASE keycloak TO keycloak;
EOSQL

        File execution location:

Note: The two files should be placed in the same folder, otherwise you need to modify the path to the left of the colon; if you don’t modify it, the file will not be found, resulting in failure to initialize the keycloak database, and an error will be reported when keycloak writes data to the database.

        Tips: 1. The above docker compose configuration code can be used directly by copying it. Remember to download the image first, otherwise it will take a long time to complete the deployment (after docker compose up -d starts, if the image does not exist, it will be downloaded automatically).

        2. In the configuration of this article, volumes uses the docker default path to save data. If you need to customize the data saving path, please change volumes to the following writing method:

 After that, the bottom volumes will not be used anymore, just delete or comment out:

        3. Remember to modify the parameter value when deploying (the company may have a unified password or requirements, etc.).

        4. When starting in linux, pay attention to firewall restrictions and port number conflicts.

        5. When querying the startup status, you can view it through docker ps (docker compose ps needs to be executed in the folder where the yml file is located to be effective, otherwise an error will be reported; why it can only be used here, we still need to wait for the official optimization, there is no solution).

        6. If keycloak is on the public network linux server, you need to log in to the postgreSQL database after the deployment is complete, enter the keycloak database -- "select the relam table --" modify the ssl_required field of id=master to NONE, example:

 After the modification is complete, restart the keycloak container to access the keycloak console page; access to the console without modifying this parameter will be blocked by https.

The above is the whole content of this article. This article is suitable for reading and use by friends who have a certain foundation of docker or docker compose; because I did not explain the specific parameters, new friends will be very confused, so I will write another article. Explain the meaning of each parameter. This ends, *★,°*:.☆( ̄▽ ̄)/$:*.°★*.

Guess you like

Origin blog.csdn.net/guo0208/article/details/127921337