AWS ECR镜像未创建

huangapple go评论65阅读模式
英文:

AWS ECR images not creating

问题

我正在尝试按照一些教程将我的容器部署到 ECR(Amazon Elastic Container Registry)。(请注意,我对 ECR 流程完全不熟悉)。我的 Github actions 工作流成功运行,但是当我检查我的 ECR 存储库时,没有构建任何镜像。以下是包含工作流的我的 deplo.yml 文件:

name: 部署到生产环境

on:
  push:
    branches: ["main"]

jobs:

  build:
    name: 构建镜像
    runs-on: ubuntu-latest

    steps:
    - name: 检出代码
      uses: actions/checkout@v2

    - name: 配置 AWS 凭据
      uses: aws-actions/configure-aws-credentials@v1
      with:
        aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        aws-region: us-west-2

    - name: 登录到 Amazon ECR
      id: login-ecr
      uses: aws-actions/amazon-ecr-login@v1

    - name: 构建、标记并推送 Docker 镜像到 Amazon ECR
      env:
        REGISTRY: ${{ steps.login-ecr.outputs.registry }}
        REPOSITORY: my_repository_name
        IMAGE_TAG: ${{ github.sha }}
      run:
        docker-compose build --file ./myservice_docker/docker-compose.yml --tag myservice-service:$(date +%s) .
        docker-compose push --file ./myservice_docker/docker-compose.yml --tag myservice-service:$(date +%s) .

请注意,我已经将代码翻译成中文,但保留了代码部分的原始语言。

英文:

I'm trying to deploy my containers to ECR by following some tutorials. (Please note, I'm totally new to the ECR flow).
My workflow on Github actions is successful however when I check my ECR repository no images have been built. Here is my deplo.yml file that contains the workflow

name: Deploy to prod

on:
  push:
    branches: [ "main" ]
 

jobs:

  build:
    name: Build image
    runs-on: ubuntu-latest

    steps:
    - name: Check out code
      uses: actions/checkout@v2
      
    - name: Configure AWS credentials
      uses: aws-actions/configure-aws-credentials@v1
      with:
        aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        aws-region: us-west-2

    - name: Login to Amazon ECR
      id: login-ecr
      uses: aws-actions/amazon-ecr-login@v1

    - name: Build, tag, and push docker image to Amazon ECR
      env:
        REGISTRY: ${{ steps.login-ecr.outputs.registry }}
        REPOSITORY: my_repository_name
        IMAGE_TAG: ${{ github.sha }}
      run:
        docker-compose build --file ./myservice_docker/docker-compose.yml --tag myservice-service:$(date +%s) .
        docker-compose push --file ./myservice_docker/docker-compose.yml --tag myservice-service:$(date +%s) .

答案1

得分: 1

我不确定这是否是推送Docker镜像到ECR的正确命令。

您可以尝试以下命令:

docker-compose build --tag myservice-service:$(date +%s) --file ./myservice_docker/docker-compose.yml .

docker tag myservice-service:$(date +%s) xxxxx.dkr.ecr.${region}.amazonaws.com/myservice-service:$(date +%s)

docker push xxxx.dkr.ecr.${region}.amazonaws.com/myservice-service:$(date +%s)
英文:

I am not sure if it is the right command to push docker images to ECR.

Can you try below commands instead?

docker-compose build --tag myservice-service:$(date +%s) --file ./myservice_docker/docker-compose.yml .

docker tag myservice-service:$(date +%s) xxxxx.dkr.ecr.${region}.amazonaws.com/myservice-service:$(date +%s)

docker push xxxx.dkr.ecr.${region}.amazonaws.com/myservice-service:$(date +%s)

huangapple
  • 本文由 发表于 2023年6月12日 16:10:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76454689.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定