Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
language: python
python:
- "3.6"
install:
- pip install pipenv
- pipenv install --dev

services:
- docker

env:
- secure: "ir3jXjYj2rstjhCTu6dbSZJb6JWiwE+VhoAY1z5KumilS8OU1rSytNyoxNMElcatzzfGYvwwCuh4M8iY5NbtDvWnHGvUXxcuZAKDSZ96bM9QNXlOzTNuRjwl9aQN2majkZCY2irRDmuAVoxodkNxavtw71D9jru5bv0J2kZdvobIjrTLHCj1kpbbxGgzWQz+2pRoX1sL3k7X17sKsf6i+7fG04OgaL1xKgLt2caaD7keAnt7vU8kk3gM2RtFwZHM8+qbnNVDT/lwKSHmjX+8J531F4rqAnPquGqUrOGmfhd6Nu5FG3n3x5/8axBfi+l04/c8lWO4MUCGSxZW6Rwx30HxXKgwff2yHgAo9yYWnOuri5rbDDiemhF7zRXeAl650usI4headAQK7S1q323/3AX+7vueL9L66Wg8u64ywY5EvqwoSBT7AgzvItqXI+PrSMGTimx9k0rMrLDOV0hMERzKaTO9qJb2Em5LNWBWAE76InGSD9F63PxL1NseDSjLHvYHM/dDflaTJBCWY5KMhO9jtqlT9jzu6gUDIzPQvXuusNo8a0V7giQ3vrB4vCLUSN9FUPN/kB5D/xzgAnKgm1gWXqdUoHF17XQxBqfdh0StefNP/5c/7UEFgQ8qgFUgclv4oWB3QN0Qv9V75JYJdcALdVHbz/1w5RgyxttXYVg="

before_install:
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get update
- sudo apt-get -y install docker-ce
- docker --version
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/1.20.1/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
- docker-compose --version

#install:
# - docker-compose up

script:
- pipenv run pytest
# - docker-compose exec backend pytest
- docker build -t backend ./backend
- docker images
- docker login -u "sztymajakub" -p "$HUB_PASSWORD" https://index.docker.io/v1/

deploy:
provider: script
script: bash docker_push.sh
on:
branch: master
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@

[![Build Status](https://travis-ci.org/apptension/django-restauth.svg?branch=master)](https://travis-ci.org/apptension/django-restauth)


## Runing on DigitalOcean
```
Here we use a database on a pod to avoid paying for managed database.
Normally a managed database should be used to run on DigitalOcean.
```
#### Create pods and services
```
kubectl apply -f kubernetes
```
#### Create a database on a pod
```
kubectl exec db bash
su postgres
psql
create database dev;
```
#### Run migrations
```
kubectl exec [dev pod name] bash
./manage.py migrate
./manage.py runserver 0:8000
```
### Test deployment
```
curl http://[load balancer external IP]:8080
```

## Running

```
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Dockerfile → backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ COPY Pipfile Pipfile.lock ./
RUN pip install --upgrade pip
RUN pip install pipenv
RUN pipenv install --system --dev
COPY . .
COPY locale .

CMD ["./run-backend.sh"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion restauth/settings.py → backend/restauth/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
AUTH_USER_MODEL = 'restauth.User'

LOCALE_PATHS = [
os.path.join(BASE_DIR, 'locale')
os.path.join(BASE_DIR, '../../locale')
]

REST_FRAMEWORK = {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions backend/run-backend.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

echo 'Hello'
./wait-for-it.sh db:5432
python manage.py migrate
python manage.py runserver 0:8080
File renamed without changes.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
depends_on:
- "db"
restart: on-failure
env_file: .env
env_file: .env.example

volumes:
restauth_backend:
Expand Down
3 changes: 3 additions & 0 deletions docker_push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
docker tag backend sztymajakub/main
docker push sztymajakub/main
37 changes: 37 additions & 0 deletions kubernetes/db-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.19.0 ()
creationTimestamp: null
labels:
app: v1
name: dev
spec:
replicas: 1
selector:
matchLabels:
app: v1
strategy: {}
template:
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.19.0 ()
creationTimestamp: null
labels:
app: v1
spec:
containers:
- image: sztymajakub/main:latest
name: dev
ports:
- containerPort: 8080
envFrom:
- configMapRef:
name: cm
args:
- ./run_django.sh
imagePullPolicy: Always
status: {}
16 changes: 16 additions & 0 deletions kubernetes/db-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
app: db
name: db
spec:
containers:
- image: postgres:9.6
name: db
ports:
- containerPort: 5432
resources: {}
restartPolicy: OnFailure
status: {}
13 changes: 13 additions & 0 deletions kubernetes/db-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: db
spec:
selector:
app: db
ports:
- name: "5432"
port: 5432
targetPort: 5432
status:
loadBalancer: {}
11 changes: 11 additions & 0 deletions kubernetes/dev-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: dev-svc
spec:
selector:
app: dev
ports:
- protocol: TCP
port: 8080
targetPort: 8080
11 changes: 11 additions & 0 deletions kubernetes/load-balancer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: lb
spec:
selector:
app: v1
ports:
- port: 8080
targetPort: 8080
type: LoadBalancer