-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
31 lines (26 loc) · 1.72 KB
/
.gitlab-ci.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
stages:
- build
- test
- deploy
- clean
Fastapi_image_build:
stage: build
script:
- echo "FastApi build, Dockerfile:"
- cat Dockerfile
- docker build -t fastapi:$CI_PIPELINE_ID .
Fastapi_deploy_test:
stage: test
script:
- docker run -d -p 80 --name myfastapi-test-$CI_PIPELINE_ID fastapi:$CI_PIPELINE_ID
- docker stop myfastapi-test-$CI_PIPELINE_ID
- docker rm myfastapi-test-$CI_PIPELINE_ID
Fastapi_container_deploy1:
stage: deploy
script:
- printenv DB_PASSWORD
- x=$(docker ps -f "publish=49200" | awk '{print $1}'| sed -n '2p')
- docker stop $x && docker rm $x
- export Sql_URL="mysql+asyncmy://$DB_USERNAME:$DB_PASSWORD@$DB_HOSTNAME:$DB_PORT/$DB_NAME?charset=utf8mb4"
- docker run -d -p 49200:80 --name myfastapi-w1-$CI_PIPELINE_ID -e "ADMIN_RECAPTCHA_SECRET_KEY=$ADMIN_RECAPTCHA_SECRET_KEY" -e "GENERAL_USER_RECAPTCHA_SECRET_KEY=$GENERAL_USER_RECAPTCHA_SECRET_KEY" -e "DB_USERNAME=$DB_USERNAME" -e "DB_PASSWORD=$DB_PASSWORD" -e "DB_HOSTNAME=$DB_HOSTNAME" -e "DB_PORT=$DB_PORT" -e "DB_NAME=$DB_NAME" -e "REDIS_DB_PASSWORD=$REDIS_DB_PASSWORD" -e "REDIS_DB_HOSTNAME=$REDIS_DB_HOSTNAME" -e "REDIS_DB_PORT=$REDIS_DB_PORT" -e "REDIS_DB_NAME=$REDIS_DB_NAME" -e "REDIS_USER_NAME=$REDIS_USER_NAME" -e "ACCESS_KEY_ID=$ACCESS_KEY_ID" -e "ACCESS_KEY_SECRET=$ACCESS_KEY_SECRET" -e "SECRET_KEY=$SECRET_KEY" -e "USER_SECRET_KEY=$USER_SECRET_KEY" -e "SMTPSERVER=$SMTPSERVER" -e "SMTPUSER=$SMTPUSER" -e "SMTPPASSWORD=$SMTPPASSWORD" -e "MQ_HOSTNAME=$MQ_HOSTNAME" -e "MQ_USERNAME=$MQ_USERNAME" -e "MQ_USERPASSWORD=$MQ_USERPASSWORD" -e "MQ_DBNAME=$MQ_DBNAME" -e "MQ_DBPORT=$MQ_DBPORT" -e "LogStathIP=$LogStathIP" -e "REFSECRET_KEY=$REFSECRET_KEY" fastapi:$CI_PIPELINE_ID
- docker ps