generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (66 loc) · 2.65 KB
/
docker-image-ecr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Docker Image ECR CI
on:
push:
branches:
- '**'
env:
AWS_REGION: eu-central-1
ECR_REPO_URI: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-north-1.amazonaws.com/flask-app
DOCKERHUB_URI: ingunnaf
IMAGE_NAME: flask-app
TAG: latest
jobs:
# Parts of this comes from https://docs.github.com/en/actions/publishing-packages/publishing-docker-images
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ingunnaf/flask-app
- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# - name: Build and Push Docker Image
# run: |
# docker build -t ${{ env.IMAGE_NAME }}:${{ env.TAG }} /src/backend/Dockerfile
# docker tag ${{ env.IMAGE_NAME }}:${{ env.TAG }} ${{ env.DOCKERHUB_URI }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
# docker push ${{ env.ECR_REPO_URI }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
# docker-build-push:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# role-to-assume: ${{ secrets.AWS_IAM_ROLE }}
# aws-region: ${{ env.AWS_REGION }}
# - name: Login to Amazon ECR
# run: |
# aws ecr get-login-password \
# --region ${{ env.AWS_REGION }} \
# | docker login \
# --username AWS \
# --password-stdin ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com
# - name: Log in to Dockerhub
# uses:
# - name: Build and Push Docker Image
# run: |
# docker build -t ${{ env.IMAGE_NAME }}:${{ env.TAG }} .
# docker tag ${{ env.IMAGE_NAME }}:${{ env.TAG }} ${{ env.ECR_REPO_URI }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
# docker push ${{ env.ECR_REPO_URI }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}