Update: new deploy flow for AWS
This commit is contained in:
parent
5efb9220cb
commit
640c7504c4
@ -1,2 +1 @@
|
|||||||
.git
|
.git
|
||||||
weights/
|
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -28,3 +28,4 @@ curl.md
|
|||||||
cope2n-api/fwd_api/commands/init_database.py
|
cope2n-api/fwd_api/commands/init_database.py
|
||||||
/data
|
/data
|
||||||
backup
|
backup
|
||||||
|
demo-ocr/
|
@ -5,4 +5,3 @@ __pycache__
|
|||||||
DataBase/image_temp/
|
DataBase/image_temp/
|
||||||
DataBase/json_temp/
|
DataBase/json_temp/
|
||||||
DataBase/template.db
|
DataBase/template.db
|
||||||
weights
|
|
@ -1 +1 @@
|
|||||||
Subproject commit bdba044bb2eacac7c7cfe0e0f321196d03b681f6
|
Subproject commit a471c1018c17cc917d1723776bae81f829450f95
|
@ -19,6 +19,6 @@ COPY --chown=${UID}:${GID} requirements.txt /app
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN pip install -r requirements.txt --no-cache-dir
|
RUN pip install -r requirements.txt --no-cache-dir
|
||||||
|
|
||||||
# COPY --chown=${UID}:${GID} . /app
|
COPY --chown=${UID}:${GID} . /app
|
||||||
|
|
||||||
ENV TZ="Asia/Ho_Chi_Minh"
|
ENV TZ="Asia/Ho_Chi_Minh"
|
||||||
|
1
demo-ocr
1
demo-ocr
@ -1 +0,0 @@
|
|||||||
Subproject commit 036226c29ecd4aa0e28e89880c7b331523266caa
|
|
@ -4,6 +4,7 @@ import random
|
|||||||
import string
|
import string
|
||||||
import os
|
import os
|
||||||
import boto3
|
import boto3
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
BASH_FILE = './deploy_images.sh'
|
BASH_FILE = './deploy_images.sh'
|
||||||
S3_ENDPOINT = ""
|
S3_ENDPOINT = ""
|
||||||
@ -75,6 +76,8 @@ def random_hash():
|
|||||||
def deploy():
|
def deploy():
|
||||||
# Define the variable
|
# Define the variable
|
||||||
tag = str(random_hash()[:8])
|
tag = str(random_hash()[:8])
|
||||||
|
now = datetime.now()
|
||||||
|
tag = tag + "_" + str(now.strftime("%d%m%y%H%M%S"))
|
||||||
print(tag)
|
print(tag)
|
||||||
|
|
||||||
# Execute the Bash script with the variable as a command-line argument
|
# Execute the Bash script with the variable as a command-line argument
|
||||||
@ -85,14 +88,20 @@ def deploy():
|
|||||||
# TODO: Update to S3
|
# TODO: Update to S3
|
||||||
s3_client = MinioS3Client(S3_ACCESS_KEY, S3_SECRET_KEY, S3_BUCKET, S3_ENDPOINT)
|
s3_client = MinioS3Client(S3_ACCESS_KEY, S3_SECRET_KEY, S3_BUCKET, S3_ENDPOINT)
|
||||||
local_compose_file = f"./docker-compose_{tag}.yml"
|
local_compose_file = f"./docker-compose_{tag}.yml"
|
||||||
local_env_file = f"./.env_{tag}.yml"
|
local_env_file = f"./.env_{tag}"
|
||||||
|
|
||||||
s3_compose_file = f"docker-yaml-files/docker-compose_{tag}.yml"
|
s3_compose_file = f"docker-yaml-files/docker-compose_{tag}.yml"
|
||||||
s3_env_file = f"env-files/.env_{tag}.yml"
|
s3_env_file = f"env-files/.env_{tag}"
|
||||||
|
|
||||||
|
|
||||||
print(f"[INFO]: Uploading compose and env file to s3...")
|
print(f"[INFO]: Uploading compose and env file to s3...")
|
||||||
s3_client.upload_file(local_compose_file, s3_compose_file)
|
s3_client.upload_file(local_compose_file, s3_compose_file)
|
||||||
s3_client.upload_file(local_env_file, s3_env_file)
|
s3_client.upload_file(local_env_file, s3_env_file)
|
||||||
|
|
||||||
|
print(f"[INFO]: Deleting files...")
|
||||||
|
os.remove(local_compose_file)
|
||||||
|
os.remove(local_env_file)
|
||||||
|
|
||||||
|
print(f"[INFO]: Done !!!")
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
deploy()
|
deploy()
|
@ -1,21 +1,23 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
docker compose -f docker-compose-dev.yml build
|
|
||||||
|
|
||||||
tag=$1
|
tag=$1
|
||||||
|
|
||||||
echo "Tag received from Python: $tag"
|
echo "[INFO] Tag received from Python: $tag"
|
||||||
|
|
||||||
echo "Building AI image with tag: $tag..."
|
echo "[INFO] Pushing AI image with tag: $tag..."
|
||||||
|
docker compose -f docker-compose-dev.yml build cope2n-fi-sbt
|
||||||
docker tag sidp/cope2n-ai-fi-sbt:latest public.ecr.aws/v4n9y6r8/sidp/cope2n-ai-fi-sbt:${tag}
|
docker tag sidp/cope2n-ai-fi-sbt:latest public.ecr.aws/v4n9y6r8/sidp/cope2n-ai-fi-sbt:${tag}
|
||||||
# docker push public.ecr.aws/v4n9y6r8/sidp/cope2n-ai-fi-sbt:${tag}
|
docker push public.ecr.aws/v4n9y6r8/sidp/cope2n-ai-fi-sbt:${tag}
|
||||||
|
|
||||||
echo "Building BE image with tag: $tag..."
|
echo "[INFO] Pushing BE image with tag: $tag..."
|
||||||
|
docker compose -f docker-compose-dev.yml build be-ctel-sbt
|
||||||
docker tag sidp/cope2n-be-fi-sbt:latest public.ecr.aws/v4n9y6r8/sidp/cope2n-be-fi-sbt:${tag}
|
docker tag sidp/cope2n-be-fi-sbt:latest public.ecr.aws/v4n9y6r8/sidp/cope2n-be-fi-sbt:${tag}
|
||||||
# docker push public.ecr.aws/v4n9y6r8/sidp/cope2n-ai-fi-sbt:${tag}
|
docker push public.ecr.aws/v4n9y6r8/sidp/cope2n-be-fi-sbt:${tag}
|
||||||
|
|
||||||
echo "Building BE image with tag: $tag..."
|
echo "[INFO] Pushing FE image with tag: $tag..."
|
||||||
|
docker compose -f docker-compose-dev.yml build fe-sbt
|
||||||
docker tag sidp/cope2n-fe-fi-sbt:latest public.ecr.aws/v4n9y6r8/sidp/cope2n-fe-fi-sbt:${tag}
|
docker tag sidp/cope2n-fe-fi-sbt:latest public.ecr.aws/v4n9y6r8/sidp/cope2n-fe-fi-sbt:${tag}
|
||||||
# docker push public.ecr.aws/v4n9y6r8/sidp/cope2n-ai-fi-sbt:${tag}
|
docker push public.ecr.aws/v4n9y6r8/sidp/cope2n-fe-fi-sbt:${tag}
|
||||||
|
|
||||||
cp ./docker-compose.yml ./docker-compose_${tag}.yml
|
cp ./docker-compose.yml ./docker-compose_${tag}.yml
|
||||||
sed -i "s/{{tag}}/$tag/g" ./docker-compose_${tag}.yml
|
sed -i "s/{{tag}}/$tag/g" ./docker-compose_${tag}.yml
|
||||||
|
@ -34,7 +34,7 @@ services:
|
|||||||
command: bash run.sh
|
command: bash run.sh
|
||||||
deploy:
|
deploy:
|
||||||
mode: replicated
|
mode: replicated
|
||||||
replicas: 3
|
replicas: 1
|
||||||
# Back-end services
|
# Back-end services
|
||||||
be-ctel-sbt:
|
be-ctel-sbt:
|
||||||
build:
|
build:
|
||||||
@ -69,12 +69,14 @@ services:
|
|||||||
- S3_SECRET_KEY=${S3_SECRET_KEY}
|
- S3_SECRET_KEY=${S3_SECRET_KEY}
|
||||||
- S3_BUCKET_NAME=${S3_BUCKET_NAME}
|
- S3_BUCKET_NAME=${S3_BUCKET_NAME}
|
||||||
restart: always
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 9000:9000
|
||||||
networks:
|
networks:
|
||||||
- ctel-sbt
|
- ctel-sbt
|
||||||
volumes:
|
volumes:
|
||||||
- ${HOST_MEDIA_FOLDER}:${MEDIA_ROOT}
|
- ${HOST_MEDIA_FOLDER}:${MEDIA_ROOT}
|
||||||
- ./data/BE_static:/app/static
|
- BE_static:/app/static
|
||||||
- ./cope2n-api:/app
|
# - ./cope2n-api:/app
|
||||||
working_dir: /app
|
working_dir: /app
|
||||||
depends_on:
|
depends_on:
|
||||||
db-sbt:
|
db-sbt:
|
||||||
@ -160,7 +162,7 @@ services:
|
|||||||
condition: service_started
|
condition: service_started
|
||||||
volumes:
|
volumes:
|
||||||
- ${HOST_MEDIA_FOLDER}:${MEDIA_ROOT}
|
- ${HOST_MEDIA_FOLDER}:${MEDIA_ROOT}
|
||||||
- ./cope2n-api:/app
|
# - ./cope2n-api:/app
|
||||||
|
|
||||||
working_dir: /app
|
working_dir: /app
|
||||||
command: sh -c "celery -A fwd_api.celery_worker.worker worker -l INFO -c 5"
|
command: sh -c "celery -A fwd_api.celery_worker.worker worker -l INFO -c 5"
|
||||||
@ -201,7 +203,7 @@ services:
|
|||||||
shm_size: 10gb
|
shm_size: 10gb
|
||||||
privileged: true
|
privileged: true
|
||||||
ports:
|
ports:
|
||||||
- 80:80
|
- 9881:80
|
||||||
depends_on:
|
depends_on:
|
||||||
be-ctel-sbt:
|
be-ctel-sbt:
|
||||||
condition: service_started
|
condition: service_started
|
||||||
@ -211,9 +213,10 @@ services:
|
|||||||
- VITE_PROXY=http://be-ctel-sbt:${BASE_PORT}
|
- VITE_PROXY=http://be-ctel-sbt:${BASE_PORT}
|
||||||
- VITE_API_BASE_URL=http://fe-sbt:80
|
- VITE_API_BASE_URL=http://fe-sbt:80
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/BE_static:/backend-static
|
- BE_static:/backend-static
|
||||||
networks:
|
networks:
|
||||||
- ctel-sbt
|
- ctel-sbt
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
db_data:
|
db_data:
|
||||||
|
BE_static:
|
Loading…
Reference in New Issue
Block a user