Skip to content

Commit 2d6191f

Browse files
Publish docker image to AWS ECR (#11)
1 parent 802c3f9 commit 2d6191f

6 files changed

+26
-50
lines changed

.github/workflows/main-branch-workflow.yml

-39
This file was deleted.

.github/workflows/publish.yml

+15-7
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,26 @@ on:
66
- '[0-9]+.[0-9]+.[0-9]+'
77

88
jobs:
9-
publish-to-docker-hub:
9+
publish-to-aws-ecr:
1010
runs-on: ubuntu-latest
1111
env:
1212
ENVIRONMENT: prod
13-
IMAGE_NAME: bluebrain/obp-accounting-service
13+
IMAGE_NAME: ${{ vars.PUBLICECR_URI }}
1414
steps:
1515
- name: Checkout code
1616
uses: actions/checkout@v4
17-
- name: Login to Docker Hub
18-
uses: docker/login-action@v3
17+
18+
- name: Configure AWS credentials
19+
uses: aws-actions/configure-aws-credentials@v4
20+
with:
21+
aws-access-key-id: ${{ secrets.PUBLICECR_UPLOAD_ACCESS_KEY_ID }}
22+
aws-secret-access-key: ${{ secrets.PUBLICECR_UPLOAD_SECRET_ACCESS_KEY }}
23+
aws-region: ${{ vars.PUBLICECR_REGION }}
24+
25+
- name: Authenticate with AWS Public ECR
26+
uses: aws-actions/amazon-ecr-login@v2
1927
with:
20-
username: ${{ vars.DOCKER_USERNAME }}
21-
password: ${{ secrets.DOCKER_PASSWORD }}
22-
- name: Build and publish the Docker image to DockerHub
28+
registry-type: public
29+
30+
- name: Build and publish the Docker image to AWS ECR
2331
run: make publish

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# syntax=docker/dockerfile:1.9
2-
ARG UV_VERSION=0.4.20
2+
ARG UV_VERSION=0.6
33
ARG PYTHON_VERSION=3.12
44
ARG PYTHON_BASE=${PYTHON_VERSION}-slim
55

Makefile

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ export APP_NAME := accounting-service
55
export APP_VERSION := $(shell git describe --abbrev --dirty --always --tags)
66
export COMMIT_SHA := $(shell git rev-parse HEAD)
77
export IMAGE_NAME ?= $(APP_NAME)
8-
export IMAGE_TAG ?= $(APP_VERSION)-$(ENVIRONMENT)
8+
export IMAGE_TAG := $(APP_VERSION)
9+
export IMAGE_TAG_ALIAS := latest
10+
ifneq ($(ENVIRONMENT), prod)
11+
export IMAGE_TAG := $(IMAGE_TAG)-$(ENVIRONMENT)
12+
export IMAGE_TAG_ALIAS := $(IMAGE_TAG_ALIAS)-$(ENVIRONMENT)
13+
endif
914

1015
help: ## Show this help
1116
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-23s\033[0m %s\n", $$1, $$2}'

docker-compose.run.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ services:
99
- APP_NAME
1010
- APP_VERSION
1111
- COMMIT_SHA
12+
tags:
13+
- "${IMAGE_NAME}:${IMAGE_TAG_ALIAS}"
1214
ports:
1315
- "127.0.0.1:8100:8000"
1416
environment:
@@ -51,7 +53,7 @@ services:
5153
ports:
5254
- "127.0.0.1:5433:5432"
5355
healthcheck:
54-
test: ["CMD-SHELL", "pg_isready -U accounting_service"]
56+
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER"]
5557
interval: 10s
5658
timeout: 5s
5759
retries: 3

docker-compose.test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ services:
3131
ports:
3232
- "127.0.0.1:5434:5432"
3333
healthcheck:
34-
test: ["CMD-SHELL", "pg_isready -U accounting_service"]
34+
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER"]
3535
interval: 10s
3636
timeout: 5s
3737
retries: 3

0 commit comments

Comments
 (0)