saito.k 4f0e4f4a74 Merged PR 262: [Sprint13-1着手]Pipelineのbuild/pushを固定IPで行えるようにする
## 概要
[Task2109: [Sprint13-1着手]Pipelineのbuild/pushを固定IPで行えるようにする](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2109)

- 新たに作成したリソース
  - maintenance-rg
    - vm-odms-deploy-maintenance(Pipeline実行環境のVM)
    - vm-odms-deploy-maintenance_disk1_1cbaf8f9bfdf4548902316f7be8189ed(VMのディスク)
    - nsg-odms-deploy-maintenance(VMがあるサブネットに付与したNSG)
    - vm-odms-deploy-maintenance759(VMに付与されたNIC)
    - vm-odms-deploy-maintenance_key_0720(SSH接続するために割り当てられたアクセスキー)
- 変更したリソース
  - Key Vault
    - PipelineVMがあるサブネットからのアクセスを許可する
  - nsg-odms-private-dev(DBのあるサブネットのNSG)
    - PipelineVMからのアクセスを許可する
  - Pieplineの処理

## レビューポイント
- 特にレビューしてほしい箇所
- 軽微なものや自明なものは記載不要
- 修正範囲が大きい場合などに記載
- 全体的にや仕様を満たしているか等は本当に必要な時のみ記載

## UIの変更
- Before/Afterのスクショなど
- スクショ置き場

## 動作確認状況
- deployされていることを確認

## 補足
- 相談、参考資料などがあれば
2023-07-25 08:08:38 +00:00

123 lines
4.1 KiB
YAML

# Variable 'static_dictation_deployment_token' was defined in the Variables tab
trigger:
branches:
include:
- refs/heads/develop
jobs:
- job: Job_1
displayName: Dictation App Service Deploy
pool:
name: odms-deploy-pipeline
steps:
- checkout: self
clean: true
fetchDepth: 1
- task: Npm@1
displayName: npm ci
inputs:
command: ci
workingDir: dictation_server
verbose: false
- task: AzureKeyVault@2
displayName: 'Azure Key Vault: kv-odms-secret-dev'
inputs:
ConnectedServiceName: 82047c72-0cfe-43b0-bb2f-cdfd8b165e68
KeyVaultName: kv-odms-secret-dev
SecretsFilter: token-public-key
- task: Bash@3
displayName: Bash Script (Test)
inputs:
targetType: inline
filePath: cd dictation_server && JWT_PUBLIC_KEY="$JWT_PUBLIC_KEY" && npm run test
script: >
cd dictation_server && JWT_PUBLIC_KEY="$JWT_PUBLIC_KEY" && npm run test
- task: Docker@0
displayName: build
inputs:
azureSubscriptionEndpoint: 827be338-1846-4102-b006-f457c92883d3
azureContainerRegistry: '{"loginServer":"crodmsregistrymaintenance.azurecr.io", "id" : "/subscriptions/108fb131-cdca-4729-a2be-e5bd8c0b3ba7/resourceGroups/maintenance-rg/providers/Microsoft.ContainerRegistry/registries/crOdmsRegistryMaintenance"}'
dockerFile: DockerfileServerDictation.dockerfile
imageName: $(Build.Repository.Name)/dictation:latest
- task: Docker@0
displayName: Push
inputs:
azureSubscriptionEndpoint: 827be338-1846-4102-b006-f457c92883d3
azureContainerRegistry: '{"loginServer":"crodmsregistrymaintenance.azurecr.io", "id" : "/subscriptions/108fb131-cdca-4729-a2be-e5bd8c0b3ba7/resourceGroups/maintenance-rg/providers/Microsoft.ContainerRegistry/registries/crOdmsRegistryMaintenance"}'
action: Push an image
imageName: $(Build.Repository.Name)/dictation:latest
- job: Job_2
displayName: Dictation Static App Service Deploy
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
clean: true
fetchDepth: 1
- task: Npm@1
displayName: npm ci
inputs:
command: ci
workingDir: dictation_client
verbose: false
- task: Bash@3
displayName: Bash Script
inputs:
targetType: inline
script: cd dictation_client && npm run build
- task: AzureStaticWebApp@0
displayName: 'Static Web App: '
inputs:
app_location: /dictation_client/build
config_file_location: /dictation_client
skip_app_build: true
skip_api_build: true
is_static_export: false
verbose: false
azure_static_web_apps_api_token: $(static_dictation_deployment_token)
- job: Job_3
displayName: DB migration
dependsOn:
- Job_1
- Job_2
pool:
name: odms-deploy-pipeline
steps:
- checkout: self
clean: true
fetchDepth: 1
- task: AzureKeyVault@2
displayName: 'Azure Key Vault: kv-odms-secret-dev'
inputs:
ConnectedServiceName: 82047c72-0cfe-43b0-bb2f-cdfd8b165e68
KeyVaultName: kv-odms-secret-dev
- task: CmdLine@2
displayName: migration
inputs:
script: >2
# DB接続情報書き換え
sed -i -e "s/DB_NAME/$(db-name)/g" ./dictation_server/db/dbconfig.yml
sed -i -e "s/DB_PASS/$(db-pass)/g" ./dictation_server/db/dbconfig.yml
sed -i -e "s/DB_USERNAME/$(db-user)/g" ./dictation_server/db/dbconfig.yml
sed -i -e "s/DB_PORT/$(db-port)/g" ./dictation_server/db/dbconfig.yml
sed -i -e "s/DB_HOST/$(db-host)/g" ./dictation_server/db/dbconfig.yml
sql-migrate --version
cat ./dictation_server/db/dbconfig.yml
# migration実行
sql-migrate up -config=./dictation_server/db/dbconfig.yml -env=ci
- job: Job_4
displayName: Docker Image Clean Up
dependsOn: Job_1
pool:
name: odms-deploy-pipeline
steps:
- checkout: self
clean: true
fetchDepth: 1
- task: Docker@0
displayName: Clean up
inputs:
action: Run a Docker command
imageName: $(Build.Repository.Name)/dictation:latest
customCommand: 'image prune -af '
...