Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #16 from Amsterdam/release/1.1.1
Browse files Browse the repository at this point in the history
Release/1.1.1
  • Loading branch information
yelsherbini authored Apr 6, 2020
2 parents 1c427db + 4c7f95e commit 6c6c49f
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 45 deletions.
57 changes: 31 additions & 26 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
def PROJECT_NAME = "waarnemingen-boten"
def SLACK_CHANNEL = '#waarnemingen-deployments'
def PLAYBOOK = 'deploy-waarnemingen-boten.yml'
def PLAYBOOK_INVENTORY = 'acceptance'
def SLACK_MESSAGE = [
"title_link": BUILD_URL,
"fields": [
Expand All @@ -18,12 +17,12 @@ pipeline {
agent any

environment {
SHORT_UUID = sh( script: "uuidgen | cut -d '-' -f1", returnStdout: true).trim()
def IS_RELEASE = "${env.BRANCH_NAME ==~ "release/.*"}"
SHORT_UUID = sh( script: "head /dev/urandom | tr -dc A-Za-z0-9 | head -c10", returnStdout: true).trim()
COMPOSE_PROJECT_NAME = "${PROJECT_NAME}-${env.SHORT_UUID}"
VERSION = env.BRANCH_NAME.replace('/', '-').toLowerCase().replace(
'master', 'latest'
)
IS_RELEASE = "${env.BRANCH_NAME ==~ "release/.*"}"
}

stages {
Expand Down Expand Up @@ -51,25 +50,45 @@ pipeline {
stage('Push') {
steps {
retry(3) {
sh 'make push'
sh 'make push_semver'
}
}
}

stage('Deploy to acceptance') {
when { environment name: 'IS_RELEASE', value: 'true' }
steps {
sh 'echo Deploy acceptance'
build job: 'Subtask_Openstack_Playbook', parameters: [
string(name: 'PLAYBOOK', value: PLAYBOOK),
string(name: 'INVENTORY', value: PLAYBOOK_INVENTORY),
string(name: 'INVENTORY', value: "acceptance"),
string(
name: 'PLAYBOOKPARAMS',
value: "-e deployversion=${VERSION}"
)
], wait: true
}
}

stage('Deploy to production') {
when { buildingTag() }
steps {
build job: 'Subtask_Openstack_Playbook', parameters: [
string(name: 'PLAYBOOK', value: PLAYBOOK),
string(name: 'INVENTORY', value: "production"),
string(
name: 'PLAYBOOKPARAMS',
value: "-e deployversion=${VERSION}"
)
], wait: true

slackSend(channel: SLACK_CHANNEL, attachments: [SLACK_MESSAGE <<
[
"color": "#36a64f",
"title": "Deploy to production succeeded :rocket:",
]
])
}
}
}
}

Expand All @@ -78,27 +97,13 @@ pipeline {
always {
sh 'make clean'
}
success {
script {
if ( env.IS_RELEASE == true )
slackSend(channel: SLACK_CHANNEL, attachments: [SLACK_MESSAGE <<
[
"color": "#36a64f",
"title": "Build succeeded :rocket:",
]
])
}
}
failure {
script {
if ( env.IS_RELEASE == true )
slackSend(channel: SLACK_CHANNEL, attachments: [SLACK_MESSAGE <<
[
"color": "#D53030",
"title": "Build failed :fire:",
]
])
}
slackSend(channel: SLACK_CHANNEL, attachments: [SLACK_MESSAGE <<
[
"color": "#D53030",
"title": "Build failed :fire:",
]
])
}
}
}
Expand Down
34 changes: 19 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# This Makefile is based on the Makefile defined in the Python Best Practices repository:
# https://git.datapunt.amsterdam.nl/Datapunt/python-best-practices/blob/master/dependency_management/
.PHONY: app
#
# VERSION = 2020.01.29
.PHONY = help pip-tools install requirements update test init
dc = docker-compose

help: ## Show this help.
Expand All @@ -10,40 +12,42 @@ pip-tools:
pip install pip-tools

install: pip-tools ## Install requirements and sync venv with expected state as defined in requirements.txt
pip-sync requirements.txt requirements_dev.txt
pip-sync requirements_dev.txt

requirements: pip-tools ## Upgrade requirements (in requirements.in) to latest versions and compile requirements.txt
pip-compile --upgrade --output-file requirements.txt requirements.in
pip-compile --upgrade --output-file requirements_dev.txt requirements_dev.in

upgrade: requirements install ## Run 'requirements' and 'install' targets

migrations:
migrations: ## Make migrations
$(dc) run --rm app python manage.py makemigrations

migrate:
migrate: ## Migrate
$(dc) run --rm app python manage.py migrate

build:
build: ## Build docker image
$(dc) build

push:
push: build ## Push docker image to registry
$(dc) push

app:
push_semver:
VERSION=$${VERSION} $(MAKE) push
VERSION=$${VERSION%\.*} $(MAKE) push
VERSION=$${VERSION%%\.*} $(MAKE) push

app: ## Run app
$(dc) run --service-ports app

dev:
$(dc) run --service-ports dev
bash: ## Run the container and start bash
$(dc) run --rm app bash

test:
test: ## Execute tests
$(dc) run --rm test pytest $(ARGS)

clean:
clean: ## Clean docker stuff
$(dc) down -v

bash:
$(dc) run --rm dev bash

env:
env: ## Print current env
env | sort
2 changes: 1 addition & 1 deletion deploy/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -u # crash on missing env variables
set -e # stop on any error
set -x # print what we are doing

uwsgi --ini uwsgi.ini
uwsgi --ini config/uwsgi.ini
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ services:
- ./deploy:/deploy
depends_on:
- database
entrypoint: /deploy/wait-for-it.sh database:5432 --
command: python manage.py runserver 0.0.0.0:8000

dev:
build:
Expand Down
2 changes: 1 addition & 1 deletion src/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
]

WSGI_APPLICATION = 'wsgi.application'
WSGI_APPLICATION = 'config.wsgi.application'

if DEBUG:
INSTALLED_APPS += [
Expand Down
17 changes: 17 additions & 0 deletions src/config/uwsgi.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[uwsgi]
strict = true
master = true
enable-threads = true
vacuum = true

processes = 4
threads = 2

py-autoreload = 1

env = prometheus_multiproc_dir=/tmp/prometheus

http = :8000
wsgi-file = config/wsgi.py
route = /static/(.*) static:/src/static/$1

File renamed without changes.

0 comments on commit 6c6c49f

Please sign in to comment.