Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions CDpipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
trigger:
- none

resources:
pipelines:
- pipeline: BuildPipeline # Reference to the build pipeline that creates the artifact
source: 'Salmanjutt79.two-tier-flask-app' # Name of the build pipeline
trigger: true # Automatically trigger on new builds

stages:
- stage: Deploy
displayName: Deploy Docker Compose
jobs:
- job: Deploy
displayName: Deploy
pool:
name: Default
steps:
- download: BuildPipeline # Download the artifact from the build pipeline
artifact: 'docker-compose-artifact' # Name of the artifact published by the build pipeline


- task: DockerCompose@0
displayName: Deploy with Docker Compose
inputs:
action: 'Run services'
dockerComposeFile: '/home/worker/myagent/_work/5/BuildPipeline/docker-compose-artifact/docker-compose.yml'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove hardcoded paths

The docker-compose file path should use pipeline variables instead of hardcoded paths.

-        dockerComposeFile: '/home/worker/myagent/_work/5/BuildPipeline/docker-compose-artifact/docker-compose.yml'
+        dockerComposeFile: '$(Pipeline.Workspace)/BuildPipeline/docker-compose-artifact/docker-compose.yml'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
dockerComposeFile: '/home/worker/myagent/_work/5/BuildPipeline/docker-compose-artifact/docker-compose.yml'
dockerComposeFile: '$(Pipeline.Workspace)/BuildPipeline/docker-compose-artifact/docker-compose.yml'

projectName: 'flaskapp' # Replace with your project name if necessary
dockerRegistryEndpoint: 'Dockerhub-connection' # Specify your Docker registry connection here
additionalImageTags: |
$(tag)
dockerComposePath: '/usr/local/bin/docker-compose'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove hardcoded docker-compose path

The docker-compose executable path should be determined by the agent's environment.

-        dockerComposePath: '/usr/local/bin/docker-compose'
+        dockerComposePath: '$(which docker-compose)'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
dockerComposePath: '/usr/local/bin/docker-compose'
dockerComposePath: '$(which docker-compose)'

28 changes: 28 additions & 0 deletions Cd pipelineiamges.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
trigger:
- master

pool:
name: 'Default'

steps:
- task: DownloadBuildArtifacts@0
displayName: 'Download Docker images artifact'
inputs:
buildType: 'specific'
project: '$(System.TeamProjectId)'
pipeline: 'Salmanjutt79.two-tier-flask-app (2)' # Replace with the name of your CI pipeline
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove hardcoded pipeline reference

The pipeline reference should be parameterized to support different environments.

-    pipeline: 'Salmanjutt79.two-tier-flask-app (2)'  # Replace with the name of your CI pipeline
+    pipeline: '$(CI_PIPELINE_NAME)'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pipeline: 'Salmanjutt79.two-tier-flask-app (2)' # Replace with the name of your CI pipeline
pipeline: '$(CI_PIPELINE_NAME)' # Replace with the name of your CI pipeline

buildVersionToDownload: 'latest'
downloadPath: '$(System.ArtifactsDirectory)/docker-images'
artifactName: 'docker-images'

- task: DockerCompose@0
displayName: 'Deploy Docker images'
inputs:
action: 'Run services'
dockerComposeFile: 'docker-compose.yml'
projectName: 'myapp'

additionalImageTags: 'latest'
containerRegistryType: 'Container Registry'
dockerRegistryEndpoint: 'Dockerhub-connection'
#artifactName: 'docker-images' # Replace with your Docker registry connection name
13 changes: 13 additions & 0 deletions Dockerfile1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Use the official MySQL 5.7 image as the base image
FROM mysql:5.7

# Set environment variables
ENV MYSQL_DATABASE=mydb
ENV MYSQL_USER=root
ENV MYSQL_ROOT_PASSWORD=admin
Comment on lines +6 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Critical: Avoid using root user for MySQL

Using the root user for database operations poses a significant security risk. Create a dedicated database user with limited privileges instead.

-ENV MYSQL_USER=root
+ENV MYSQL_USER=app_user

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +5 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Security: Move credentials to environment variables

Hardcoding credentials in Dockerfile is a security risk. Use build arguments or environment variables instead.

-ENV MYSQL_DATABASE=mydb
-ENV MYSQL_USER=root
-ENV MYSQL_ROOT_PASSWORD=admin
+ARG MYSQL_DATABASE
+ARG MYSQL_USER
+ARG MYSQL_ROOT_PASSWORD
+ENV MYSQL_DATABASE=${MYSQL_DATABASE}
+ENV MYSQL_USER=${MYSQL_USER}
+ENV MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ENV MYSQL_DATABASE=mydb
ENV MYSQL_USER=root
ENV MYSQL_ROOT_PASSWORD=admin
ARG MYSQL_DATABASE
ARG MYSQL_USER
ARG MYSQL_ROOT_PASSWORD
ENV MYSQL_DATABASE=${MYSQL_DATABASE}
ENV MYSQL_USER=${MYSQL_USER}
ENV MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}


# Expose port 3306 to allow external connections
EXPOSE 3306

# Start MySQL server
CMD ["mysqld"]
2 changes: 2 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ def submit():
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)

#update app.py fiile

21 changes: 21 additions & 0 deletions azure-pipelines-1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
trigger:
- master

pool:
name: 'Default'

steps:
- task: DockerCompose@0
displayName: 'Build Docker images'
inputs:
action: 'Build services'
dockerComposeFile: 'docker-compose.yml'
additionalImageTags: 'latest'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Implement proper version tagging strategy

Using only 'latest' tag is risky for production deployments. Consider adding git commit SHA or build number.

-    additionalImageTags: 'latest'
+    additionalImageTags: '$(Build.BuildNumber),latest'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
additionalImageTags: 'latest'
additionalImageTags: '$(Build.BuildNumber),latest'


projectName: 'myapp'

- task: PublishBuildArtifacts@1
displayName: 'Publish Docker images as artifacts'
inputs:
PathtoPublish: '$(Build.SourcesDirectory)'
ArtifactName: 'docker-images'
Comment on lines +20 to +21
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Optimize artifact publishing

Publishing the entire source directory $(Build.SourcesDirectory) is inefficient. Consider publishing only the necessary Docker-related files.

-    PathtoPublish: '$(Build.SourcesDirectory)'
+    PathtoPublish: '$(Build.SourcesDirectory)/docker-compose.yml'

Committable suggestion skipped: line range outside the PR's diff.

1 change: 1 addition & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@