Git Hub操作在运行时失败



我的应用程序由两个项目组成,如客户端和服务器。客户端是一个react应用程序,服务器是一个基于spring-boot的java后端项目。两者都包含单独的docker文件,在根文件夹中,我使用docker-compose.yaml文件将两者组合在一起。它在本地机器上运行良好,现在我想在AWS中部署整个应用程序。我正在尝试使用Git Hub Action将图像部署到AWS。如下所示。

name: Deploy to AWS ECR
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Runs a single command using the runners shell
- 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-east-1
# Runs a set of commands using the runners shell
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: snake_ecr
IMAGE_TAG: latest
run: |
docker-compose up --build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

我的项目结构如下,

|
|-clientDockerfile
|-serverDockerfile
|-docker-compose.yml

当运行"Build,tag,and push image to Amazon ECR"区域时,脚本会给出以下错误,

Run docker-compose up --build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker-compose up --build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
shell: /usr/bin/bash -e {0}
env:
AWS_DEFAULT_REGION: us-east-1
AWS_REGION: us-east-1
AWS_ACCESS_KEY_ID: ***
AWS_SECRET_ACCESS_KEY: ***
ECR_REGISTRY: ***.dkr.ecr.us-east-1.amazonaws.com
ECR_REPOSITORY: snake_ecr
IMAGE_TAG: latest
[1644] Failed to execute script docker-compose
Traceback (most recent call last):
File "docker-compose", line 3, in <module>
File "compose/cli/main.py", line 81, in main
File "compose/cli/main.py", line 203, in perform_command
File "compose/metrics/decorator.py", line 18, in wrapper
File "compose/cli/main.py", line 1140, in up
File "compose/cli/main.py", line 1300, in timeout_from_opts
ValueError: invalid literal for int() with base 10: '***.dkr.ecr.us-east-1.amazonaws.com/snake_ecr:latest'

有人能帮我解决这个问题吗?

您确定用于运行操作的ubuntu最新映像上安装了docker compose吗?我通常会使用一个额外的图像来处理这里指定的类似内容:https://github.com/marketplace/actions/build-and-push-docker-images#git-上下文

name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: user/app:latest

然后,您可能需要单独指定docker图像,因为它不适用于docker compose。

最新更新