简体   繁体   English

如何使用 SSL/TLS 在 CircleCI 中运行 PostgreSQL?

[英]How can I run PostgreSQL in CircleCI with SSL/TLS?

In CircleCI, I would like to run tests that access a PostgreSQL database, but I would like to connect to it using SSL/TLS (with a self-signed certificate).在 CircleCI 中,我想运行访问 PostgreSQL 数据库的测试,但我想使用 SSL/TLS(使用自签名证书)连接到它。

Ideally, it would use a default CircleCI PostgreSQL image, run using the Docker executor, and not need any volumes setup or need to copy anything into the container.理想情况下,它将使用默认的 CircleCI PostgreSQL 映像,使用 Docker 执行程序运行,并且不需要任何卷设置或需要将任何内容复制到容器中。

How can I do this?我怎样才能做到这一点?

You can have the following in your .circleci/config.yml file.您可以在.circleci/config.yml文件中包含以下内容。 It overrides the entrypoint to start bash, and then in bash it generates a self-signed certificate and private key, before running the original entrypoint.它覆盖入口点以启动 bash,然后在 bash 中生成自签名证书和私钥,然后运行原始入口点。

version: 2
jobs:
  build:
    docker:
      - image: python:3.8.7
      - image: circleci/postgres:13.0
        environment:
          POSTGRES_PASSWORD: password
        entrypoint: bash
        command: >
          -c '
            openssl req -nodes -new -x509 -subj "/CN=localhost" -keyout server.key -out server.crt &&
            chown postgres server.key &&
            chmod 600 /server.key &&
            exec /docker-entrypoint.sh -c ssl=on -c ssl_cert_file=/server.crt -c ssl_key_file=/server.key
          '

The first image: is the one where the tests run, in this case it's a Python image, but should be able to replaced by the image of your choice第一个image:是测试运行的图像,在这种情况下它是 Python 图像,但应该能够替换为您选择的图像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何更改它以在postgresql中运行? - How can I alter this to run in postgresql? 如何在没有TLS客户端身份验证的情况下通过SSL连接到Google Cloud SQL? - How can I connect to Google Cloud SQL over SSL without TLS Client Authentication? 如何从 CircleCI 连接到 DigitalOcean 上的 PostgreSQL 集群? - How to connect to PostgreSQL cluster on DigitalOcean from CircleCI? 如何对PostgreSQL数据库运行MDX查询? - How can I run MDX queries against a PostgreSQL database? 如何在Heroku中运行Rails控制台? Rails 5.1和Postgresql - How can I run rails console in Heroku? Rails 5.1 and postgresql 如何在字符串数组上运行PostgreSQL查询? - How can I run a postgresql query over array of strings? 如何在 POSTGRESQL 中运行此 SQL Server 代码? - How can I run this SQL Server code in POSTGRESQL? 如何在 Mac OS X 上运行两份 PostgreSQL? - How can I run two copies of PostgreSQL on Mac OS X? 如何获得 Heroku 的 PostgreSQL SSL 客户端配置文件? - How can I get Heroku's PostgreSQL SSL Client Configuration Files? 如何帮助 Vapor 成功与我的 PostgreSQL 服务器进行 SSL 握手? - How can I help Vapor successfully SSL-handshake my PostgreSQL server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM