Fakultas Ilmu Komputer UI

Commit 17b7bff3 authored by Dave Nathanael's avatar Dave Nathanael Committed by Yumna Pratista Tastaftian
Browse files

Initiate app structure and CI/CD

parent dcdab192
.vscode
env
\ No newline at end of file
stages:
- test
- deploy
test:
image: python:3.6.5
stage: test
before_script:
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
- pip install -r requirements.txt
- >
if [[ "${CI_COMMIT_REF_NAME}" == "staging" ]];
then
DATABASE_URL=$DATABASE_URL_STAGING
export DATABASE_NAME=d2puge2oh9kcgg
export DATABASE_USER=wvkketkmnoishk
export DATABASE_PASSWORD=3a76f9e64591d23ed092961d90beec80889e1788b668fdfc6e897065d20e6b0a
export DATABASE_HOST=ec2-18-213-176-229.compute-1.amazonaws.com
export DATABASE_PORT=5432
elif [[ "${CI_COMMIT_REF_NAME}" == "master" ]];
then
DATABASE_URL=$DATABASE_URL_PRODUCTION
export DATABASE_NAME=d16n2kmrcvrd3g
export DATABASE_USER=owrnaqzrbylqzh
export DATABASE_PASSWORD=eee44bfc9b5177f575bb40b363b7539c27625c82e58135f00a5d7df9586bd49a
export DATABASE_HOST=ec2-18-213-176-229.compute-1.amazonaws.com
export DATABASE_PORT=5432
fi
- python manage.py makemigrations
- python manage.py migrate
- apt-get update -qq && apt-get install -y -qq unzip
- apt-get install -y xvfb
- python manage.py collectstatic --no-input
- python manage.py runserver 8000 &
when: on_success
script:
- echo "Starting tests"
- coverage run --include="./app/*" manage.py test
- coverage report -m
deploy:
image: ruby:2.4
stage: deploy
before_script:
- gem install dpl
- wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
- >
if [[ "${CI_COMMIT_REF_NAME}" == "staging" ]];
then
HEROKU_APP=$HEROKU_STAGING_APP
HEROKU_APP_HOST=http://tuberculosis-ppti-staging.herokuapp.com/
ENVIRONMENT_NAME=staging
elif [[ "${CI_COMMIT_REF_NAME}" == "master" ]];
then
HEROKU_APP=$HEROKU_PRODUCTION_APP
HEROKU_APP_HOST=http://tuberculosis-ppti.herokuapp.com/
ENVIRONMENT_NAME=production
fi
- >
if [[ "${CI_COMMIT_REF_NAME}" == "staging" ]];
then
DATABASE_URL=$DATABASE_URL_STAGING
export DATABASE_NAME=d2puge2oh9kcgg
export DATABASE_USER=wvkketkmnoishk
export DATABASE_PASSWORD=3a76f9e64591d23ed092961d90beec80889e1788b668fdfc6e897065d20e6b0a
export DATABASE_HOST=ec2-18-213-176-229.compute-1.amazonaws.com
export DATABASE_PORT=5432
export HEROKU_APP_NAME=tuberculosis-ppti-staging
elif [[ "${CI_COMMIT_REF_NAME}" == "master" ]];
then
DATABASE_URL=$DATABASE_URL_PRODUCTION
export DATABASE_NAME=d16n2kmrcvrd3g
export DATABASE_USER=owrnaqzrbylqzh
export DATABASE_PASSWORD=eee44bfc9b5177f575bb40b363b7539c27625c82e58135f00a5d7df9586bd49a
export DATABASE_HOST=ec2-18-213-176-229.compute-1.amazonaws.com
export DATABASE_PORT=5432
export HEROKU_APP_NAME=tuberculosis-ppti
fi
- export HEROKU_API_KEY=0ee33a63-1aa9-4e5a-880a-ca123fdbbf16
- echo $HEROKU_APP_NAME
- echo $HEROKU_APP_HOST
- echo $HEROKU_API_KEY
- heroku run --app $HEROKU_APP_NAME makemigrations
script:
- dpl --provider=heroku --app=$HEROKU_APP_NAME --api-key=$HEROKU_API_KEY
- export HEROKU_API_KEY=$HEROKU_API_KEY
- heroku run --app $HEROKU_APP_NAME migrate
environment:
name: $ENVIRONMENT_NAME
url: $HEROKU_APP_HOST
FROM python:3.7-alpine
RUN apk update && apk add postgresql-dev gcc python3-dev musl-dev
LABEL maintainer="nezappl@gmail.com"
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV DEBUG 0
COPY ./requirements.txt /requirements.txt
RUN pip install -r requirements.txt
RUN mkdir /app
WORKDIR /app
COPY ./app /app
RUN adduser -D user
USER user
CMD python manage.py runserver 0.0.0.0:$PORT
\ No newline at end of file
web: gunicorn app.wsgi
Mobile Apps Monitoring Wabah Tuberkulosis - TBCare
\ No newline at end of file
# Mobile Apps Monitoring Wabah Tuberkulosis - TBCare
## Overview
This repository contains codebase for TBCare backend system
## Tech Stack
- Django Rest Framework
- PostgreSQL RDBMS
- Docker (with compose)
## Team Members
- Dave Nathanael
- Irwanto
- Jonathan Christopher J
- Josh Sudung
- Nandhika Prayoga
"""
ASGI config for app project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
application = get_asgi_application()
"""
Django settings for app project.
Generated by 'django-admin startproject' using Django 3.0.1.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "e6cve$0dh*pzse)e2w%!kim^&a17*fgle@b4y!yvk@eih+r_4("
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ["*"]
# Application definition
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"home",
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
ROOT_URLCONF = "app.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
WSGI_APPLICATION = "app.wsgi.application"
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ.get('DATABASE_NAME'),
'USER': os.environ.get('DATABASE_USER'),
'PASSWORD': os.environ.get('DATABASE_PASSWORD'),
'HOST': os.environ.get('DATABASE_HOST'),
'PORT': os.environ.get('DATABASE_PORT'),
}
}
# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",},
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",},
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",},
]
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE = "en-us"
TIME_ZONE = "UTC"
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
"""app URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path("", include("home.urls")),
path("admin/", admin.site.urls),
]
"""
WSGI config for app project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
application = get_wsgi_application()
version: "3"
services:
web:
build: .
ports:
- "8000:8000"
env_file:
- local-var.env
volumes:
- ./app:/app
command: sh -c "python manage.py runserver 0.0.0.0:8000"
depends_on:
- db
db:
image: postgres
ports:
- "5432:5432"
deploy:
build: .
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment