Github操作将Docker部署到AWS ECS ECR [英] Github action deploy docker to AWS ECS ECR
本文介绍了Github操作将Docker部署到AWS ECS ECR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用Github操作来构建并将github存储库的前端和后端映像推送到AWS ECR.
Hi I want to use Github action to build and push my github repo's frontend and backend images to AWS ECR.
如何更改Github操作的这部分配置?
How change this part of the Github action's config??
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: githubactions
IMAGE_TAG: latest
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
可以说,在我的Github存储库中,我有两个带有web/Dockerfile和backend/Dockerfile的映像
Lets say in my Github repository, I have two images with web/Dockerfile and backend/Dockerfile
推荐答案
您只需要使用 docker build -f PATH
并运行build + push命令两次,即可作为同一命令中的其他命令步骤:
You just need to use docker build -f PATH
and run the build+push commands twice, either as additional commands in the same step:
- name: Build, tag, and push images to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker build -f backend/Dockerfile -t $ECR_REGISTRY/backend:latest .
docker push $ECR_REGISTRY/backend:latest
docker build -f web/Dockerfile -t $ECR_REGISTRY/web:latest .
docker push $ECR_REGISTRY/web:latest
或两个单独的步骤:
- name: Build, tag, and push backend image to Amazon ECR
id: build-backend
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: backend
IMAGE_TAG: latest
run: |
docker build -f backend/Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
- name: Build, tag, and push web image to Amazon ECR
id: build-web
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: web
IMAGE_TAG: latest
run: |
docker build -f web/Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
这篇关于Github操作将Docker部署到AWS ECS ECR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文