循环Ci,无服务器框架,无服务器python需求



我试图通过circleci CI/CD将我的Python项目上传到AWS帐户,但当我部署代码时,它总是停止并删除docker "docker运行——rm -v"在日志

我使用orb

aws-cli: circleci/aws-cli@3.1.3

serverless-framework: circleci/serverless-framework@2.0.0

帮忙吗?

这是。circleci/config.yml

version: 2.1
orbs:
aws-cli: circleci/aws-cli@3.1.3
serverless-framework: circleci/serverless-framework@2.0.0
jobs:
deploy:
executor: serverless-framework/default
docker: # run the steps with Docker
- image: cimg/python:3.8.0
steps:
- checkout
- aws-cli/setup
- serverless-framework/setup
- run:
name: Install plugins
command: |
serverless plugin install -n serverless-python-requirements
- run: python --version
- run:
name: deploy
command: |
sls deploy --stage dev --verbose
sls doctor
workflows:
deploy:
jobs:
- deploy

和serverless。Yml文件

service: myapp-api
frameworkVersion: "3"
package:
patterns:
- '!node_modules/**'
- '!.vscode'
- '!.circleci'
- '!temp.txt'
- '!README.md'
- '!env/**'
- '!package.json'
- '!package-lock.json'
- '!others/*.yml'
- '!resources'
provider:
name: aws
stage: dev
endpointType: REGIONAL
runtime: python3.8
region: us-east-2
plugins:
- serverless-python-requirements
custom:
pythonRequirements:
dockerizePip: true
slim: true
zip: true
functions:
# others & publics
- ${file(./others/TestGet.yml)}
- ${file(./others/DownloadFactsPost.yml)}
- ${file(./others/DownloadTagsPost.yml)}
resources:
# api gateway
- ${file(./resources/api-gateway-request-validator.yml)}

这是提供的错误日志

Running "serverless" from node_modules
Deploying myapp-api to stage dev (*********)
Adding Python requirements helper
Generated requirements from /home/circleci/project/requirements.txt in /home/circleci/project/.serverless/requirements.txt
Installing requirements from "/home/circleci/.cache/serverless-python-requirements/6b1b8e5bcb3893228e019bffa40e9c7db43bac76b8b7f2766f061ca751e722ce_x86_64_slspyc/requirements.txt"
Docker Image: public.ecr.aws/sam/build-python3.8:latest-x86_64
Using download cache directory /home/circleci/.cache/serverless-python-requirements/downloadCacheslspyc
Running docker run --rm -v /home/circleci/.cache/serverless-python-requirements/6b1b8e5bcb3893228e019bffa40e9c7db43bac76b8b7f2766f061ca751e722ce_x86_64_slspyc:/var/task:z -v /home/circleci/.cache/serverless-python-requirements/downloadCacheslspyc:/var/useDownloadCache:z public.ecr.aws/sam/build-python3.8:latest-x86_64 /bin/sh -c 'chown -R 0\:0 /var/useDownloadCache && python3.8 -m pip install -t /var/task/ -r /var/task/requirements.txt --cache-dir /var/useDownloadCache && chown -R 3434\:3434 /var/task && chown -R 3434\:3434 /var/useDownloadCache && find /var/task -name \*.so -exec strip \{\} \;'...
× Stack myapp-api-dev failed to deploy (0s)
Environment: linux, node 16.16.0, framework 3.25.1 (local) 3.25.1v (global), plugin 6.2.2, SDK 4.3.2
Credentials: Local, environment variables
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues
Error:
Running "docker run --rm -v /home/circleci/.cache/serverless-python-requirements/6b1b8e5bcb3893228e019bffa40e9c7db43bac76b8b7f2766f061ca751e722ce_x86_64_slspyc:/var/task:z -v /home/circleci/.cache/serverless-python-requirements/downloadCacheslspyc:/var/useDownloadCache:z public.ecr.aws/sam/build-python3.8:latest-x86_64 /bin/sh -c chown -R 0:0 /var/useDownloadCache && python3.8 -m pip install -t /var/task/ -r /var/task/requirements.txt --cache-dir /var/useDownloadCache && chown -R 3434:3434 /var/task && chown -R 3434:3434 /var/useDownloadCache && find /var/task -name *.so -exec strip {} ;" failed with: "docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'."
Exited with code exit status 1

Docker不运行,当你使用球体aws-cliserverless-framework

所以解决方案是自己构建。

这是。circleci/config.yml

version: 2.1
jobs:
deploy:
docker: # run the steps with Docker
# Specify the version you desire here https://circleci.com/developer/images
- image: cimg/python:3.8-node
steps: # a set of executable commands
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}
- v1-dependencies-
- run:
name: install dependencies
command: |
python3 -m venv env
. env/bin/activate
pip install -r requirements.txt
- save_cache:
key: v1-dependencies-{{ checksum "requirements.txt" }}
paths:
- env
- run:
name: Update NPM
command: |
npm install -g npm
- run:
name: Install serverless framework
command: |
npm install -g serverless
- run:
name: Install serverless plugins
command: |
sls plugin install -n serverless-python-requirements
- run:
name: deploy
command: |
sls deploy --stage dev --verbose
sls doctor
workflows:
deploy:
jobs:
- deploy

和serverless。Yml文件

service: myapp-api
frameworkVersion: "3"
package:
patterns:
- '!node_modules/**'
- '!.vscode'
- '!.circleci'
- '!temp.txt'
- '!README.md'
- '!env/**'
- '!package.json'
- '!package-lock.json'
- '!others/*.yml'
- '!resources'
provider:
name: aws
stage: dev
endpointType: REGIONAL
runtime: python3.8
region: us-east-2
plugins:
- serverless-python-requirements
#   - serverless-reqvalidator-plugin
#   - serverless-aws-documentation
custom:
pythonRequirements:
noDeploy:
- boto3
- botocore
- docutils
- autopep8
- pycodestyle
- six
- tomli
functions:
# others & publics
- ${file(./others/TestGet.yml)}
- ${file(./others/DownloadFactsPost.yml)}
- ${file(./others/DownloadTagsPost.yml)}
resources:
# api gateway
- ${file(./resources/api-gateway-request-validator.yml)}

相关内容

  • 没有找到相关文章

最新更新