小编Sou*_*euh的帖子

在docker gitlab-ci-runner上运行docker-compose

我在Docker上运行了一个带有docker-compose for dev环境的项目.

我想通过gitlab-ci-multi-runner"Docker mode"实例在GitLabCI上运行它.

这是我的.gitlab-ci.yml文件:

image: soullivaneuh/docker-bash

before_script:
  - apk add --update bash curl
  - curl --silent --location https://github.com/docker/compose/releases/download/1.5.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
  - chmod +x /usr/local/bin/docker-compose
  - ./configure
  - docker-compose up -d
Run Code Online (Sandbox Code Playgroud)

请注意,soullivaneuh/docker-bash图像只是安装了bash的docker镜像.

脚本docker-compose up -d命令失败:

gitlab-ci-multi-runner 0.7.2 (998cf5d)
Using Docker executor with image soullivaneuh/docker-bash ...
Pulling docker image soullivaneuh/docker-bash:latest ...

Running on runner-1ee5079f-project-3-concurrent-1 via sd-59984...
Fetching changes...
Removing app/config/parameters.yml
Removing docker-compose.env
HEAD is now at 5c5e7ff remove docker service
From https://git.dummy.net/project/project …
Run Code Online (Sandbox Code Playgroud)

docker gitlab-ci gitlab-ci-runner docker-compose

11
推荐指数
1
解决办法
4392
查看次数

Jest 和 RANDOMBYTESREQUEST 打开句柄

我有一个运行Jest的FeathersJS api 项目进行测试。

\n

我的测试套件工作正常。但是,它总是以以下警告消息结束:

\n
Jest has detected the following 2 open handles potentially keeping Jest from exiting:\n\n  \xe2\x97\x8f  RANDOMBYTESREQUEST\n\n      at random (node_modules/bcryptjs/dist/bcrypt.js:70:56)\n      at node_modules/bcryptjs/dist/bcrypt.js:84:9\n      at node_modules/bcryptjs/dist/bcrypt.js:39:29\n      at Object.<anonymous> (node_modules/bcryptjs/dist/bcrypt.js:43:2)\n\n\n  \xe2\x97\x8f  RANDOMBYTESREQUEST\n\n      at Object.<anonymous>.module.exports (node_modules/nexmo/node_modules/uuid/rng.js:3:10)\n      at Object.<anonymous> (node_modules/nexmo/node_modules/uuid/uuid.js:57:18)\n      at Object.<anonymous> (node_modules/nexmo/src/JwtGenerator.js:1:1)\n
Run Code Online (Sandbox Code Playgroud)\n

此错误意味着什么以及如何修复它?

\n

注意:我很乐意添加更多详细信息,例如代码示例,但我真的不知道从哪里开始。请随时提出更多评论,我将相应地更新帖子。

\n

谢谢

\n

jestjs feathersjs

10
推荐指数
1
解决办法
4990
查看次数

如何使用 ChartJS v3 创建一个简单的仪表?

我在以前的项目中使用ChartJS v2 创建如下所示的仪表:

在此输入图像描述

在 React 集成期间,我需要做同样的事情,但需要从 Donut 修改本身开始,新安装的该库的 v3 版本。

这是当前的配置:

export const GaugeChart: VFC<GaugeChartProps> = ({
  value,
  max = 100,
})  => {
  const percent = value / max;

  return <ChartJS
    type="doughnut"
    data={{
      datasets: [
        {
          backgroundColor: [
            'rgb(255, 99, 132)',
            '#ccc',
          ],
          data: [
            percent * 100,
            100 - (percent * 100),
          ],
        },
      ],
    }}
    options={{
      rotation: -1.0 * Math.PI, // start angle in radians
      circumference: Math.PI, // sweep angle in radians
    }}
  />
};
Run Code Online (Sandbox Code Playgroud)

注意: …

chart.js

10
推荐指数
1
解决办法
2万
查看次数

Symfony DI:与Doctrine事件订阅者的循环服务引用

为了重构有关票证通知系统的代码,我创建了一个Doctrine侦听器:

final class TicketNotificationListener implements EventSubscriber
{
    /**
     * @var TicketMailer
     */
    private $mailer;

    /**
     * @var TicketSlackSender
     */
    private $slackSender;

    /**
     * @var NotificationManager
     */
    private $notificationManager;

    /**
     * We must wait the flush to send closing notification in order to
     * be sure to have the latest message of the ticket.
     *
     * @var Ticket[]|ArrayCollection
     */
    private $closedTickets;

    /**
     * @param TicketMailer        $mailer
     * @param TicketSlackSender   $slackSender
     * @param NotificationManager $notificationManager
     */
    public function __construct(TicketMailer $mailer, TicketSlackSender $slackSender, …
Run Code Online (Sandbox Code Playgroud)

php dependency-injection symfony doctrine-orm

8
推荐指数
2
解决办法
1957
查看次数

在sqlite上重复索引,而不是在mysql上

我有一个实体定义,适用于开发和生产环境(mysql),但不适用于测试(sqlite):

/**
 * Invoice
 *
 * @ORM\Table(name="invoice", indexes={
 *     @ORM\Index(name="ref_idx", columns={"ref"}),
 *     @ORM\Index(name="created_at_idx", columns={"created_at"}),
 *     @ORM\Index(name="paid_idx", columns={"paid"}),
 *     @ORM\Index(name="is_valid_idx", columns={"is_valid"}),
 *     @ORM\Index(name="canceled_idx", columns={"canceled"})
 * })
 * @ORM\Entity(repositoryClass="AppBundle\Repository\InvoiceRepository")
 */
class Invoice
// [...]
Run Code Online (Sandbox Code Playgroud)

当我运行doctrine:schema:create或doctrine:schema:update --force on test env时,我有以下错误:

  [Doctrine\DBAL\DBALException]                                                                 
  An exception occurred while executing 'CREATE INDEX created_at_idx ON invoice (created_at)':  
  SQLSTATE[HY000]: General error: 1 index created_at_idx already exists                         


  [PDOException]                                                         
  SQLSTATE[HY000]: General error: 1 index created_at_idx already exists 
Run Code Online (Sandbox Code Playgroud)

有人已经有过这种问题吗?如何解决/忽略它?

谢谢.

sqlite symfony doctrine-orm

6
推荐指数
1
解决办法
2567
查看次数

FOS REST 捆绑包上的动态序列化组

我目前正在使用FOSRESTBundleJMSSerialize来制作 RESTFull API(当然)。

我的项目是一个供客户和管理员使用的外联网。

这样,我必须禁止客户查看某些字段,仅对管理员可见。

我首先为实体进行了序列化器配置:

AppBundle\Entity\IncidentComment:
    exclusion_policy: ALL
    properties:
        id:
            expose: true
            groups: [list, details]
        author:
            expose: true
            groups: [list, details]
        addedAt:
            expose: true
            groups: [list, details]
        content:
            expose: true
            groups: [details]
        customerVisible:
            expose: true
            groups: [list_admin, details_admin]
Run Code Online (Sandbox Code Playgroud)

如您所见,customerVisible组有_admin后缀。该字段应仅对管理员显示。

_admin如果用户具有例如 ROLE_ADMIN 角色或其他条件,我想动态添加带有后缀的组来在视图上设置组,而不将其写入每个其余控制器的每个操作上。

我正在考虑创建一个带有安全上下文参数的自定义视图处理程序来添加组,但我不知道这是否是正确的方法。

你认为这是好方法吗?您对此有什么建议吗?

顺便说一句,如果某些开发人员遇到同样的问题,我会很高兴看到他如何解决它!:)

谢谢。

rest symfony fosrestbundle

6
推荐指数
1
解决办法
5081
查看次数

在与 Sapper 和 Svelte 的会话中写作

我按照RealWorld 示例编写了一个带有会话管理的 Sapper 应用程序:

polka()
  .use(bodyParser.json())
  .use(session({
    name: 'kidways-app',
    secret: 'conduit',
    resave: false,
    saveUninitialized: true,
    cookie: {
      maxAge: 31536000
    },
    store: new FileStore({
      path: 'data/sessions',
    })
  }))
  .use(
    compression({ threshold: 0 }),
    sirv('static', { dev }),
    pdfMiddleware,
    sapper.middleware({
      session: req => ({
        token: req.session && req.session.token
      })
    })
  )
  .listen(PORT, err => {
    if (err) console.log('error', err);
  });
Run Code Online (Sandbox Code Playgroud)

然后在我的_layout.sevlte

<script context="module">
  export async function preload({ query }, session) {
    console.log('preload', session)
    return {
      // ...
    }; …
Run Code Online (Sandbox Code Playgroud)

session svelte sapper

6
推荐指数
1
解决办法
2200
查看次数

如何告诉 Jest 空间实际上是空间?

鉴于代码:

import { getLocale } from './locale';

export const euro = (priceData: number): string => {
  const priceFormatter = new Intl.NumberFormat(getLocale(), {
    style: 'currency',
    currency: 'EUR',
  });

  return priceFormatter.format(priceData);
}

export default null;
Run Code Online (Sandbox Code Playgroud)

以及相关测试:

import { euro } from './currency';

test('euro', () => {
  expect(euro(42)).toBe("42,00 €");
});
Run Code Online (Sandbox Code Playgroud)

Jest 说:

Jest 抱怨字符串不相等的屏幕截图,即使两者看似相同。 错误在于 Intl 组件产生的数字和货币之间的空间。

即使我将 Jest 的预期结果复制粘贴到我的断言中,错误仍然相同。

所以问题是:为什么是地狱?:-D

currency number-formatting node.js typescript jestjs

6
推荐指数
1
解决办法
245
查看次数

Docker和文件锁定

我编写了一个简单的go应用程序,并添加了一个flock系统,以防止同时运行两次:

import "github.com/nightlyone/lockfile"

lock, err := lockfile.New(filepath.Join(os.TempDir(), "pagerduty-read-api.lock"))
if err != nil {
    panic(err)
}

if err = lock.TryLock(); err != nil {
    fmt.Println("Already running.")
    return
}

defer lock.Unlock()
Run Code Online (Sandbox Code Playgroud)

它在我的主机上运行良好。在docker上,我尝试通过以下方式共享卷tmp

docker run --rm -it -v /tmp:/tmp my-go-binary
Run Code Online (Sandbox Code Playgroud)

但这行不通。我想这是因为羊群系统没有移植到卷共享上。

我的问题:Docker是否可以选择让群集在正在运行的实例之间工作?如果没有,那么我具有相同行为的其他选择是什么?

谢谢。

flock go docker

5
推荐指数
2
解决办法
881
查看次数

如何使 svg 反应组件从外部模块导入与 create-react-app 一起使用?

语境

为了使一些代码部分可以在许多 React 项目中重复使用,我有以下项目结构:

  1. @foo/design:包含设计内容,例如原始 svg 图像
  2. @foo/ui:基于 Create React App 的常用组件的 React 库
  3. @foo/project:最终的 CRA 项目使用foo/ui

图书馆

foo/ui库导出一些从以下位置导入 svg 图像的组件@foo/design

// MyComponent.ts
import React, { FC } from 'react';
import {
  ReactComponent as Logo,
} from '@foo/design/static/img/logo.svg';

export const MyComponent: FC = () => {
  return (
    <div>
      Some stuff.
      <Logo />
    </div>
  );
};

export default null;
Run Code Online (Sandbox Code Playgroud)

该组件在相关的 Storybook 实例上完美运行@foo/ui,并使用tsc如下方式进行编译:

// MyComponent.js
import { jsx as …
Run Code Online (Sandbox Code Playgroud)

javascript svg typescript reactjs create-react-app

5
推荐指数
1
解决办法
768
查看次数