在 github 操作 yml 文件中创建 Minio(S3) 容器 [英] Creating a Minio(S3) container inside a github actions yml file
问题描述
我正在尝试创建一个 Minio/S3 容器,以便我可以在 github 上将我的测试套件作为操作运行.我目前有以下:
name:运行测试在:推:分支:[主]拉取请求:分支:[主]工作:建造:运行:ubuntu-18.04服务:postgres:...迷你:图片:迷你/迷你卷:-/数据端口:- 9000:9000环境:MINIO_ACCESS_KEY:迷你MINIO_SECRET_KEY:minio123选项:--entrypoint迷你服务器/数据";--health-cmd "curl -f http://localhost:9000/minio/health/live"--health-interval 10s --health-timeout 5s --health-retries 5脚步:...
我尝试了以下排列以使 minio 容器工作但没有成功:
卷:- ./数据:/数据卷:- ./:/数据卷:- .:/数据卷:-/数据:/数据
我什至尝试过:
选项:--entrypoint "mkdir/data;minio 服务器/数据"...选项:--entrypoint "minio server/tmp";...选项:--entrypoint [迷你服务器",/tmp"] ...
我已经尝试使用 -v
标志在 --entrypoint
标志之前安装卷.
选项:-v/s3_data:/data --entrypoint "minio server/data";...选项:-v ${{ github.workspace }}/s3_data:/data --entrypoint "minio server/data";...选项:-v ${{ github.workspace }}/s3_data:/data:rw --entrypoint "minio server/data";...
试图让它工作.但不幸的是我得到:
启动容器进程导致: exec: "minio server/data": stat minio server/data: no such file or directory: unknown
而且我不能在没有任何参数的情况下运行 minio 服务器
:(
TL;DR;
I am trying to create an Minio/S3 container so I can run my test suite as an action on github. I currently have the following:
name: Run Tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-18.04
services:
postgres:
...
minio:
image: minio/minio
volumes:
- /data
ports:
- 9000:9000
env:
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
options: --entrypoint "minio server /data" --health-cmd "curl -f http://localhost:9000/minio/health/live" --health-interval 10s --health-timeout 5s --health-retries 5
steps:
...
I have tried the following permutations to get the minio container to work but with no success:
volumes:
- ./data:/data
volumes:
- ./:/data
volumes:
- .:/data
volumes:
- /data:/data
And I even tried:
options: --entrypoint "mkdir /data; minio server /data" ...
options: --entrypoint "minio server /tmp" ...
options: --entrypoint ["minio server", "/tmp"] ...
And I have tried using the -v
flag to mount volumes before the --entrypoint
flag.
options: -v /s3_data:/data --entrypoint "minio server /data" ...
options: -v ${{ github.workspace }}/s3_data:/data --entrypoint "minio server /data" ...
options: -v ${{ github.workspace }}/s3_data:/data:rw --entrypoint "minio server /data" ...
In an attempt to get it to work. But unfortunately I get:
starting container process caused: exec: "minio server /data": stat minio server /data: no such file or directory: unknown
And I can't run the minio server
without any argument :(
TL;DR;
There exists an ongoing GitHub Actions Community thread concerning the lack of support for setting jobs.<job_id>.services.<service_id>.command
and
this existing question is very similar to yours.
You could extend the official image as suggested by @ahasbini then build and push your docker image
to a Docker Registry and use your own image
in the GitHub Actions jobs.<job_id>.services.<service_id>.image
. For example:
The Dockerfile
:
FROM minio/minio
CMD ["server", "/data", "--address=0.0.0.0:9000"]
Note: you can use the
lazybit/minio
image I built for this answer.
The job.<job_id>.services.<service_id>
spec:
jobs:
...
minio:
name: minio
runs-on: ubuntu-latest
services:
minio:
image: lazybit/minio
ports:
- 9000:9000
env:
MINIO_ACCESS_KEY: ${{ secrets.MINIO_ACCESS_KEY }}
MINIO_SECRET_KEY: ${{ secrets.MINIO_SECRET_KEY }}
volumes:
- ${{ github.workspace }}/data:/data
options: --name=minio --health-cmd "curl http://localhost:9000/minio/health/live"
steps:
- run: pip3 install minio
- run: |
python3 - <<'EOF'
from minio import Minio
from minio.error import ResponseError
try:
minio = Minio(
'localhost:9000',
access_key='${{ secrets.MINIO_ACCESS_KEY }}',
secret_key='${{ secrets.MINIO_SECRET_KEY }}',
secure=False
)
except Exception as ex:
raise
minio.make_bucket('foo')
minio.make_bucket('bar')
print(f'{minio.list_buckets()}')
EOF
Notes:
- The
minio/minio
images do not currently have aHEALTHCHECK
instruction set (docker inspect minio/minio:latest --format {{.Config.Healthcheck}}
) so we need to set the--health-cmd
in thejobs.<job_id>.services.<service_id>.options
to hit the serviceslivenessProbe
endpoint to make sure the service is running before we start running thejobs.<job_id>.steps
- I had some issues connecting to the service by name so I set the
minio
endpoint tolocahost:9000
, the GitHub Actions are run in a KubernetesPod
, they share the same network namespace and are accessible vialocalhost
- Accessing encrypted secrets in the
jobs.<job_id>.services.<service_id>.env
andjobs.<job_id>.steps.<step_id>.run
- Mounting a local directory as the volume backing the
minio
service using thegithub
context'sworkspace
这篇关于在 github 操作 yml 文件中创建 Minio(S3) 容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!