docker安装jira

目录

一、安装docker

二、下载MySQL 驱动

三、下载JIRA  依赖软件

四、编写jira Dockerfile文件

五、创建jira 容器启动文件

六、数据库配置和创建jiradb

七、配置jira和配置许可

八、k8s部署jira文件(附加内容)


一、安装docker

        安装docker和docker-compose请参考:https://blog.csdn.net/weixin_44770684/article/details/129227050

二、下载MySQL 驱动

        既然默认使用PostgreSQL数据库,若使用MySQL数据库,则需要添加MySQL驱动,

从MySQL官网下载MySQL驱动,具体的驱动版本号需要根据实际使用的数据库版本号,理论上高版本的MySQL 驱动支持低版本的MySQL数据库。

        说明:我使用的是mysql 8.0的驱动和MySQL 5.7数据库。

        MySQL驱动下载:https://downloads.mysql.com/archives/c-j/     

         点击 Archives 菜单可以选择目标版本号的MySQL驱动,我下载的驱动是:mysql-connector-java-8.0.23.jar 。

       解压下载的MySQL驱动压缩包,将 MySQL压缩包里面的 mysql-connector-java-8.0.23.jar 文件复制到Dockerfile 文件目录

三、下载JIRA  依赖软件

       参考文档说明:https://github.com/qinyuxin99/atlassian-agent 

        我下载的版本是:atlassian-agent-v1.2.3.tar.gz,解压下载的jira软件包,将 atlassian-agent.jar 文件复制到Dockerfile 文件目录

四、编写jira Dockerfile文件

        1、我将jira需要的文件都放在 jira 目录下:

        2、 构建jira镜像的Dockerfile文件内容见:

## cat Dockerfile

# jira 的基础镜像版本, 需要更换成自己需求的版本号,适用于升级jira
FROM atlassian/jira-software:8.16.1 AS jira

LABEL creator="@土豆"

USER root

# 软件包下载地址: https://github.com/qinyuxin99/atlassian-agent

COPY atlassian-agent.jar /opt/atlassian/jira/

# jira配置和连接mysql参考文档:https://confluence.atlassian.com/adminjiraserver0816/connecting-jira-applications-to-a-database-1063163980.html
# 添加 mysql 驱动 下载地址: https://downloads.mysql.com/archives/c-j/
#COPY mysql-connector-java-5.1.49.jar /opt/atlassian/jira/lib/
COPY mysql-connector-java-8.0.23.jar  /opt/atlassian/jira/lib/

# 使atlassian-agent.jar和 Tomcat 一起启动
RUN echo 'export JAVA_OPTS="-javaagent:/opt/atlassian/jira/atlassian-agent.jar ${JAVA_OPTS}"' >> /opt/atlassian/jira/bin/setenv.sh

# RUN echo 'java -jar /opt/atlassian/jira/atlassian-agent.jar -p jira -m admin@qq.com -n jira -o https://zhile.io -s BUB5-TBAT-K30D-VCPN' >/opt/1.txt

# ubuntu 系统设置时区 和 24小时
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone && echo "LC_TIME=en_DK.UTF-8" >/etc/default/locale

#  安装docker和docker-compose 教程见: https://blog.csdn.net/weixin_44770684/article/details/129227050
#  curl -SL https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose 
#  chmod a+x /usr/local/bin/docker-compose
# 
# 构建 jira镜像和 推送镜像到harbor等镜像仓库
#  docker build -t test/atlassian/jira-software:8.16.1 . --no-cache
#  docker push test/atlassian/jira-software:8.16.1 

        3、构建jira镜像

# 构建 jira 镜像
cd jira  # 切换到 Dockerfile 文件目录下,执行构建镜像命令
docker build -t test/atlassian/jira-software:8.16.1 . --no-cache

五、创建jira 容器启动文件

        使用 docker-compose 创建jira启动文件,并且包含了mysql 启动文件(若是使用其他安装的mysql,则可以注释掉mysql 启动文件部分)

## cat docker-compose.yaml

version: '3.3'
services:
    jira:
        container_name: jira
#        depends_on:
#        - mysql
#        links:
#        - mysql
        image: test/atlassian/jira-software:8.16.1
        restart: always
        privileged: true
        ports:
            - '8080:8080'
        environment:
            - TZ=Asia/Shanghai
#            TZ: Asia/Shanghai # 两种环境变量写法
        volumes:
            - './jira/jiradata:/var/atlassian/application-data/jira'

#   容器安装mysql 启动
#   jira连接mysql 配置参考文档: https://confluence.atlassian.com/adminjiraserver0816/connecting-jira-applications-to-a-database-1063163980.html
    mysql:
        container_name: mysql
        image: mysql:5.7
        restart: always
        ports:
            - '3306:3306'
        environment:
            - MYSQL_ROOT_PASSWORD=root
            - TZ=Asia/Shanghai
        volumes:
            - './mysql/data:/var/lib/mysql'
            - './mysql/conf:/etc/mysql/conf.d'
            - './mysql/backup:/backup'



六、数据库配置和创建jiradb

        1、jira连接mysql 5.7,需要满足的条件

参考文档:https://confluence.atlassian.com/adminjiraserver0816/connecting-jira-applications-to-mysql-5-7-1063163986.html

         2、jira连接mysql 8.0,需要满足的条件 

参考文档:https://confluence.atlassian.com/adminjiraserver0816/connecting-jira-applications-to-mysql-8-0-1063163987.html

        3、mysql启动参数

## my.cnf
## 将 my.cnf 文件复制到 mysql的配置映射目录 mysql/conf

[mysqld]
default-storage-engine=INNODB
character_set_server=utf8mb4
innodb_default_row_format=DYNAMIC
innodb_large_prefix=ON
innodb_file_format=Barracuda
innodb_log_file_size=2G

        4、登录mysql创建jiradb数据库和jira用户(mysql 5.7)

--- mysql 5.7 创建 jiradb数据库脚本
CREATE DATABASE jiradb CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;

--- MySQL 5.7.0 - 5.7.5:

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX on jiradb.* TO 'jira'@'%' IDENTIFIED BY 'jira';
flush privileges;

--- MySQL 5.7.6 and later 
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,REFERENCES,ALTER,INDEX on jiradb.* TO 'jira'@'%' IDENTIFIED BY 'jira';
flush privileges;

七、配置jira和配置许可

        1、配置jira,访问地址是:http://ip:8080

        2、从截图看出jira Server ID为: BRM9-6AGL-H5ZZ-2APS,则登录jira容器执行获取许可命令:

# 登录 jira容器 执行破解命令, BRM9-6AGL-H5ZZ-2APS 为 对应的  Server ID
java -jar /opt/atlassian/jira/atlassian-agent.jar -p jira -m admin@qq.com -n jira -o https://zhile.io -s 'BRM9-6AGL-H5ZZ-2APS'

         3、将输出许可秘钥结果回填到 Your License Key 填写框中:

         4、填写许可秘钥,点下一步后,出现的空白框为设置管理员相关信息、,按照自己的情况填写即可,我这里以admin为例:

        5、邮箱认证测试可以选择laster,即先不测试邮箱是否能接收到通知可用,然后接着下一步继续即可

         6、查询成功许可结果,可见许可到期时间为:2089-07-06

八、k8s部署jira文件(附加内容)

        最后附上一个在k8s环境部署jira的部署文件,如果有兴趣在k8s部署jira可参考是文件:


### cat k8s-jira.yaml

---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    meta.helm.sh/release-name: my-jira
    meta.helm.sh/release-namespace: default
  labels:
    app.kubernetes.io/instance: my-jira
    app.kubernetes.io/name: jira-software
  name: my-jira-jira-software
  namespace: default
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app.kubernetes.io/instance: my-jira
      app.kubernetes.io/name: jira-software
  strategy:
    type: Recreate
  template:
    metadata:
      annotations:
      labels:
        app.kubernetes.io/instance: my-jira
        app.kubernetes.io/name: jira-software
    spec:
      containers:
      - image: test/atlassian/jira-software:8.16.1
        imagePullPolicy: IfNotPresent
        name: jira-software
        ports:
        - containerPort: 8080
          name: http
          protocol: TCP
        resources:
          requests:
            cpu: 500m
            memory: 1Gi
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /etc/localtime
          name: host-time
          readOnly: true
        - mountPath: /var/atlassian/application-data/jira
          name: jira-data-pvc
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext:
        fsGroup: 2001
      serviceAccount: default
      serviceAccountName: default
      terminationGracePeriodSeconds: 30
      volumes:
      - hostPath:
          path: /etc/localtime
          type: ""
        name: host-time
      - name: jira-data-pvc
        persistentVolumeClaim:
          claimName: jira-data
---
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    meta.helm.sh/release-name: my-jira
    meta.helm.sh/release-namespace: default
  labels:
    app.kubernetes.io/instance: my-jira
    app.kubernetes.io/name: jira-software
  name: my-jira-jira-software
  namespace: default
spec:
  clusterIP: 10.233.39.2
  clusterIPs:
  - 10.233.39.2
  internalTrafficPolicy: Cluster
  ipFamilies:
  - IPv4
  ipFamilyPolicy: SingleStack
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 8080
  selector:
    app.kubernetes.io/instance: my-jira
    app.kubernetes.io/name: jira-software
  sessionAffinity: None
  type: ClusterIP

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    nginx.ingress.kubernetes.io/proxy-body-size: 1024m
  name: my-jira-jira-software
spec:
  ingressClassName: nginx
  rules:
  - host: myjira.com
    http:
      paths:
      - backend:
          service:
            name: my-jira-jira-software
            port:
              number: 80
        path: /
        pathType: Prefix
---

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值