Skip to content

Commit

Permalink
Fix some issues with configs and entrypoint testing for database
Browse files Browse the repository at this point in the history
  • Loading branch information
abkfenris committed May 31, 2019
1 parent 1f75d45 commit 04ffac2
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 204 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,4 @@ docker-data/media
docker-data/django-static
secrets.yaml
dump.sql
docker-hub-secret.yaml
1 change: 0 additions & 1 deletion app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
binutils=2.28-5 \
libproj-dev=4.9.3-1 \
gdal-bin=2.1.2+dfsg-5 \
postgresql-client=9.6+181+deb9u2 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
16 changes: 16 additions & 0 deletions app/account/management/commands/db_ready.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django.core.management.base import BaseCommand, CommandError
from django.db import connection, OperationalError


class Command(BaseCommand):
help = "Check if the database is currently avaliable"

def handle(self, *args, **kwargs):
try:
if connection.introspection.table_names():
pass
except OperationalError:
raise CommandError("Database is not yet up")

else:
self.stdout.write("Database up")
2 changes: 1 addition & 1 deletion app/requirements.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Django==2.2
gunicorn==19.9.0
psycopg2-binary==2.7.7
psycopg2-binary==2.8.2
djangorestframework==3.9.2
djangorestframework-gis==0.14
django-memoize==2.2.0
Expand Down
6 changes: 3 additions & 3 deletions app/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ chardet==3.0.4 # via requests
click==7.0 # via pip-tools
coverage==4.5.3
decorator==4.4.0 # via ipython, traitlets
django-cors-headers==2.5.3
django-cors-headers==2.5.2
django-debug-toolbar==1.11
django-memoize==2.2.0
django-redis==4.10.0
django==2.2.1
django==2.2
djangorestframework-gis==0.14
djangorestframework==3.9.2
dodgy==0.1.9 # via prospector
Expand Down Expand Up @@ -49,7 +49,7 @@ pip_tools==3.5.0
pipdeptree==0.13.2
prompt-toolkit==2.0.9 # via ipython
prospector[with_mypy,with_vulture]==1.1.6.2
psycopg2-binary==2.7.7
psycopg2-binary==2.8.2
ptyprocess==0.6.0 # via pexpect
pycodestyle==2.4.0 # via prospector
pydocstyle==3.0.0 # via prospector
Expand Down
2 changes: 1 addition & 1 deletion app/utils/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

set -e

until pg_isready -h $POSTGRES_HOST; do
until python manage.py db_ready; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
Expand Down
179 changes: 0 additions & 179 deletions app/utils/wait-for-it.sh

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ cache:

web:
build: ./app
command: bash -c "./utils/wait-for-it.sh db:5432 && python manage.py runserver 0:8080"
command: python manage.py runserver 0:8080
# # command: "uwsgi --http :8080 --wsgi-file buoy_barn/wsgi.py --master --processes 4 --threads 2"
# command: "uwsgi --module=buoy_barn.wsgi:application --master --pidfile=/tmp/project-master.pid --http :8080 --uid=1000 --gid=2000 --max-requests=5000 --vacuum --processes 4"
# # command: "gunicorn --bind 0.0.0.0:8080 buoy_barn.wsgi:application"
Expand Down
20 changes: 13 additions & 7 deletions k8s/base/cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@ apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: buoy-barn-cache
label:
labels:
service: redis
tier: backend
role: cache
spec:
serviceName: buoy-barn-cache
replicas: 1
template:
name: buoy-barn-cache
labels:
selector:
matchLabels:
service: redis
tier: backend
role: cache
serviceName: buoy-barn-cache
replicas: 1
template:
metadata:
labels:
service: redis
tier: backend
role: cache
spec:
containers:
- name: redis
image: 5.0.5-alpine
image: redis:5.0.5-alpine
ports:
- containerPort: 6379
volumeClaimTemplates: []
15 changes: 7 additions & 8 deletions k8s/base/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ kind: Deployment
metadata:
labels:
service: web
app: buoy-barn
tier: frontend
role: api
name: web
spec:
template:
metadata:
labels:
service: web
app: buoy-barn
tier: frontend
role: api
spec:
containers:
- args:
Expand All @@ -36,14 +38,11 @@ spec:
value: "on"
- name: DJANGO_MANAGEPY_COLLECTSTATIC
value: "on"
- name: POSTGRES_HOST
- name: POSTGRES_PASSWORD
- name: POSTGRES_USER
- name: SECRET_KEY
- name: SENTRY_DSN
image: grmi/buoy-barn
image: gmri/neracoos-buoy-barn
name: web
ports:
- containerPort: 8080
name: http
resources: {}
imagePullSecrets:
- name: docker-hub-secret
3 changes: 2 additions & 1 deletion k8s/base/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ metadata:
nginx.ingress.kubernetes.io/cors-allow-origin: "localhost mariners.neracoos.org"
spec:
rules:
- http:
- host: buoybarn.neracoos.org
http:
paths:
- path: /
backend:
Expand Down
1 change: 1 addition & 0 deletions k8s/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace: buoy-barn
resources:
- docker-hub-secret.yaml
- cache.yaml
- cache-service.yaml
- deployment.yaml
Expand Down
3 changes: 2 additions & 1 deletion k8s/base/web-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ spec:
targetPort: 8080
selector:
service: web
app: buoy-barn
tier: frontend
role: api
2 changes: 1 addition & 1 deletion skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: skaffold/v1beta2
kind: Config
build:
artifacts:
- image: grmi/neracoos-buoy-barn
- image: gmri/neracoos-buoy-barn
context: app
deploy:
kustomize:
Expand Down

0 comments on commit 04ffac2

Please sign in to comment.