docker部署snipe-it资产管理系统

Snipe-IT 是一个基于 Laravel 构建的免费开源 (FOSS) 项目,主要能够跟踪谁拥有哪台笔记本电脑、购买时间、可用的软件许可证和附件等

1.docker服务和docker-compose

  1. 使用pip方式安装docker-compose_pip安装docker-compose-CSDN博客icon-default.png?t=N7T8https://blog.csdn.net/baidu_35848778/article/details/125082770?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~Ctr-1-125082770-blog-128466622.235%5Ev43%5Epc_blog_bottom_relevance_base4&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~Ctr-1-125082770-blog-128466622.235%5Ev43%5Epc_blog_bottom_relevance_base4&utm_relevant_index=2

2.docker拉取snipe-it和mysql8.0的镜像

docker pull mysql:8.0
docker pull snipe/snipe-it:v6.3.3

生成应用密钥 app_key,保留好生成的key,需要放在后面.env.docker配置文件里
docker run --rm snipe/snipe-it:v6.3.3

如果snipe-it镜像包拉取失败,可在文章顶部下载6.3.3的镜像,或者查阅一些科学上网的文章去拉取想要的版本,我是拉了好多次才拉取到的,配了国内镜像加速也不稳定

导入docker镜像
docker load -i snipe-it6.3.3.tar

3.解压snipe-it-6.3.3.zip的源码包后进入目录编辑 .env.docker和docker-compose.yaml

 到github找对应源码包下载上传到服务器

https://github.com/snipe/snipe-it/releases/tag/v6.3.3
unzip snipe-it-6.3.3.zip

vim docker-compose.yaml

version: '3'
services:
  snipeit:
    container_name: snipeit
    image: snipe/snipe-it:v6.3.3
    restart: always
    ports:
    - "8080:80"
    volumes:
    - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime
    - ./logs:/var/www/html/storage/logs
    - ./snipe-vol:/var/lib/snipeit
    depends_on:
    - mysql
    env_file:
    - .env.docker
    networks:
    - snipeit-backend
  mysql:
    image: mysql:8.0
    container_name: mysql
    ports:
      - 3306:3306
    restart: always
    volumes:
      - ./db:/var/lib/mysql
      - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime
    environment:
      MYSQL_ROOT_PASSWORD: 123456

      MYSQL_DATABASE: snipeit_data

      MYSQL_USER: snipeit

      MYSQL_PASSWORD: 123456
    command:
      - --default-authentication-plugin=mysql_native_password
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_unicode_ci
    networks:
    - snipeit-backend
networks:
  snipeit-backend:

vim.env.docker

替换成上方生成的appkey
APP_KEY=base64:m10Y+0J5Rik4NXAjyLw4QfhYzvYJLxKwl9DcqQlpuEw=

修改成自己服务器ip
APP_URL=http://ip:8080
APP_TIMEZONE='Asia/Shanghai'
APP_LOCALE=zh-CN
MAX_RESULTS=1000

API_THROTTLE_PER_MINUTE=2000
PRIVATE_FILESYSTEM_DISK=local
PUBLIC_FILESYSTEM_DISK=local_public

配置mysql的库和用户密码,与docker-compose.yml内一致
DB_CONNECTION=mysql
DB_HOST=mysql
DB_DATABASE=snipeit_data
DB_USERNAME=snipeit
DB_PASSWORD=123456
DB_PREFIX=null
DB_DUMP_PATH='/usr/bin'
DB_CHARSET=utf8mb4
DB_COLLATION=utf8mb4_unicode_ci

4.编辑完成后执行容器创建和启动

创建并启动容器
docker compose up -d
重启 compose
docker compose restart
进入容器赋予权限
docker compose exec snipeit bash
chmod -R 777 storage
chmod -R 777 public/uploads
chmod -R 777 bootstrap/cache

5.打开网页搜索ip:端口

docker部署snipe-it资产管理系统_第1张图片

你可能感兴趣的:(docker,容器,运维)