Spaces:
Sleeping
Sleeping
Commit
·
375a71f
1
Parent(s):
2e2af5e
Add environment configuration and Docker setup for parser service
Browse files- .env.build.develop +3 -0
- .env.build.main +3 -0
- .env.build.staging +3 -0
- Dockerfile +1 -0
- azure-pipelines.yml +200 -0
- docker-compose.override.yml +7 -0
- docker-compose.yml +16 -0
.env.build.develop
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
CORS_ALLOW_ORIGINS=http://localhost, http://127.0.0.1
|
| 2 |
+
|
| 3 |
+
SPACY_MODEL_NAME=en_core_web_trf
|
.env.build.main
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
CORS_ALLOW_ORIGINS=http://localhost, http://127.0.0.1
|
| 2 |
+
|
| 3 |
+
SPACY_MODEL_NAME=en_core_web_trf
|
.env.build.staging
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
CORS_ALLOW_ORIGINS=http://localhost, http://127.0.0.1
|
| 2 |
+
|
| 3 |
+
SPACY_MODEL_NAME=en_core_web_trf
|
Dockerfile
CHANGED
|
@@ -44,6 +44,7 @@ USER appuser
|
|
| 44 |
EXPOSE 8001
|
| 45 |
|
| 46 |
ENV PYTHONUNBUFFERED=1
|
|
|
|
| 47 |
ENV SPACY_MODEL_NAME=en_core_web_sm
|
| 48 |
|
| 49 |
CMD ["python", "main.py"]
|
|
|
|
| 44 |
EXPOSE 8001
|
| 45 |
|
| 46 |
ENV PYTHONUNBUFFERED=1
|
| 47 |
+
ENV PYTHONPATH=/app
|
| 48 |
ENV SPACY_MODEL_NAME=en_core_web_sm
|
| 49 |
|
| 50 |
CMD ["python", "main.py"]
|
azure-pipelines.yml
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
trigger:
|
| 2 |
+
- main
|
| 3 |
+
|
| 4 |
+
pool:
|
| 5 |
+
vmImage: "ubuntu-24.04"
|
| 6 |
+
|
| 7 |
+
parameters:
|
| 8 |
+
- name: dockerRegistry
|
| 9 |
+
displayName: Docker Registry
|
| 10 |
+
type: string
|
| 11 |
+
default: "sifars.azurecr.io"
|
| 12 |
+
- name: projectName
|
| 13 |
+
displayName: Docker Compose Project Name
|
| 14 |
+
type: string
|
| 15 |
+
default: "parser"
|
| 16 |
+
|
| 17 |
+
variables:
|
| 18 |
+
- name: DOCKER_REGISTRY
|
| 19 |
+
value: ${{ parameters.dockerRegistry }}
|
| 20 |
+
- name: DOCKER_COMPOSE_PROJECT_NAME
|
| 21 |
+
value: ${{ parameters.projectName }}
|
| 22 |
+
|
| 23 |
+
stages:
|
| 24 |
+
- stage: Build
|
| 25 |
+
displayName: "Build and Publish"
|
| 26 |
+
jobs:
|
| 27 |
+
- job: BuildImages
|
| 28 |
+
displayName: "Build and Push Container Images"
|
| 29 |
+
steps:
|
| 30 |
+
# Source code checkout
|
| 31 |
+
- checkout: self
|
| 32 |
+
clean: true
|
| 33 |
+
fetchDepth: 1
|
| 34 |
+
persistCredentials: true
|
| 35 |
+
|
| 36 |
+
# Container registry login
|
| 37 |
+
- task: Docker@2
|
| 38 |
+
displayName: "Login to Container Registry"
|
| 39 |
+
inputs:
|
| 40 |
+
command: login
|
| 41 |
+
containerRegistry: $(DOCKER_REGISTRY)
|
| 42 |
+
|
| 43 |
+
# Environment setup
|
| 44 |
+
- task: DownloadSecureFile@1
|
| 45 |
+
displayName: "Download Environment Override File"
|
| 46 |
+
name: env_build_override
|
| 47 |
+
inputs:
|
| 48 |
+
secureFile: .env.build.$(Build.Repository.Name).$(Build.SourceBranchName).override
|
| 49 |
+
continueOnError: true
|
| 50 |
+
|
| 51 |
+
- task: Bash@3
|
| 52 |
+
displayName: "Setup Build Environment Variables"
|
| 53 |
+
inputs:
|
| 54 |
+
targetType: "inline"
|
| 55 |
+
script: mv .env.build.$(Build.SourceBranchName) .env
|
| 56 |
+
workingDirectory: $(Build.SourcesDirectory)
|
| 57 |
+
|
| 58 |
+
- task: Bash@3
|
| 59 |
+
displayName: "Add Trailing Empty Line"
|
| 60 |
+
inputs:
|
| 61 |
+
targetType: "inline"
|
| 62 |
+
script: echo >> .env
|
| 63 |
+
workingDirectory: $(Build.SourcesDirectory)
|
| 64 |
+
|
| 65 |
+
- task: Bash@3
|
| 66 |
+
displayName: "Override Environment Variables"
|
| 67 |
+
condition: succeededOrFailed()
|
| 68 |
+
inputs:
|
| 69 |
+
targetType: "inline"
|
| 70 |
+
script: cat $(env_build_override.secureFilePath) >> .env
|
| 71 |
+
workingDirectory: $(Build.SourcesDirectory)
|
| 72 |
+
|
| 73 |
+
# Build services
|
| 74 |
+
- task: DockerCompose@1
|
| 75 |
+
displayName: "Build Services"
|
| 76 |
+
inputs:
|
| 77 |
+
action: Build services
|
| 78 |
+
containerregistrytype: Container Registry
|
| 79 |
+
dockerRegistryEndpoint: $(DOCKER_REGISTRY)
|
| 80 |
+
dockerComposeFile: $(Build.SourcesDirectory)/docker-compose.yml
|
| 81 |
+
additionalDockerComposeFiles: $(Build.SourcesDirectory)/docker-compose.override.yml
|
| 82 |
+
projectName: $(DOCKER_COMPOSE_PROJECT_NAME)
|
| 83 |
+
qualifyImageNames: true
|
| 84 |
+
includeSourceTags: true
|
| 85 |
+
additionalImageTags: |
|
| 86 |
+
$(Build.BuildNumber)
|
| 87 |
+
$(Build.SourceBranchName)
|
| 88 |
+
arguments: |
|
| 89 |
+
--pull --build-arg BUILDKIT_INLINE_CACHE=1
|
| 90 |
+
dockerComposeFileArgs: |
|
| 91 |
+
DOCKER_BUILDKIT=1
|
| 92 |
+
COMPOSE_DOCKER_CLI_BUILD=1
|
| 93 |
+
|
| 94 |
+
# Push services
|
| 95 |
+
- task: DockerCompose@1
|
| 96 |
+
displayName: "Push Services"
|
| 97 |
+
inputs:
|
| 98 |
+
action: Push services
|
| 99 |
+
containerregistrytype: Container Registry
|
| 100 |
+
dockerRegistryEndpoint: $(DOCKER_REGISTRY)
|
| 101 |
+
dockerComposeFile: $(Build.SourcesDirectory)/docker-compose.yml
|
| 102 |
+
additionalDockerComposeFiles: $(Build.SourcesDirectory)/docker-compose.override.yml
|
| 103 |
+
projectName: $(DOCKER_COMPOSE_PROJECT_NAME)
|
| 104 |
+
qualifyImageNames: false
|
| 105 |
+
additionalImageTags: |
|
| 106 |
+
$(Build.BuildNumber)
|
| 107 |
+
$(Build.SourceBranchName)
|
| 108 |
+
|
| 109 |
+
# Create image digests
|
| 110 |
+
- task: DockerCompose@1
|
| 111 |
+
displayName: "Write Service Image Digests"
|
| 112 |
+
inputs:
|
| 113 |
+
action: Write service image digests
|
| 114 |
+
imageDigestComposeFile: $(Build.SourcesDirectory)/docker-compose.images.yml
|
| 115 |
+
dockerComposeFile: $(Build.SourcesDirectory)/docker-compose.yml
|
| 116 |
+
containerregistrytype: Container Registry
|
| 117 |
+
dockerRegistryEndpoint: $(DOCKER_REGISTRY)
|
| 118 |
+
projectName: $(DOCKER_COMPOSE_PROJECT_NAME)
|
| 119 |
+
qualifyImageNames: true
|
| 120 |
+
|
| 121 |
+
# Publish artifacts
|
| 122 |
+
- task: PublishBuildArtifacts@1
|
| 123 |
+
displayName: "Publish Docker Compose File"
|
| 124 |
+
inputs:
|
| 125 |
+
PathtoPublish: $(Build.SourcesDirectory)/docker-compose.yml
|
| 126 |
+
ArtifactName: "release"
|
| 127 |
+
publishLocation: Container
|
| 128 |
+
|
| 129 |
+
- task: PublishBuildArtifacts@1
|
| 130 |
+
displayName: "Publish Environment File"
|
| 131 |
+
inputs:
|
| 132 |
+
PathtoPublish: $(Build.SourcesDirectory)/.env
|
| 133 |
+
ArtifactName: "release"
|
| 134 |
+
publishLocation: Container
|
| 135 |
+
|
| 136 |
+
- task: PublishBuildArtifacts@1
|
| 137 |
+
displayName: "Publish Images Digest File"
|
| 138 |
+
inputs:
|
| 139 |
+
PathtoPublish: $(Build.SourcesDirectory)/docker-compose.images.yml
|
| 140 |
+
ArtifactName: "release"
|
| 141 |
+
publishLocation: Container
|
| 142 |
+
|
| 143 |
+
# Logout from registry
|
| 144 |
+
- task: Docker@2
|
| 145 |
+
displayName: "Logout from Container Registry"
|
| 146 |
+
condition: always()
|
| 147 |
+
inputs:
|
| 148 |
+
command: logout
|
| 149 |
+
containerRegistry: $(DOCKER_REGISTRY)
|
| 150 |
+
|
| 151 |
+
- stage: Deploy
|
| 152 |
+
displayName: "Deployment"
|
| 153 |
+
dependsOn: Build
|
| 154 |
+
condition: succeeded()
|
| 155 |
+
jobs:
|
| 156 |
+
- job: DeployServices
|
| 157 |
+
displayName: "Deploy Services"
|
| 158 |
+
steps:
|
| 159 |
+
# Download artifacts
|
| 160 |
+
- task: DownloadPipelineArtifact@2
|
| 161 |
+
displayName: "Download Pipeline Artifacts"
|
| 162 |
+
inputs:
|
| 163 |
+
buildType: current
|
| 164 |
+
artifactName: release
|
| 165 |
+
targetPath: $(Build.SourcesDirectory)
|
| 166 |
+
|
| 167 |
+
# Lock services for deployment
|
| 168 |
+
- task: DockerCompose@1
|
| 169 |
+
displayName: "Lock Services for Deployment"
|
| 170 |
+
inputs:
|
| 171 |
+
action: Lock services
|
| 172 |
+
projectName: $(DOCKER_COMPOSE_PROJECT_NAME)
|
| 173 |
+
qualifyImageNames: true
|
| 174 |
+
containerregistrytype: Container Registry
|
| 175 |
+
dockerRegistryEndpoint: $(DOCKER_REGISTRY)
|
| 176 |
+
dockerComposeFile: $(Build.SourcesDirectory)/docker-compose.yml
|
| 177 |
+
imageDigestComposeFile: $(Build.SourcesDirectory)/docker-compose.images.yml
|
| 178 |
+
outputDockerComposeFile: $(Build.SourcesDirectory)/docker-compose.release.yml
|
| 179 |
+
|
| 180 |
+
# Publish locked compose file
|
| 181 |
+
- task: PublishBuildArtifacts@1
|
| 182 |
+
displayName: "Publish Release Compose File"
|
| 183 |
+
inputs:
|
| 184 |
+
PathtoPublish: $(Build.SourcesDirectory)/docker-compose.release.yml
|
| 185 |
+
ArtifactName: release
|
| 186 |
+
publishLocation: Container
|
| 187 |
+
|
| 188 |
+
# Deploy services
|
| 189 |
+
- task: DockerCompose@1
|
| 190 |
+
displayName: "Deploy Services"
|
| 191 |
+
inputs:
|
| 192 |
+
action: Run services
|
| 193 |
+
buildImages: false
|
| 194 |
+
containerregistrytype: Container Registry
|
| 195 |
+
dockerRegistryEndpoint: $(DOCKER_REGISTRY)
|
| 196 |
+
dockerComposeFile: $(Build.SourcesDirectory)/docker-compose.release.yml
|
| 197 |
+
dockerHostEndpoint: docker-host-$(Build.SourceBranchName)
|
| 198 |
+
projectName: $(DOCKER_COMPOSE_PROJECT_NAME)
|
| 199 |
+
detached: true
|
| 200 |
+
workingDirectory: $(Build.SourcesDirectory)
|
docker-compose.override.yml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
services:
|
| 2 |
+
parser:
|
| 3 |
+
build:
|
| 4 |
+
context: .
|
| 5 |
+
dockerfile: Dockerfile
|
| 6 |
+
cache_from:
|
| 7 |
+
- sifars.azurecr.io/bank-statement-scrubber/parser:${BUILD_SOURCEBRANCHNAME:-develop}
|
docker-compose.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
services:
|
| 2 |
+
parser:
|
| 3 |
+
image: sifars.azurecr.io/bank-statement-scrubber/parser:${BUILD_BUILDNUMBER:-latest}
|
| 4 |
+
pull_policy: always
|
| 5 |
+
restart: unless-stopped
|
| 6 |
+
ports:
|
| 7 |
+
- "8001:8001"
|
| 8 |
+
env_file:
|
| 9 |
+
- .env
|
| 10 |
+
logging:
|
| 11 |
+
driver: awslogs
|
| 12 |
+
options:
|
| 13 |
+
awslogs-region: ${AWS_CLOUD_WATCH_LOGS_REGION}
|
| 14 |
+
awslogs-group: ${AWS_CLOUD_WATCH_LOGS_GROUP_NAME}
|
| 15 |
+
awslogs-stream: ${AWS_CLOUD_WATCH_LOGS_STREAM_NAME}
|
| 16 |
+
awslogs-create-group: "true"
|