承接 ibra-akv/docker-jobs-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ibra-akv/docker-jobs-bundle

最新稳定版本:6.0.1

Composer 安装命令:

composer require ibra-akv/docker-jobs-bundle

包简介

Symfony bundle that offers a batch processing system with Docker.

README 文档

README

Symfony bundle that offers a batch processing system with Docker.

Uses Docker containers to run and handle your jobs.

Need to know

All containers started by this bundle, are by default on the host's network.
So, if you need to connect to a local database, you can with the usual localhost|127.0.0.1.

Docker configuration

Docker Engine API must be exposed on a local port in order to be able to connect.

1. Edit the docker.service which by default on debian is located at /lib/systemd/system/docker.service

From this:

# /lib/systemd/system/docker.service
...
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
...

To this:

# /lib/systemd/system/docker.service
...
ExecStart=/usr/bin/dockerd
...
2. Edit /etc/docker/daemon.json to expose docker api at 127.0.0.1:2375

Add hosts to the json file as next:

{
  ...
  "hosts": ["fd://", "tcp://127.0.0.1:2375"]
  ...
}
3. Restart Docker completely
systemctl daemon-reload
systemctl restart docker
service docker restart

Docker Image

If not already done, you must create a Docker image which will be used to execute your jobs.

This bundle allows use of different images for each job but requires a default image to fallback on when no docker image is specified at launch.

Installation

When installing, you must specify the correct version of the bundle which coressponds to the Symfony version of your project.

# Symfony 6
composer require ibra-akv/docker-jobs-bundle:~6.0

# Symfony 5
composer require ibra-akv/docker-jobs-bundle:~5.0

# Symfony 4
composer require ibra-akv/docker-jobs-bundle:~4.0

# Symfony 3
composer require ibra-akv/docker-jobs-bundle:~3.0

Configuration

The configuration process is a bit lengthy, follow all the steps shown below.


Job Entity

You must create your Job entity and extend of BaseJob class.

<?php

namespace App\Entity;

use IterativeCode\DockerJobsBundle\Entity\BaseJob;

class Job extends BaseJob
{
}

As long as you extend it of BaseJob, the bundle will work correctly.

Bundle Configuration

Once you've got your Job entity and Docker image ready, the last step is to configure the bundle.

If not already done, include the bundle to your project:

<?php
# Symfony 4
# ./project_dir/config/bundles.php

return [
 Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
 ...
 IterativeCode\DockerJobsBundle\DockerJobsBundle::class => ['all' => true],
];

# Symfony 3
# ./project_dir/app/AppKernel.php

$bundles = array(
 new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
 new Symfony\Bundle\SecurityBundle\SecurityBundle(),
 ...
 new IterativeCode\DockerJobsBundle\DockerJobsBundle(),
)

Yaml configuration

# Symfony 4
# ./project_dir/config/packages/docker_jobs.yaml

# Symfony 2 - 3
# ./project_dir/app/config/config.yml

docker_jobs:
 class:
   job: App\Entity\Job # Required

 docker:
   # The URI where Docker Engine API is exposed
   # The bundle will use this endpoint to communicate with Docker
   docker_api_endpoint: 'http://127.0.0.1:2375' # optional (default: http://localhost:2375)

   # Default docker image ID for job execution
   # You can specify docker image when creating a job, this image will be used if no image is specified at creation.
   default_image_id: '6c39ebee77c9'         # Required

   # This parameter is required to avoid eventual errors
   # When starting a container for your job, the user will cd into this directory.
   container_working_dir: '/opt/symfony-project'        # Required

   # This parameter is used to convert docker container dates to my timezone.
   # Docker by default uses UTC+00:00 time, me who's residing in France, i need to add 1 hour to it for it to be correct (UTC+01:00).
   # You can use this parameter to add or remove hours to adapt it to your timezone.
   time_difference: '+1 hour' # Optional (default: +1 hour)
   # time_difference: '+3 hours'
   # time_difference: '-2 hours'

 runtime: # Optional
   # This is a default concurrency limit value
   # This value can be overridden in the job orchestrating command.
   concurrency_limit: 4 # Optional (default: 4)

At this point, you should have the bundle imported and working.
Next you need to configure the job orchestrating command to run non-stop.
Check out the steps below.

Next steps

  • Check out the Console commands to get the system up and running.
    This step is vital to get the orchestration of job containers up and running.

  • Check out the Monitoring dashboard that you can activate if you wish.

License

统计信息

  • 总下载量: 36
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 21
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 21
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固