[英]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.