首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >循环Ci,无服务器框架,无服务器python.要求

循环Ci,无服务器框架,无服务器python.要求
EN

Stack Overflow用户
提问于 2022-12-01 10:54:49
回答 1查看 70关注 0票数 1

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

我用的球体就像

aws-cli: circleci/aws-cli@3.1.3

serverless-framework: circleci/serverless-framework@2.0.0

有什么帮助吗?

这是。循环/config.yml

代码语言:javascript
复制
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文件是

代码语言:javascript
复制
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)}

这是提供的错误日志。

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2022-12-01 14:38:19

当您使用orbs、aws-cliserverless-framework时,Docker不运行

所以解决的办法是自己建造它。

这是。循环/config.yml

代码语言:javascript
复制
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文件是

代码语言:javascript
复制
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)}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74640748

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档