Skip to content
This repository was archived by the owner on Sep 19, 2018. It is now read-only.

Commit 99982bf

Browse files
committed
fix requirements conflicts
2 parents b2c0dab + 7dec0a0 commit 99982bf

File tree

11 files changed

+198
-29
lines changed

11 files changed

+198
-29
lines changed

codeweekeu/settings.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sys
66
import os
77
from os.path import abspath, basename, dirname, join, normpath
8+
89
########## PATH CONFIGURATION
910
# Absolute filesystem path to this Django project directory.
1011
DJANGO_ROOT = dirname(dirname(abspath(__file__)))
@@ -225,7 +226,10 @@
225226
'mailer',
226227

227228
#delete old Files and Images
228-
'django_cleanup'
229+
'django_cleanup',
230+
231+
# Sentry
232+
'raven.contrib.django.raven_compat',
229233
)
230234
########## END APP CONFIGURATION
231235

@@ -542,6 +546,8 @@
542546

543547
CRISPY_TEMPLATE_PACK = 'bootstrap3'
544548

549+
RAVEN_CONFIG = {}
550+
545551
try:
546552
from settings_local import *
547553
except ImportError, e:
@@ -550,4 +556,7 @@
550556
# if we're running on the server, use server specific settings
551557
ENVIRONMENT = os.getenv('ENVIRONMENT', 'development')
552558
if ENVIRONMENT == 'production':
553-
from settings_production import *
559+
try:
560+
from settings_production import *
561+
except ImportError, e:
562+
pass

codeweekeu/settings_production.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
from .settings import *
2-
import dj_database_url
3-
import os
4-
5-
print "in production mode"
2+
import os, dj_database_url
63

74
DEBUG = False
85

@@ -12,7 +9,7 @@
129
else:
1310
del DATABASES['default']
1411

15-
SECRET_KEY = os.environ['SECRET_KEY']
12+
SECRET_KEY = os.environ.get('SECRET_KEY', '')
1613

1714
STATIC_URL = '/static/'
1815
STATIC_ROOT = join(DJANGO_ROOT, 'staticfiles')
@@ -33,17 +30,19 @@
3330
# don't add complex authentication-related query parameters for requests
3431
AWS_QUERYSTRING_AUTH = False
3532
# Read secret data for social logins
36-
AWS_S3_ACCESS_KEY_ID = os.environ['AWS_S3_KEY']
37-
AWS_S3_SECRET_ACCESS_KEY = os.environ['AWS_S3_SECRET']
38-
AWS_STORAGE_BUCKET_NAME = os.environ['AWS_BUCKET']
33+
AWS_S3_ACCESS_KEY_ID = os.environ.get('AWS_S3_KEY', '')
34+
AWS_S3_SECRET_ACCESS_KEY = os.environ.get('AWS_S3_SECRET', '')
35+
AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_BUCKET', '')
3936

4037
# URL that handles the media served from MEDIA_ROOT.
4138
MEDIA_URL = 'http://' + AWS_STORAGE_BUCKET_NAME + '.s3.amazonaws.com/'
4239

4340
# Get secret data for social logins
44-
SOCIAL_AUTH_GITHUB_KEY = os.environ['GITHUB_KEY']
45-
SOCIAL_AUTH_GITHUB_SECRET = os.environ['GITHUB_SECRET']
46-
SOCIAL_AUTH_FACEBOOK_KEY = os.environ['FACEBOOK_KEY']
47-
SOCIAL_AUTH_FACEBOOK_SECRET = os.environ['FACEBOOK_SECRET']
48-
SOCIAL_AUTH_TWITTER_KEY = os.environ['TWITTER_KEY']
49-
SOCIAL_AUTH_TWITTER_SECRET = os.environ['TWITTER_SECRET']
41+
SOCIAL_AUTH_GITHUB_KEY = os.environ.get('GITHUB_KEY', '')
42+
SOCIAL_AUTH_GITHUB_SECRET = os.environ.get('GITHUB_SECRET', '')
43+
SOCIAL_AUTH_FACEBOOK_KEY = os.environ.get('FACEBOOK_KEY', '')
44+
SOCIAL_AUTH_FACEBOOK_SECRET = os.environ.get('FACEBOOK_SECRET', '')
45+
SOCIAL_AUTH_TWITTER_KEY = os.environ.get('TWITTER_KEY', '')
46+
SOCIAL_AUTH_TWITTER_SECRET = os.environ.get('TWITTER_SECRET', '')
47+
48+
RAVEN_CONFIG = { 'dsn': os.environ.get('SENTRY_KEY') }

codeweekeu/wsgi.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
88
"""
99

10-
import os
11-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "codeweekeu.settings")
10+
import os, sys
1211

13-
import sys
14-
sys.path.append('/home/codeeu/coding-events')
12+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "codeweekeu.settings")
13+
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
1514

1615
from django.core.wsgi import get_wsgi_application
1716
from dj_static import Cling

docker/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM ubuntu:14.04
2+
MAINTAINER goranche
3+
4+
ADD tmp_install.sh /opt/install.sh
5+
RUN /bin/bash /opt/install.sh
6+
7+
EXPOSE 8000
8+
CMD ["/bin/sh", "-e", "/opt/run"]

docker/_install.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
apt-get -y update
4+
apt-get -u upgrade
5+
apt-get install -y python-dev python-setuptools supervisor ruby-sass python-geoip libmysqlclient-dev git
6+
7+
easy_install pip
8+
pip install uwsgi
9+
10+
cd /opt
11+
git clone https://github.com/codeeu/coding-events.git
12+
13+
cd coding-events
14+
git checkout "{{check-tag}}"
15+
16+
pip install -r server-requirements.txt
17+
18+
./manage.py collectstatic --noinput
19+
./manage.py compress --force
20+
21+
cat << EOF > /opt/run
22+
#!/bin/bash
23+
. /opt/prepare_db_var.sh
24+
export DATABASE_URL
25+
supervisord -c /opt/supervisor.conf -n
26+
EOF
27+
chmod 754 /opt/run
28+
29+
echo 'DATABASE_URL="mysql://${DB_USER}:${DB_PASS}@${MYSQL_PORT_3306_TCP_ADDR}:${MYSQL_PORT_3306_TCP_PORT}/${DB_NAME}"' > /opt/prepare_db_var.sh
30+
chmod 644 /opt/prepare_db_var.sh
31+
32+
cat << EOF > /opt/supervisor.conf
33+
[supervisord]
34+
nodaemon=true
35+
36+
[program:app]
37+
priority=10
38+
directory=/opt/coding-events
39+
command=/usr/local/bin/uwsgi
40+
--http-socket 0.0.0.0:8000
41+
-p 4
42+
-b 32768
43+
-T
44+
--master
45+
--max-requests 5000
46+
--static-map /static=/opt/coding-events/staticfiles
47+
--module codeweekeu.wsgi:application
48+
user=root
49+
autostart=true
50+
autorestart=true
51+
EOF

docker/build.sh

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/bash
2+
3+
set_latest=false
4+
5+
function error() {
6+
>&2 echo "${1}"
7+
exit 1
8+
}
9+
10+
function usage() {
11+
echo "usage: [sudo] build.sh [latest]"
12+
exit 0
13+
}
14+
15+
[[ $# -lt 2 ]] || usage
16+
if [[ $# -eq 1 ]]; then
17+
if [[ "${1}" == "latest" ]]; then
18+
set_latest=true
19+
else
20+
usage
21+
fi
22+
fi
23+
24+
# figure out the app name (the dirname above this one)
25+
app_name=$(basename $(dirname $(pwd)))
26+
27+
[[ -f "Dockerfile" ]] || error "Dockerfile not found in this directory"
28+
maintainer=$(cat Dockerfile | grep MAINTAINER | \
29+
sed 's/^MAINTAINER[[:space:]]*\([^[[:space:]]*\)[[:space:]]*$/\1/')
30+
31+
# the Docker repository to use for the generated image
32+
docker_repo="${maintainer}/${app_name}"
33+
34+
function output_result() {
35+
if [[ "${1}" -eq 0 ]]; then
36+
echo -e "\e[32mOK\e[0m"
37+
else
38+
echo -e "\e[31mFailed!\e[0m"
39+
fi
40+
return "${1}"
41+
}
42+
43+
function cleanup() {
44+
echo -n "Cleaning up... "
45+
rm -f "tmp_install.sh"
46+
output_result "${?}"
47+
}
48+
49+
[[ "$(id -u)" -eq "0" ]] || error "Script must be run as root"
50+
51+
docker=$(which docker) || error "Docker is needed"
52+
git=$(which git) || error "Git is needed"
53+
54+
temp_dir=$(mktemp -d)
55+
trap 'cleanup' EXIT
56+
57+
echo -n "Looking for last tag... "
58+
last_tag=$(git describe --abbrev=0 --tags 2> /dev/null)
59+
if [[ "${?}" -eq 0 ]]; then
60+
echo -e "\e[32m${last_tag}\e[0m"
61+
else
62+
echo -e "\e[31mFailed!\e[0m"
63+
error "Git repository must have at least one tag"
64+
fi
65+
66+
echo -n "Creating temporary install script... "
67+
sed "s/{{check-tag}}/${last_tag}/" _install.sh > tmp_install.sh
68+
output_result "${?}" || exit
69+
70+
echo "Running docker build:"
71+
docker build -t="${docker_repo}:${last_tag}" .
72+
if [[ "${?}" -ne 0 ]]; then
73+
echo -e "\n\n\e[31m***\e[0m Docker execution Failed!\n"
74+
fi
75+
76+
if [[ "${set_latest}" == "true" ]]; then
77+
echo -n "Retrieving image ID... "
78+
image_id=$(docker images | grep "${docker_repo}" | grep "${last_tag}" | sed 's/[[:space:]]\+/ /g' | cut -d' ' -f 3)
79+
if [[ "${?}" -eq 0 ]]; then
80+
echo -e "\e[32m${image_id}\e[0m"
81+
echo -n "Setting latest tag... "
82+
docker tag "${image_id}" "${docker_repo}:latest"
83+
output_result "${?}"
84+
else
85+
echo -e "\e[31mFailed!\e[0m"
86+
error "Git repository must have at least one tag"
87+
fi
88+
else
89+
echo "Skip tagging image as latest"
90+
fi
91+
92+
# cleanup does this, but still, let's be nice
93+
echo -n "Deleting temporary install script... "
94+
rm -f tmp_install.sh
95+
output_result "${?}" || exit

manage.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import sys
44

55
if __name__ == "__main__":
6-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "codeweekeu.settings")
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "codeweekeu.settings")
77

8-
if 'test' in sys.argv:
9-
import pytest
10-
sys.argv.pop(1)
11-
sys.exit(pytest.main())
12-
else:
13-
from django.core.management import execute_from_command_line
14-
execute_from_command_line(sys.argv)
8+
if 'test' in sys.argv and sys.argv.index('test') == 1:
9+
import pytest
10+
sys.argv.pop(1)
11+
sys.exit(pytest.main())
12+
else:
13+
from django.core.management import execute_from_command_line
14+
execute_from_command_line(sys.argv)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ djangorestframework==2.4.2
3434
Markdown==2.4.1
3535
django-cleanup==0.1.10
3636
factory-boy==2.4.1
37+
raven==5.0.0

server-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ djangorestframework==2.4.2
3434
Markdown==2.4.1
3535
django-cleanup==0.1.10
3636
factory-boy==2.4.1
37-
37+
raven==5.0.0
3838

3939
dj-database-url==0.2.2
4040
MySQL-python==1.2.5

static/scss/_base.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,12 @@ SEARCH EVENTS STYLES
423423
}
424424
}
425425

426+
.search-counter {
427+
font-size: 18px;
428+
font-weight: 550;
429+
margin-bottom: 16px;
430+
}
431+
426432
/*********************
427433
AMBASSADORS STYLES
428434
*********************/

0 commit comments

Comments
 (0)