如何在 docker 模式下更改 bitbucket-server 的上下文路径

How to change the context path of bitbucket-server in docker mode

我正在寻找一种在 docker 模式下更改 bitbucket-server 上下文路径的方法,因为我正试图 运行 它在 traefik 反向代理后面并想使用我的域对于多个应用程序(每个路径一个):

我希望我的 bitbucket-server 在 https://my.domain.name/bitbucket 上运行,而我的 jira 在 https://my.domain.name/jira 上运行...等等

我已经找到了使用反向代理设置 ATL_TOMCAT_CONTEXTPATH 的其他 Atlassian 产品(jira、servicedesk 和 confluence)的解决方案,bitbucket-server docker hub page 中没有描述环境参数。

我的 docker 集群堆栈如下所示:

version: '3'

services:

  bitbucket-server:
    image: atlassian/bitbucket-server:6.7
    deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.bitbucket-server.entryPoints=websecure"
        - "traefik.http.routers.bitbucket-server.rule=Host(`my.domain.name`) && PathPrefix(`/bitbucket`)"
        - "traefik.http.services.bitbucket-server.loadbalancer.server.port=7990"
        - "traefik.http.routers.bitbucket-server.tls=true"
        - "traefik.http.routers.bitbucket-server.tls.certresolver=letsencrypt"
        - "traefik.http.routers.bitbucket-server.tls.domains=my.domain.name"
    environment:
      - ATL_PROXY_NAME=traefik.my.domain.name
      - ATL_PROXY_PORT=443
      # next line didn't work ! 
      # - ATL_TOMCAT_CONTEXTPATH=/bitbucket
    volumes:
      - bitbucket_data:/var/atlassian/application-data/bitbucket
    networks:
      - local
      - public-proxy
    labels:
      - description= "Bitbucket"
      
  jira-software:
    image: atlassian/jira-software:8.5
    deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.jira-software.entryPoints=websecure"
        - "traefik.http.routers.jira-software.rule=Host(`my.domain.name`) && PathPrefix(`/jira`)"
        - "traefik.http.services.jira-software.loadbalancer.server.port=8080"
        - "traefik.http.routers.jira-software.tls=true"
        - "traefik.http.routers.jira-software.tls.certresolver=letsencrypt"
        - "traefik.http.routers.jira-software.tls.domains=my.domain.name"
    volumes:
      - jira_software_data:/var/atlassian/application-data/jira
    environment:
      - ATL_PROXY_NAME=traefik.my.domain.name
      - ATL_PROXY_PORT=443
      # next line did work !
      - ATL_TOMCAT_CONTEXTPATH=/jira
      - ATL_TOMCAT_SCHEME=https
      - ATL_TOMCAT_SECURE=true
    networks:
      - local
      - public-proxy
    labels:
      - description= "Jira Software"
  
  jira-servicedesk:
    image: atlassian/jira-servicedesk:4.5
    
    # ... Same as jira-software

  confluence:
    image: atlassian/confluence-server:7.1  
    
    # ... Same as jira-software
    
networks:
  local:
  public-proxy :
    external: true

volumes:
  servicedesk_data:
  confluence_data:
  jira_software_data:
  bitbucket_data:

可以通过添加此行

bitbucket.properties配置上下文路径
server.context-path=/bitbucket

在 docker 环境中,您可以将 bitbucket 属性文件挂载到您的容器中,以便它替换默认文件

volumes:
  - YOUR_BITBUCKET_PROPERTIES:<Bitbucket home directory>/shared/bitbucket.properties