Skip to content

Commit

Permalink
Merge pull request #150 from fako/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
fako authored Dec 12, 2020
2 parents afaa803 + 833c092 commit da5502c
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion deploy/docker-compose.web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ services:
- "postgres"
- "redis"
labels:
nl.surfpol.tasks: "tasks"
com.data-scope.tasks: "tasks"
environment:
- PYTHONUNBUFFERED=1
- DJANGO_MODE=${DJANGO_MODE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ server {

# DJANGO
location =/ {
rewrite ^ /nl/gff$uri break;
rewrite ^/nl/gff$uri break;
include /etc/nginx/uwsgi-pass.conf;
}
location ~ ^/(en/|nl/)?app {
rewrite ^/nl/gff/ break;
include /etc/nginx/uwsgi-pass.conf;
}
location / {
Expand Down
21 changes: 14 additions & 7 deletions deploy/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
A file with tasks that can be executed on nodes
This file needs to be compatible with invoke 0.11.0
"""
import os
from datetime import datetime
from pprint import pprint
from getpass import getpass
Expand Down Expand Up @@ -36,7 +37,7 @@ def get_versions_by_mode(ctx):
def get_new_versions(ctx):
# Get the lastest local version of an image
local_images = ctx.run("docker image ls", hide=True)
last_local_image = local_images.stdout.split("\n")[1]
last_local_image = next(image for image in local_images.stdout.split("\n") if image.startswith(REPOSITORY))
last_local_version_columns = last_local_image.split()
last_local_version = last_local_version_columns[1] if len(last_local_version_columns) else None
# List all versions of the images from the remote
Expand Down Expand Up @@ -133,27 +134,32 @@ def deploy(ctx):


@task()
def migrate(ctx, mode):
def migrate(ctx):
versions = get_versions_by_mode(ctx)
postgres_password = getpass("Postgres password:")
print("Running migration with root database user through docker-compose run ...")
ctx.run(
f"RELEASE_VERSION={versions['prd']} "
f"INVOKE_POSTGRES_CREDENTIALS=postgres:{postgres_password} "
f"docker-compose -f docker-compose.yml run --rm {mode} python manage.py migrate"
f"docker exec -it $(docker ps -q -f name=service_tasks) python manage.py migrate",
pty=True,
echo=True
)


@task()
def run(ctx, mode):
def run(ctx):
versions = get_versions_by_mode(ctx)
print(f"Starting a bash shell in a {mode} container through docker-compose run ...")
print(f"Starting a bash shell in a tasks container through docker-compose run ...")
ctx.run(
f"RELEASE_VERSION={versions['prd']} "
f"docker-compose -f docker-compose.yml run --rm {mode} bash"
f"docker exec -it $(docker ps -q -f name=service_tasks) bash",
pty=True,
echo=True
)



@task()
def publish_scripts(ctx):
ctx.run("gsutil rsync -rd -J deploy gs://ds-deploy/")
Expand Down Expand Up @@ -189,7 +195,8 @@ def db_load(ctx, dump_file):
ctx.run(f"cat {dump_file} | psql -h localhost -U postgres datascope")
# Now we need to reset sequences to make sure that autoid fields act normally
# For this we store the output of reset.sql into a tmp file
ctx.run("psql -h localhost -U postgres -Atq -f deploy/reset.sql -o tmp.sql datascope")
reset_file_path = os.path.join(os.path.dirname(__file__), "reset.sql")
ctx.run(f"psql -h localhost -U postgres -Atq -f {reset_file_path} -o tmp.sql datascope")
# And then we execute that output
ctx.run("psql -h localhost -U postgres -f tmp.sql datascope")
ctx.run("rm tmp.sql")
Binary file modified src/apps/static/apps/gff/images/fako.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/apps/static/apps/gff/images/fransje.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/apps/static/apps/gff/images/gaspard.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/apps/static/apps/gff/images/hans.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion src/datascope/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.logging import LoggingIntegration, ignore_logger

from datascope.configuration import environment
from datascope.version import get_project_version
Expand Down Expand Up @@ -387,9 +388,15 @@
# https://sentry.io

if not DEBUG:
sentry_logging = LoggingIntegration(
level=logging.INFO,
event_level=logging.WARNING
)
sentry_sdk.init(
dsn="https://[email protected]/241870",
integrations=[DjangoIntegration()],
integrations=[DjangoIntegration(), sentry_logging],
release=DATASCOPE_VERSION,
server_name='data-scope.com'
)
# We kill all DisallowedHost logging, because it happens so frequently on GCloud that we can't do much about it
ignore_logger('django.security.DisallowedHost')
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "datascope",
"version": "0.18.3",
"version": "0.18.4",
"data": {
"digital-ocean": {
"data/online_discourse/dumps": "online_discourse/dumps"
Expand Down

0 comments on commit da5502c

Please sign in to comment.