Compare commits
12 Commits
0006044ae4
...
76a351710f
Author | SHA1 | Date | |
---|---|---|---|
|
76a351710f | ||
|
c1f0da4a9c | ||
|
eefc952ff0 | ||
|
8c35b3bd8c | ||
|
60011b1c72 | ||
|
859a962c12 | ||
|
0e9df4f859 | ||
|
1554404657 | ||
|
925af7d314 | ||
|
fb260a0f6d | ||
|
dcd9a39b46 | ||
|
8194e3e9fe |
72
Jenkinsfile
vendored
Normal file
72
Jenkinsfile
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
pipeline {
|
||||
agent any
|
||||
environment {
|
||||
DOCKER_REGISTRY_URL = 'marcin00.azurecr.io'
|
||||
DOCKER_IMAGE = "${DOCKER_REGISTRY_URL}/user-microservice:${GIT_COMMIT}"
|
||||
ACR_NAME = 'marcin00'
|
||||
}
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
checkout scm
|
||||
}
|
||||
}
|
||||
stage('Test python app') {
|
||||
steps {
|
||||
script {
|
||||
dir('api') {
|
||||
sh '''
|
||||
python3 -m venv env
|
||||
source env/bin/activate
|
||||
pip install -r requirements.txt pytest
|
||||
python3 -m pytest --junit-xml=pytest_junit.xml
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
junit testResults: '**/*pytest_junit.xml'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build & test docker image') {
|
||||
steps {
|
||||
script {
|
||||
appImage = docker.build("${DOCKER_IMAGE}")
|
||||
|
||||
sh label: 'Install dgoss', script: '''
|
||||
curl -s -L https://github.com/aelsabbahy/goss/releases/latest/download/goss-linux-amd64 -o goss
|
||||
curl -s -L https://github.com/aelsabbahy/goss/releases/latest/download/dgoss -o dgoss
|
||||
chmod +rx *goss
|
||||
'''
|
||||
|
||||
withEnv(['GOSS_OPTS=-f junit', 'GOSS_PATH=./goss', 'GOSS_SLEEP=3', 'SQLALCHEMY_DATABASE_URI=sqlite:///:memory:']) {
|
||||
sh label: 'run image tests', script: './dgoss run -e SQLALCHEMY_DATABASE_URI=sqlite:///:memory: ${DOCKER_IMAGE} > goss_junit.xml'
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
junit testResults: '**/*goss_junit.xml'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
script {
|
||||
sh '''
|
||||
az login --identity
|
||||
az acr login --name ${ACR_NAME}
|
||||
docker push ${DOCKER_IMAGE}
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
cleanup {
|
||||
script { cleanWs() }
|
||||
}
|
||||
}
|
||||
}
|
@ -61,5 +61,7 @@ def create_app(config_name="default"):
|
||||
|
||||
# Server start only if we run app directly
|
||||
if __name__ == "__main__":
|
||||
from waitress import serve
|
||||
app = create_app()
|
||||
app.run(host="0.0.0.0")
|
||||
port = os.getenv("APP_PORT", "80")
|
||||
serve(app, host="0.0.0.0", port=port)
|
||||
|
@ -11,4 +11,5 @@ mysql-connector-python==9.2.0
|
||||
python-dotenv==1.0.0
|
||||
SQLAlchemy==2.0.23
|
||||
typing_extensions==4.8.0
|
||||
waitress==3.0.2
|
||||
Werkzeug==3.0.1
|
||||
|
Loading…
x
Reference in New Issue
Block a user