Project Icon

docker

Monica个人关系管理系统的Docker部署方案

Monica提供Docker镜像,支持Apache和FPM版本,可通过Docker和docker-compose快速部署。镜像包含MySQL数据库,支持数据持久化和连接现有数据库。多架构支持适配不同硬件平台。简单配置即可启动Monica个人关系管理系统,实现便捷部署和使用。

Monica's docker image

Docker Pulls Monica's docker

amd64 build status badge arm32v5 build status badge arm32v6 build status badge arm32v7 build status badge arm64v8 build status badge i386 build status badge mips64le build status badge ppc64le build status badge s390x build status badge

MonicaHQ

Monica can run with Docker images.

Prerequisites

You can use Docker and docker-compose to pull or build and run a Monica image, complete with a self-contained MySQL database. This has the nice properties that you don't have to install lots of software directly onto your system, and you can be up and running quickly with a known working environment.

For any help about how to install Docker, see their documentation

Use Monica docker image

There are two versions of the image you may choose from.

The apache tag contains a full Monica installation with an apache webserver. This points to the default latest tag too.

The fpm tag contains a fastCGI-Process that serves the web pages. This image should be combined with a webserver used as a proxy, like apache or nginx.

Using the apache image

This image contains a webserver that exposes port 80. Run the container with:

docker run -d -p 8080:80 monica

Using the fpm image

This image serves a fastCGI server that exposes port 9000. You may need an additional web server that can proxy requests to the fpm port 9000 of the container. Run this container with:

docker run -d -p 9000:9000 monica:fpm

Persistent data storage

To have a persistent storage for your datas, you may want to create volumes for your db, and for monica you will have to save the /var/www/html/storage directory.

Run a container with this named volume:

docker run -d 
-v monica_data:/var/www/html/storage
monica

Connect to a mysql database

Monica needs a database connection, and currently supports mysql/mariadb only. Run these to have a running environment:

mysqlCid="$(docker run -d \
 -e MYSQL_RANDOM_ROOT_PASSWORD=true \
 -e MYSQL_DATABASE=monica \
 -e MYSQL_USER=homestead \
 -e MYSQL_PASSWORD=secret \
 "mariadb:11")"
docker run -d \
 --link "$mysqlCid":mysql \
 -e DB_HOST=mysql \
 -p 8080:80 \
 monica

If you want to use a mysql installation that already exists, you can pass the database environment variables directly into the docker run command, with DB_HOST indicating the IP address of the MySQL database. Ensure all permissions are granted to the user specified in the enviornment variable DB_USERNAME.

docker run -d \
 -e DB_PORT=3306 \
 -e DB_DATABASE=monica \
 -e DB_USERNAME=homestead \
 -e DB_PASSWORD=secret \
 -e DB_HOST=0.0.0.0 \
 -p 8080:80 \
 monica

Wait until all migrations are done and then access Monica at http://localhost:8080/ from your host system. If this looks ok, add your first user account.

Run commands inside the container

Like every Laravel application, the php artisan command is very usefull for Monica. To run a command inside the container, run

docker exec CONTAINER_ID php artisan COMMAND

or for docker-compose

docker-compose exec monica php artisan COMMAND

where monica is the name of the service in your docker-compose.yml file.

Running the image with docker-compose

See some examples of docker-compose possibilities in the example section.


Apache version

This version will use the apache image and add a mysql container. The volumes are set to keep your data persistent. This setup provides no ssl encryption and is intended to run behind a proxy.

Make sure to pass in values for APP_KEY variable before you run this setup.

Set APP_KEY to a random 32-character string. You can for instance copy and paste the output of echo -n 'base64:'; openssl rand -base64 32.

  1. Create a docker-compose.yml file
version: "3.4"

services:
  app:
    image: monica
    depends_on:
      - db
    ports:
      - 8080:80
    environment:
      - APP_KEY=
      - DB_HOST=db
      - DB_USERNAME=usermonica
      - DB_PASSWORD=secret
    volumes:
      - data:/var/www/html/storage
    restart: always

  db:
    image: mariadb:11
    environment:
      - MYSQL_RANDOM_ROOT_PASSWORD=true
      - MYSQL_DATABASE=monica
      - MYSQL_USER=usermonica
      - MYSQL_PASSWORD=secret
    volumes:
      - mysql:/var/lib/mysql
    restart: always

volumes:
  data:
    name: data
  mysql:
    name: mysql
  1. Set a value for APP_KEY variable before you run this setup. You can for instance copy and paste the output of

    echo -n 'base64:'; openssl rand -base64 32
    
  2. Run

    docker-compose up -d
    

    Wait until all migrations are done and then access Monica at http://localhost:8080/ from your host system. If this looks ok, add your first user account.

  3. Run this command once:

    docker-compose exec app php artisan setup:production
    

FPM version

When using FPM image, you will need another container with a webserver to proxy http requests. In this example we use nginx with a basic container to do this.

  1. Download nginx.conf and Dockerfile file for nginx image. An example can be found on the example section
    mkdir web
    curl -sSL https://raw.githubusercontent.com/monicahq/docker/master/.examples/nginx-proxy/web/nginx.conf -o web/nginx.conf
    curl -sSL https://raw.githubusercontent.com/monicahq/docker/master/.examples/nginx-proxy/web/Dockerfile -o web/Dockerfile
    

The web container image should be pre-build before each deploy with: docker-compose build

  1. Create a docker-compose.yml file
version: "3.4"

services:
  app:
    image: monica:fpm
    depends_on:
      - db
    environment:
      - APP_KEY=
      - DB_HOST=db
      - DB_USERNAME=usermonica
      - DB_PASSWORD=secret
    volumes:
      - data:/var/www/html/storage
    restart: always
  
  web:
    build: ./web
    ports:
      - 8080:80
    depends_on:
      - app
    volumes:
      - data:/var/www/html/storage:ro
    restart: always

  db:
    image: mariadb:11
    environment:
      - MYSQL_RANDOM_ROOT_PASSWORD=true
      - MYSQL_DATABASE=monica
      - MYSQL_USER=usermonica
      - MYSQL_PASSWORD=secret
    volumes:
      - mysql:/var/lib/mysql
    restart: always

volumes:
  data:
    name: data
  mysql:
    name: mysql
  1. Set a value for APP_KEY variable before you run this setup. You can for instance copy and paste the output of

    echo -n 'base64:'; openssl rand -base64 32
    
  2. Run

    docker-compose up -d
    

    Wait until all migrations are done and then access Monica at http://localhost:8080/ from your host system. If this looks ok, add your first user account.

  3. Run this command once:

    docker-compose exec app php artisan setup:production
    

Make Monica available from the internet

To expose your Monica instance for the internet, it's important to set APP_ENV=production in your .env file or environment variables. In this case https scheme will be mandatory.

Using a proxy webserver on the host

One way to expose your Monica instance is to use a proxy webserver from your host with SSL capabilities. This is possible with a reverse proxy.

Using a proxy webserver container

See some examples of docker-compose possibilities in the example section to show how to a proxy webserver with ssl capabilities.

项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

吐司

探索Tensor.Art平台的独特AI模型,免费访问各种图像生成与AI训练工具,从Stable Diffusion等基础模型开始,轻松实现创新图像生成。体验前沿的AI技术,推动个人和企业的创新发展。

Project Cover

SubCat字幕猫

SubCat字幕猫APP是一款创新的视频播放器,它将改变您观看视频的方式!SubCat结合了先进的人工智能技术,为您提供即时视频字幕翻译,无论是本地视频还是网络流媒体,让您轻松享受各种语言的内容。

Project Cover

美间AI

美间AI创意设计平台,利用前沿AI技术,为设计师和营销人员提供一站式设计解决方案。从智能海报到3D效果图,再到文案生成,美间让创意设计更简单、更高效。

Project Cover

AIWritePaper论文写作

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号