Skip to content

Commit 621f9fb

Browse files
committed
WIP
1 parent 29748e1 commit 621f9fb

15 files changed

Lines changed: 111 additions & 61 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,4 @@ tests/test_data/notice_transformer/mapping_suite_processor_repository/test_packa
121121
tests/test_data/notice_transformer/mapping_suite_processor_repository/test_package_fake/transformation/resources/languages.json
122122
tests/test_data/notice_transformer/mapping_suite_processor_repository/test_package_fake/transformation/resources/main_activity.json
123123
tests/test_data/notice_transformer/mapping_suite_processor_repository/test_package_fake/transformation/resources/nuts.json
124+
/infra/digest_api/digest_service/project_requirements.txt

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,10 @@ start-all-apis: start-digest_service-api
307307

308308
stop-all-apis: stop-digest_service-api
309309

310-
build-digest_service-api:
310+
create-env-digest-api:
311+
@ cp requirements.txt ./infra/digest_api/digest_service/project_requirements.txt
312+
313+
build-digest_service-api: create-env-digest-api
311314
@ echo -e "$(BUILD_PRINT) Build digest_service API service $(END_BUILD_PRINT)"
312315
@ docker-compose -p common --file infra/api/docker-compose.yml --env-file ${ENV_FILE} build --no-cache --force-rm
313316
@ docker-compose -p common --file infra/api/docker-compose.yml --env-file ${ENV_FILE} up -d --force-recreate

infra/airflow/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM apache/airflow:2.2.5-python3.8
1+
FROM docker.io/apache/airflow:2.2.5-python3.8
22

33
# quick sudo
44
USER root

infra/airflow/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ services:
104104
- airflow
105105

106106
redis:
107-
image: redis:latest
107+
image: redis:7.0.4-alpine3.16
108108
container_name: redis-airflow-${ENVIRONMENT}
109109
expose:
110110
- 6379

infra/api/digest_service/Dockerfile

Lines changed: 0 additions & 11 deletions
This file was deleted.

infra/aws/airflow.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ services:
1919
AIRFLOW_HOME: /opt/airflow
2020
PYTHONPATH: /opt/airflow/
2121
AIRFLOW_UID: ${AIRFLOW_UID}
22-
image: public.ecr.aws/g5y4d1v2/meaningfy:airflow-meaningfy-225
22+
image: ${AIRFLOW_IMAGE_URI}
2323
links:
2424
- postgres
2525
- redis
@@ -62,7 +62,7 @@ services:
6262
AIRFLOW_HOME: /opt/airflow
6363
PYTHONPATH: /opt/airflow/
6464
AIRFLOW_UID: ${AIRFLOW_UID}
65-
image: public.ecr.aws/g5y4d1v2/meaningfy:airflow-meaningfy-225
65+
image: ${AIRFLOW_IMAGE_URI}
6666
logging:
6767
driver: awslogs
6868
options:
@@ -86,7 +86,7 @@ services:
8686
timeout: 5s
8787
interval: 30s
8888
retries: 3
89-
image: public.ecr.aws/g5y4d1v2/meaningfy:postgres
89+
image: ${AIRFLOW_POSTGRES_IMAGE_URI}
9090
logging:
9191
driver: awslogs
9292
options:
@@ -103,7 +103,7 @@ services:
103103
interval: 5s
104104
timeout: 30s
105105
retries: 10
106-
image: public.ecr.aws/g5y4d1v2/meaningfy:redis
106+
image: ${REDIS_IMAGE_URI}
107107
labels:
108108
ecs-local.task-definition-input.type: remote
109109
ecs-local.task-definition-input.value: airflow-reload-task
@@ -137,7 +137,7 @@ services:
137137
interval: 10s
138138
timeout: 10s
139139
retries: 5
140-
image: public.ecr.aws/g5y4d1v2/meaningfy:airflow-meaningfy-225
140+
image: ${AIRFLOW_IMAGE_URI}
141141
links:
142142
- postgres
143143
- redis
@@ -170,7 +170,7 @@ services:
170170
PYTHONPATH: /opt/airflow/
171171
RML_MAPPER_PATH: /opt/airflow/.rmlmapper/rmlmapper.jar
172172
XML_PROCESSOR_PATH: /opt/airflow/.saxon/saxon-he-10.6.jar
173-
image: public.ecr.aws/g5y4d1v2/meaningfy:airflow-meaningfy-225
173+
image: ${AIRFLOW_IMAGE_URI}
174174
links:
175175
- postgres
176176
- redis
@@ -205,7 +205,7 @@ services:
205205
PYTHONPATH: /opt/airflow/
206206
RML_MAPPER_PATH: /opt/airflow/.rmlmapper/rmlmapper.jar
207207
XML_PROCESSOR_PATH: /opt/airflow/.saxon/saxon-he-10.6.jar
208-
image: public.ecr.aws/g5y4d1v2/meaningfy:airflow-meaningfy-225
208+
image: ${AIRFLOW_IMAGE_URI}
209209
links:
210210
- postgres
211211
- redis
@@ -244,7 +244,7 @@ services:
244244
PYTHONPATH: /opt/airflow/
245245
RML_MAPPER_PATH: /opt/airflow/.rmlmapper/rmlmapper.jar
246246
XML_PROCESSOR_PATH: /opt/airflow/.saxon/saxon-he-10.6.jar
247-
image: public.ecr.aws/g5y4d1v2/meaningfy:airflow-meaningfy-225
247+
image: ${AIRFLOW_IMAGE_URI}
248248
labels:
249249
ecs-local.task-definition-input.type: remote
250250
ecs-local.task-definition-input.value: airflow-reload-task
Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
REGION=eu-west-3
2-
REPOSITORIES=(fuseki)
1+
REGION=eu-west-1
32
MONGO_IMAGE=docker.io/mongo:5.0.10
43
FUSEKI_IMAGE=docker.io/secoresearch/fuseki:4.5.0
54
METABASE_IMAGE=docker.io/metabase/metabase:v0.43.4
6-
AIRFLOW_POSTGRES=docker.io/postgres:14.4-alpine
5+
AIRFLOW_POSTGRES_IMAGE=docker.io/postgres:14.4-alpine
6+
REDIS_IMAGE=docker.io/redis:7.0.4-alpine3.16
7+
MONGO_EXPRESS_IMAGE=docker.io/mongo-express:0.54.0
78

8-
IMAGES_TO_BE_BUILD=(airflow digest-api )
9+
10+
IMAGES_TO_BE_BUILD=(airflow digest_api metabase_postgres)
11+
IMAGES_FROM_DOCKER_HUB=(fuseki airflow_postgres metabase mongo redis mongo_express)
912

1013
touch .repositories_ids
1114

1215
create_repository(){
1316
echo "Creating repository for $1"
14-
aws ecr create-repository --repository-name $1 --image-scanning-configuration scanOnPush=true --region $2 > repo.json
17+
aws ecr create-repository --repository-name $1 --region $2 > repo.json
1518
REPO_NAME=$1
1619
REPO_ID=`jq -r ".repository.repositoryUri" repo.json`
1720
echo ${REPO_NAME^^}_REPO_ID=$REPO_ID >> .repositories_ids
@@ -21,35 +24,74 @@ create_repository(){
2124

2225

2326
build_image_and_push_to_repo(){
27+
echo "Building image for $1"
2428
REPO=$1
2529
REPO_NAME=${REPO^^}
2630
REPO_ID=${REPO_NAME}_REPO_ID
2731
echo ${!REPO_ID}
28-
aws ecr get-login-password --region eu-west-3 | podman login --username AWS --password-stdin ${!REPO_ID}
29-
podman build -t $1 ../$1/ --label=$1-image
32+
aws ecr get-login-password --region $REGION | podman login --username AWS --password-stdin ${!REPO_ID}
33+
if [ "$REPO" = "metabase_postgres" ]; then
34+
REPO=metabase
35+
fi
36+
podman build -t $REPO ../$REPO/ --label=$1-image
3037
IMAGE=`podman images --filter label=$1-image --format {{.Repository}}:{{.Tag}}`
38+
echo "image found is $IMAGE"
39+
TAG=$(echo $IMAGE| cut -d':' -f 2)
40+
echo "TAG found is $TAG"
41+
if [ ! -z $TAG ]
42+
then
43+
podman tag $IMAGE ${!REPO_ID}:$TAG
44+
podman push ${!REPO_ID}:$TAG
45+
fi
46+
3147
podman tag $IMAGE ${!REPO_ID}:latest
3248
podman push ${!REPO_ID}:latest
33-
}
3449

50+
echo ${REPO_NAME}_IMAGE_URI=${!REPO_ID}:latest >> .env
51+
echo "Image for $1 has been pushed in AWS"
52+
podman system prune --all --force && podman rmi --all
53+
}
3554

55+
get_built_image_and_push_to_repo(){
56+
echo "Getting image for $1"
57+
REPO=$1
58+
REPO_NAME=${REPO^^}
59+
REPO_ID=${REPO_NAME}_REPO_ID
60+
IMAGE_TO_PULL=${REPO_NAME}_IMAGE
61+
echo "REPO_ID=${!REPO_ID}"
62+
echo ${!IMAGE_TO_PULL}
63+
aws ecr get-login-password --region $REGION | podman login --username AWS --password-stdin ${!REPO_ID}
64+
podman pull ${!IMAGE_TO_PULL}
65+
echo "string to compare is $REPO"
66+
IMAGE_NAME_TO_FIND=$REPO
67+
if [ "$REPO" = "airflow_postgres" ]; then
68+
IMAGE_NAME_TO_FIND=postgres
69+
fi
70+
echo " Image to find is $IMAGE_NAME_TO_FIND"
71+
IMAGE=`podman images --format {{.Repository}}:{{.Tag}} | grep $IMAGE_NAME_TO_FIND`
72+
echo "image found is $IMAGE"
73+
TAG=$(echo $IMAGE| cut -d':' -f 2)
74+
podman tag $IMAGE ${!REPO_ID}:latest
75+
podman tag $IMAGE ${!REPO_ID}:$TAG
76+
podman push ${!REPO_ID}:latest
77+
podman push ${!REPO_ID}:$TAG
78+
echo ${REPO_NAME}_IMAGE_URI=${!REPO_ID}:latest >> .env
79+
echo "Image for $1 has been pushed in AWS"
80+
podman system prune --all --force && podman rmi --all
81+
}
3682

37-
for REPO in "${REPOSITORIES[@]}"
83+
for IMAGE in "${IMAGES_FROM_DOCKER_HUB[@]}"
3884
do
39-
# create_repository $REPO $REGION
85+
create_repository $IMAGE $REGION
4086
source .repositories_ids
4187
export $(cat .repositories_ids | xargs)
42-
build_image_and_push_to_repo $REPO
88+
get_built_image_and_push_to_repo $IMAGE
4389
done
4490

45-
46-
#podman images --filter label=label --format {{.Repository}}
47-
#podman images --format {{.Repository}} | grep fuseki
48-
#
49-
#
50-
#podman build -t fuseki ../fuseki/ --label=label
51-
#
52-
#docker push 013659641721.dkr.ecr.eu-west-3.amazonaws.com/fuseki:latest
53-
54-
55-
#aws ecr get-login-password --region eu-west-3 | podman login --username AWS --password-stdin 013659641721.dkr.ecr.eu-west-3.amazonaws.com
91+
for IMAGE in "${IMAGES_TO_BE_BUILD[@]}"
92+
do
93+
create_repository $IMAGE $REGION
94+
source .repositories_ids
95+
export $(cat .repositories_ids | xargs)
96+
build_image_and_push_to_repo $IMAGE
97+
done

infra/aws/digest-api.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: "3"
22
services:
33
digest-api:
4-
image: public.ecr.aws/g5y4d1v2/meaningfy:meaningfy-digest-api
4+
image: ${DIGEST_API_IMAGE_URI}
55
logging:
66
driver: awslogs
77
options:

infra/aws/metabase.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
ENV_MB_DB_PASS: ${ENV_MB_DB_PASS}
1010
ENV_MB_DB_HOST: postgres-metabase
1111
ENV_MB_ENCRYPTION_SECRET_KEY: ${ENV_MB_ENCRYPTION_SECRET_KEY}
12-
image: public.ecr.aws/g5y4d1v2/meaningfy:metabase
12+
image: ${METABASE_IMAGE_URI}
1313
logging:
1414
driver: awslogs
1515
options:
@@ -26,7 +26,7 @@ services:
2626
environment:
2727
POSTGRES_PASSWORD: postgres
2828
METABASE_PASSWORD: metabase
29-
image: public.ecr.aws/g5y4d1v2/meaningfy:metabase-postgres
29+
image: ${METABASE_POSTGRES_IMAGE_URI}
3030
volumes:
3131
- metabase-postgres-db:/var/lib/postgresql/data
3232
logging:

infra/aws/mongo-express.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
ME_CONFIG_MONGODB_ADMINUSERNAME: ${ME_CONFIG_MONGODB_ADMINUSERNAME}
99
ME_CONFIG_MONGODB_ENABLE_ADMIN: "true"
1010
ME_CONFIG_MONGODB_SERVER: ${ME_CONFIG_MONGODB_SERVER}
11-
image: public.ecr.aws/g5y4d1v2/meaningfy:mongo-express
11+
image: ${MONGO_EXPRESS_IMAGE_URI}
1212
logging:
1313
driver: awslogs
1414
options:

0 commit comments

Comments
 (0)