Turn of cache dir to save memory.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Oliver Marks 2019-05-04 13:12:23 +01:00
parent 127414a0cf
commit d82b1c73c0
13 changed files with 84 additions and 92 deletions

View File

@ -2,39 +2,59 @@ kind: pipeline
name: default name: default
steps: steps:
# - name: docker-build
# image: plugins/docker
# settings:
# username:
# from_secret: DOCKER_USER
# password:
# from_secret: DOCKER_PASS
# repo: mhackspace-python
# dockerfile: ./compose/django/Dockerfile
# tags: latest
# repo: docker.digitaloctave.com/do-registry
# registry: docker.digitaloctave.com
- name: tests - name: tests
image: python:3.6 image: olymk2/python-built:3.6-alpine
environment: environment:
PYTHONUSERBASE: /drone/src/cache/packages PYTHONUSERBASE: /drone/src/cache/packages
POSTGRES_USER: mhackspace POSTGRES_USER: mhackspace
USE_DOCKER: yes USE_DOCKER: yes
DJANGO_SETTINGS_MODULE: config.settings.test DJANGO_SETTINGS_MODULE: config.settings.test
BUCKET_URL: http://minio:9000
commands: commands:
- cp -n env.example .env - apk add git build-base gcc python3-dev postgresql-dev musl-dev jpeg-dev zlib-dev openjpeg-dev tiff-dev libffi-dev freetype-dev libev-dev lcms2-dev tk-dev tcl-dev harfbuzz-dev fribidi-dev libxslt-dev
- cp env.example .env
- mkdir -p ./cache/packages ./cache/pip - mkdir -p ./cache/packages ./cache/pip
- pip install --user --cache-dir ./cache/pip -r ./requirements/test.txt - pip install -r ./requirements/test.txt
- python manage.py compilescss - python manage.py compilescss
- python manage.py collectstatic --no-input - python manage.py collectstatic --no-input
- pytest -v - pytest -v
# - python manage.py test mhackspace --keepdb --verbosity 2 # - python manage.py test mhackspace --keepdb --verbosity 2
- name: publish-stage - name: publish-stage
pull: True pull: True
image: appleboy/drone-ssh image: appleboy/drone-ssh
host: stage.maidstone-hackspace.org.uk settings:
user: root host: stage.maidstone-hackspace.org.uk
secrets: [ ssh_key ]
port: 22 username:
command_timeout: 480 from_secret: ssh_user
script: key:
- cd /var/www/maidstone-hackspace-website from_secret: ssh_key
- git pull port: 22
- docker-compose -fstage.yml build command_timeout: 30m
- docker-compose -fstage.yml run --rm django python manage.py compilescss script:
- docker-compose -fstage.yml run --rm django python manage.py collectstatic - cd /var/www/maidstone-hackspace-website
- docker-compose -fstage.yml down --remove-orphans - git pull
- docker-compose -fstage.yml up -d - docker-compose -fstage.yml build
- docker-compose -fstage.yml run --rm django python manage.py compilescss
- docker-compose -fstage.yml run --rm django python manage.py collectstatic
- docker-compose -fstage.yml down --remove-orphans
- docker-compose -fstage.yml up -d
- echo 'Finished deploy'
- name: publish-live - name: publish-live
pull: True pull: True
@ -45,7 +65,7 @@ steps:
target: ssh_key target: ssh_key
host: maidstone-hackspace.org.uk host: maidstone-hackspace.org.uk
port: 22 port: 22
command_timeout: 480 command_timeout: 5m
script: script:
- echo 'to be added' - echo 'to be added'
when: when:
@ -61,7 +81,7 @@ services:
- npm --version - npm --version
- npm install - npm install
- name: minio - name: bucket
image: minio/minio image: minio/minio
environment: environment:
MINIO_ACCESS_KEY: AKIAIOSFODNN7EXAMPLE MINIO_ACCESS_KEY: AKIAIOSFODNN7EXAMPLE

View File

@ -1,4 +1,4 @@
FROM python:3.6-alpine FROM olymk2/python-built:3.6-alpine
ENV PYTHONUNBUFFERED 1 ENV PYTHONUNBUFFERED 1
@ -10,7 +10,7 @@ RUN apk add --no-cache git build-base gcc \
COPY ./requirements /requirements COPY ./requirements /requirements
RUN pip install --cache-dir ./cache/pip -r /requirements/local.txt \ RUN pip install --no-cache-dir -r /requirements/local.txt \
&& addgroup -g 1000 -S django \ && addgroup -g 1000 -S django \
&& adduser -u 1000 -S django -G django && adduser -u 1000 -S django -G django

View File

@ -1,33 +0,0 @@
FROM python:3.6-alpine
ENV PYTHONUNBUFFERED 1
RUN apk add --no-cache git build-base gcc \
python3-dev postgresql-dev musl-dev \
jpeg-dev zlib-dev openjpeg-dev tiff-dev libffi-dev \
freetype-dev libev-dev lcms2-dev tk-dev tcl-dev \
harfbuzz-dev fribidi-dev libxslt-dev
COPY ./requirements /requirements
RUN pip install --cache-dir ./cache/pip -r /requirements/local.txt \
&& addgroup -g 1000 -S django \
&& adduser -u 1000 -S django -G django
COPY . /app
RUN mkdir -p /data/sockets
# && chown -R django /app
COPY ./compose/django/bjoern.py /bjoern.py
COPY ./compose/django/entrypoint.sh /entrypoint.sh
RUN sed -i 's/\r//' /entrypoint.sh \
&& chmod +x /entrypoint.sh \
&& chown django /entrypoint.sh \
&& chown django /data/sockets
WORKDIR /app
ENTRYPOINT ["/entrypoint.sh"]

View File

@ -15,8 +15,6 @@ fi
export DATABASE_URL=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@postgres:5432/$POSTGRES_USER export DATABASE_URL=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@postgres:5432/$POSTGRES_USER
export CELERY_BROKER_URL=$REDIS_URL/0
function postgres_ready(){ function postgres_ready(){
python << END python << END

View File

@ -626,6 +626,7 @@ HUEY = {
'store_errors': True, # Store error info if task throws exception. 'store_errors': True, # Store error info if task throws exception.
'blocking': False, # Poll the queue rather than do blocking pop. 'blocking': False, # Poll the queue rather than do blocking pop.
'backend_class': 'huey.RedisHuey', # Use path to redis huey by default, 'backend_class': 'huey.RedisHuey', # Use path to redis huey by default,
'immediate': False,
'connection': { 'connection': {
'host': 'redis', 'host': 'redis',
'port': 6379, 'port': 6379,
@ -635,7 +636,6 @@ HUEY = {
# huey-specific connection parameters. # huey-specific connection parameters.
'read_timeout': 1, # If not polling (blocking pop), use timeout. 'read_timeout': 1, # If not polling (blocking pop), use timeout.
'max_errors': 1000, # Only store the 1000 most recent errors.
'url': None, # Allow Redis config via a DSN. 'url': None, # Allow Redis config via a DSN.
}, },
'consumer': { 'consumer': {

View File

@ -24,6 +24,8 @@ services:
user: django user: django
depends_on: depends_on:
- postgres - postgres
- directory
- redis
command: /live-gunicorn-mhackspace.sh command: /live-gunicorn-mhackspace.sh
env_file: .env env_file: .env
volumes: volumes:
@ -39,10 +41,11 @@ services:
huey: huey:
build: build:
context: . context: .
dockerfile: ./compose/django/Dockerfile-dev dockerfile: ./compose/django/Dockerfile
user: django user: django
depends_on: depends_on:
- postgres - postgres
- directory
- redis - redis
command: python manage.py run_huey command: python manage.py run_huey
env_file: .env env_file: .env

View File

@ -29,7 +29,7 @@ services:
huey: huey:
build: build:
context: . context: .
dockerfile: ./compose/django/Dockerfile-dev dockerfile: ./compose/django/Dockerfile
user: django user: django
depends_on: depends_on:
- postgres - postgres
@ -43,7 +43,7 @@ services:
django: django:
build: build:
context: . context: .
dockerfile: ./compose/django/Dockerfile-dev dockerfile: ./compose/django/Dockerfile
user: django user: django
depends_on: depends_on:
- postgres - postgres
@ -57,7 +57,7 @@ services:
django_bjoren: django_bjoren:
build: build:
context: . context: .
dockerfile: ./compose/django/Dockerfile-dev dockerfile: ./compose/django/Dockerfile
user: django user: django
depends_on: depends_on:
- postgres - postgres

View File

@ -9,7 +9,7 @@ import json
server = Server(settings.LDAP_SERVER) server = Server(settings.LDAP_SERVER)
conn = Connection( conn = Connection(
server, server,
'cn=admin, dc=maidstone-hackspace, dc=org, dc=uk', f'cn=admin, {settings.LDAP_ROOT}',
settings.LDAP_PASSWORD, settings.LDAP_PASSWORD,
auto_bind=True) auto_bind=True)

View File

@ -61,7 +61,7 @@ class MembershipAdmin(ModelAdmin):
return my_urls + urls return my_urls + urls
def refresh_payments(self, request): def refresh_payments(self, request):
update_users_memebership_status.apply_async() update_users_memebership_status()
# for user in update_subscriptions(provider_name='gocardless'): # for user in update_subscriptions(provider_name='gocardless'):
# continue # continue
self.message_user(request, 'Successfully triggered user payment refresh') self.message_user(request, 'Successfully triggered user payment refresh')

View File

@ -2,16 +2,16 @@
# like Pillow and psycopg2 # like Pillow and psycopg2
# See http://bitly.com/wheel-building-fails-CPython-35 # See http://bitly.com/wheel-building-fails-CPython-35
# Verified bug on Python 3.5.1 # Verified bug on Python 3.5.1
wheel==0.32.3 wheel==0.33.1
# Bleeding edge Django # Bleeding edge Django
django==2.1.7 django==2.2.1
django-dynamic-filenames==1.1.4 django-dynamic-filenames==1.1.4
# Configuration # Configuration
django-environ==0.4.5 django-environ==0.4.5
whitenoise==4.1.2 whitenoise==4.1.2
# Static and Media Storage # Static and Media Storage
# ------------------------------------------------ # ------------------------------------------------
boto3==1.9.96 boto3==1.9.142
django-storages==1.7.1 django-storages==1.7.1
# django-storages-redux==1.3.2 # django-storages-redux==1.3.2
@ -20,29 +20,29 @@ django-storages==1.7.1
django-braces==1.13.0 django-braces==1.13.0
django-crispy-forms==1.7.2 django-crispy-forms==1.7.2
django-extensions==2.1.5 django-extensions==2.1.6
Werkzeug==0.14.1 Werkzeug==0.15.2
# Models # Models
django-stdimage==4.0.1 django-stdimage==4.0.1
django-model-utils==3.1.2 django-model-utils==3.1.2
# Images # Images
Pillow==5.4.1 Pillow==6.0.0
# For user registration, either via email or social # For user registration, either via email or social
# Well-built with regular release cycles! # Well-built with regular release cycles!
django-allauth==0.38.0 django-allauth==0.39.1
# Python-PostgreSQL Database Adapter # Python-PostgreSQL Database Adapter
psycopg2==2.7.7 psycopg2==2.8.2
# Unicode slugification # Unicode slugification
awesome-slugify==1.6.5 awesome-slugify==1.6.5
# Time zones support # Time zones support
pytz==2018.9 pytz==2019.1
# Redis support # Redis support
django-redis==4.10.0 django-redis==4.10.0
@ -54,45 +54,45 @@ django-compressor==2.2
#fix for use with s3 buckets merged in master, so next release we can remove this #fix for use with s3 buckets merged in master, so next release we can remove this
#django-sass-processor==0.5.7 #django-sass-processor==0.5.7
git+https://github.com/jrief/django-sass-processor.git git+https://github.com/jrief/django-sass-processor.git
libsass==0.17.0 libsass==0.18.0
lxml==4.3.1 lxml==4.3.3
# WSGI Handler # WSGI Handler
# ------------------------------------------------ # ------------------------------------------------
gevent==1.4.0 gevent==1.4.0
gunicorn==19.9.0 gunicorn==19.9.0
#https://github.com/jonashaag/bjoern #https://github.com/jonashaag/bjoern
bjoern bjoern==2.2.3
# Your custom requirements go here # Your custom requirements go here
mock==2.0.0 mock==3.0.4
gocardless_pro==1.9.0 gocardless_pro==1.9.0
braintree==3.51.0 braintree==3.53.0
django-autofixture==0.12.1 django-autofixture==0.12.1
wiki==0.4.4 wiki==0.4.4
djangorestframework==3.9.1 djangorestframework==3.9.3
djangorestframework-jwt==1.11.0 djangorestframework-jwt==1.11.0
django-filter==2.1.0 django-filter==2.1.0
coreapi==2.3.3 coreapi==2.3.3
# api libraries end # api libraries end
martor==1.3.8 martor==1.4.0
django-spirit==0.7.0 django-spirit==0.7.1
django-djconfig==0.9.0 django-djconfig==0.10.0
django-haystack==2.8.1 django-haystack==2.8.1
django-xforwardedfor-middleware==2.0 django-xforwardedfor-middleware==2.0
# Application queue # Application queue
huey[backends] huey[backends]==2.0.1
argon2-cffi==19.1.0 argon2-cffi==19.1.0
django-cors-headers==2.4.0 django-cors-headers==2.5.3
python-magic==0.4.15 python-magic==0.4.15
ldap3==2.5.2 ldap3==2.6
bcrypt==3.1.6 bcrypt==3.1.6
python-twitter==3.5 python-twitter==3.5
feedparser==5.2.1 feedparser==5.2.1

View File

@ -2,15 +2,15 @@
-r base.txt -r base.txt
# linting # linting
flake8==3.7.5 # pyup: != 2.6.0 flake8==3.7.7 # pyup: != 2.6.0
coverage==4.5.2 coverage==4.5.3
factory-boy==2.11.1 factory-boy==2.11.1
django-coverage-plugin==1.6.0 django-coverage-plugin==1.6.0
django-test-plus==1.1.1 django-test-plus==1.1.1
# pytest pytest==4.4.1
pytest-django==3.4.7 pytest-django==3.4.8
pytest-sugar==0.9.2 pytest-sugar==0.9.2
model_mommy==1.6.0 model_mommy==1.6.0

View File

@ -24,8 +24,9 @@ services:
user: django user: django
depends_on: depends_on:
- postgres - postgres
# - redis - directory
command: /stage-gunicorn-mhackspace.sh - redis
command: python /app/wsgi_bjoern.py
env_file: .env env_file: .env
volumes: volumes:
- .:/app - .:/app
@ -39,11 +40,12 @@ services:
huey: huey:
build: build:
context: . context: .
dockerfile: ./compose/django/Dockerfile-dev dockerfile: ./compose/django/Dockerfile
user: django user: django
depends_on: depends_on:
- postgres - postgres
- redis - redis
- directory
command: python manage.py run_huey command: python manage.py run_huey
env_file: .env env_file: .env
volumes: volumes:

View File

@ -52,13 +52,15 @@ application.debug = True
# application = ReloadApplicationMiddleware(application) # application = ReloadApplicationMiddleware(application)
socket_path = '/data/sockets/bjoern-mhackspace.sock' socket_path = '/data/sockets/maidstone-hackspace.sock'
if os.path.exists(socket_path): if os.path.exists(socket_path):
os.unlink(socket_path) os.unlink(socket_path)
sock = socket.socket(socket.AF_UNIX) sock = socket.socket(socket.AF_UNIX)
sock.bind(socket_path) sock.bind(socket_path)
sock.listen(1024) sock.listen(1024)
os.chmod(socket_path, 0o666) os.chmod(socket_path, 0o666)
try: try:
bjoern.server_run(sock, application) bjoern.server_run(sock, application)
except KeyboardInterrupt: except KeyboardInterrupt: