Skip to content

Commit 05191ec

Browse files
authored
Merge pull request #58 from codeguru42/54-docker-hub
54 docker hub
2 parents 40d9ad4 + 2c3ced3 commit 05191ec

File tree

2 files changed

+23
-40
lines changed

2 files changed

+23
-40
lines changed

.github/workflows/build.yaml

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,28 @@ jobs:
1313
- name: black
1414
uses: psf/black@stable
1515

16-
- name: Configure AWS credentials
17-
uses: aws-actions/configure-aws-credentials@v1-node16
16+
- name: Log in to Docker Hub
17+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
1818
with:
19-
role-to-assume: arn:aws:iam::200049542062:role/go_capture/GithubRole
20-
aws-region: us-west-1
19+
username: ${{ secrets.DOCKERHUB_USERNAME }}
20+
password: ${{ secrets.DOCKERHUB_TOKEN }}
2121

22-
- name: Set ECR Stack Name
23-
id: ecr-stack-name
24-
run: echo ECR_STACK_NAME=GoCaptureECR >> $GITHUB_OUTPUT
25-
26-
- name: Deploy ECR repository
27-
uses: aws-actions/aws-cloudformation-github-deploy@v1
22+
- name: Extract metadata (tags, labels) for Docker
23+
id: meta
24+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
2825
with:
29-
name: ${{ steps.ecr-stack-name.outputs.ECR_STACK_NAME }}
30-
template: cloud-formation/ecr.yaml
31-
no-fail-on-empty-changeset: 1
32-
33-
- name: Beta Deploy User
34-
uses: aws-actions/aws-cloudformation-github-deploy@v1
26+
images: codeguru42/go-capture
27+
tags: |
28+
type=raw,value=latest,enable={{is_default_branch}}
29+
type=semver,pattern={{version}}
30+
type=semver,pattern={{major}}.{{minor}}
31+
type=sha
32+
33+
- name: Build and push Docker image
34+
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
3535
with:
36-
name: GoCaptureBetaDeployUser
37-
template: cloud-formation/beta-deploy-user.yaml
38-
parameter-overrides: EcrStackName=${{ steps.ecr-stack-name.outputs.ECR_STACK_NAME }}
39-
capabilities: CAPABILITY_NAMED_IAM
40-
no-fail-on-empty-changeset: 1
41-
42-
- name: Login to Amazon ECR
43-
id: login-ecr
44-
uses: aws-actions/amazon-ecr-login@v1
45-
46-
- name: Build, tag, and push docker image to Amazon ECR
47-
env:
48-
BRANCH_NAME: ${{ github.ref_name }}
49-
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
50-
REPOSITORY: go-capture
51-
IMAGE_TAG: ${{ github.sha }}
52-
run: |
53-
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
54-
if [ $BRANCH_NAME = main ]
55-
then
56-
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
57-
fi
36+
context: .
37+
file: ./Dockerfile
38+
push: true
39+
tags: ${{ steps.meta.outputs.tags }}
40+
labels: ${{ steps.meta.outputs.labels }}

docker-compose-prod.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
services:
22
api:
3-
image: ${account_id}.dkr.ecr.us-west-1.amazonaws.com/go-capture:${image_hash}
3+
image: ${image}:${tag}
44
env_file:
55
- .env
66
environment:
77
- CELERY_BROKER_URL=amqp://guest:guest@broker:5672
88
ports:
99
- 8000:8000
1010
worker:
11-
image: ${account_id}.dkr.ecr.us-west-1.amazonaws.com/go-capture:${image_hash}
11+
image: ${image}:${tag}
1212
command: "poetry run celery -A go_capture.tasks worker"
1313
depends_on:
1414
- broker

0 commit comments

Comments
 (0)