-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from infracloudio/django-vote-app
acornfile for django vote app
- Loading branch information
Showing
31 changed files
with
806 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Publish Acorn image | ||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- "v[0-9]*" | ||
|
||
jobs: | ||
publish: | ||
name: Publish | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: acorn-io/actions-setup@v2 | ||
with: | ||
acorn-version: "main" | ||
- name: Login to GHCR | ||
uses: acorn-io/actions-login@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and Publish with signature | ||
run: | | ||
TAG=${GITHUB_REF#refs/*/} | ||
acorn build --platform linux/amd64 --platform linux/arm64 --push -t ghcr.io/infracloudio/django-acorn:${TAG} . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
services: db: image: "ghcr.io/acorn-io/mariadb:v10.11.5-1" | ||
|
||
containers: web: { | ||
build: { | ||
context: "./mysite" | ||
dockerfile: "./mysite/Dockerfile" | ||
} | ||
ports: publish: "8000:8000/http" | ||
if args.dev {dirs: "/app": "./mysite"} | ||
env: { | ||
MARIADB_USER: "@{service.db.secrets.admin.username}" | ||
MARIADB_ROOT_PASSWORD: "@{service.db.secrets.admin.password}" | ||
MARIADB_HOST: "@{service.db.address}" | ||
MARIADB_PORT: "@{service.db.port.3306}" | ||
MARIADB_DATABASE: "@{service.db.data.dbName}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Acorn for Django sample app - Vote App | ||
====== | ||
|
||
This is an Acorn for the sample Django Vote app following Django's Offical [Tutorial](https://docs.djangoproject.com/en/4.2/intro/tutorial01/).This sample Vote app lets people view polls and vote in them. An admin site that lets you add, change, and delete polls. | ||
|
||
## Deploy the Django App | ||
|
||
You can deploy the sample web app on the Acorn SaaS Platform with following simple steps. | ||
|
||
1. Login to the [Acorn SaaS Platform](https://beta.acorn.io/) using the Github Sign-In option with your Github user. | ||
2. Select the "Create Acorn" option. | ||
3. Choose the source for deploying your Acorns | ||
* Select "From Acorn Image" to deploy the sample Application | ||
* Provide a name such as `Django Sample Acorn` and keeping Project's default Region, type in the below Acorn image and choose Create | ||
```bash | ||
ghcr.io/infracloudio/django-acorn:v0.0.5 | ||
``` | ||
4. Now the sample App is provisioned on Acorn SaaS Platform and is available for 2hrs. Upgrade to pro account to keep it running longer. | ||
5. Once the Acorn is running, you can access it by clicking the Endpoint or the redirect link. | ||
|
||
## Acorn Django App Details | ||
|
||
The Acorn Dashboard is integrated with multiple features such as Events, Logs, Details and accessing the Shell of the Application. Details include the CPU, Memory, Network, Latency, Requests and Errors for the Application. | ||
|
||
Explore various available options by clicking the Menu option on your Acorn App. | ||
|
||
For more details on using the Acorn Dashboard, check this link - [https://beta-docs.acorn.io/getting-started#exploring-the-acorn-dashboard](https://beta-docs.acorn.io/getting-started#exploring-the-acorn-dashboard) | ||
|
||
## What next? | ||
After deploying you can edit the Acorn Application or remove it if no longer needed. | ||
|
||
1. Click the Edit option to edit your Acorn's Image. Toggle the Advanced Options switch for additional edit options. | ||
2. Remove the Acorn by selecting the Remove option from your Acorn dashboard. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# syntax=docker/dockerfile:1.4 | ||
|
||
FROM --platform=$BUILDPLATFORM python:3.10-alpine AS builder | ||
EXPOSE 8000 | ||
WORKDIR /app | ||
# Install system dependencies | ||
RUN apk update | ||
RUN apk add \ | ||
pkgconfig \ | ||
gcc \ | ||
musl-dev \ | ||
bash \ | ||
mariadb-dev | ||
|
||
COPY requirements.txt /app | ||
RUN pip3 install -r requirements.txt --no-cache-dir | ||
COPY . /app | ||
CMD bash -c "./db-script.sh && python3 manage.py runserver 0.0.0.0:8000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#! /bin/bash | ||
|
||
sleep 10 | ||
python3 manage.py migrate | ||
echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', '[email protected]', 'adminpassword')" | python3 manage.py shell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
"""Django's command-line utility for administrative tasks.""" | ||
import os | ||
import sys | ||
|
||
|
||
def main(): | ||
"""Run administrative tasks.""" | ||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') | ||
try: | ||
from django.core.management import execute_from_command_line | ||
except ImportError as exc: | ||
raise ImportError( | ||
"Couldn't import Django. Are you sure it's installed and " | ||
"available on your PYTHONPATH environment variable? Did you " | ||
"forget to activate a virtual environment?" | ||
) from exc | ||
execute_from_command_line(sys.argv) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
ASGI config for mysite 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/4.2/howto/deployment/asgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.asgi import get_asgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') | ||
|
||
application = get_asgi_application() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
""" | ||
Django settings for mysite project. | ||
Generated by 'django-admin startproject' using Django 4.2.6. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/4.2/topics/settings/ | ||
For the full list of settings and their values, see | ||
https://docs.djangoproject.com/en/4.2/ref/settings/ | ||
""" | ||
|
||
from pathlib import Path | ||
import os | ||
|
||
# Build paths inside the project like this: BASE_DIR / 'subdir'. | ||
BASE_DIR = Path(__file__).resolve().parent.parent | ||
|
||
|
||
# Quick-start development settings - unsuitable for production | ||
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ | ||
|
||
# SECURITY WARNING: keep the secret key used in production secret! | ||
SECRET_KEY = 'django-insecure-rw&hze^c#g8%f!bbplm7!%(^yryd9m&rjbho(31%rpgi#^9y1*' | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = True | ||
|
||
ALLOWED_HOSTS = ["*"] | ||
CSRF_TRUSTED_ORIGINS = ['http://*.on-acorn.io','https://*.on-acorn.io'] | ||
|
||
# Application definition | ||
|
||
INSTALLED_APPS = [ | ||
"polls.apps.PollsConfig", | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
] | ||
|
||
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 = 'mysite.urls' | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': [BASE_DIR / "templates"], | ||
'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 = 'mysite.wsgi.application' | ||
|
||
|
||
# Database | ||
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.mysql', | ||
# 'NAME': 'djangodemo2', | ||
# "USER": 'admin', | ||
# "PASSWORD": 'password', | ||
# "HOST": 'localhost', | ||
# "PORT": '3306', | ||
'NAME': os.getenv('MARIADB_DATABASE'), | ||
"USER": os.getenv('MARIADB_USER'), | ||
"PASSWORD": os.getenv('MARIADB_ROOT_PASSWORD'), | ||
"HOST": os.getenv('MARIADB_HOST'), | ||
"PORT": os.getenv('MARIADB_PORT', 3306), | ||
} | ||
} | ||
|
||
|
||
# Password validation | ||
# https://docs.djangoproject.com/en/4.2/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/4.2/topics/i18n/ | ||
|
||
LANGUAGE_CODE = 'en-us' | ||
|
||
TIME_ZONE = 'UTC' | ||
|
||
USE_I18N = True | ||
|
||
USE_TZ = True | ||
|
||
|
||
# Static files (CSS, JavaScript, Images) | ||
# https://docs.djangoproject.com/en/4.2/howto/static-files/ | ||
|
||
STATIC_URL = 'static/' | ||
|
||
# Default primary key field type | ||
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field | ||
|
||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
URL configuration for mysite project. | ||
The `urlpatterns` list routes URLs to views. For more information please see: | ||
https://docs.djangoproject.com/en/4.2/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 include, path | ||
from polls import views | ||
|
||
urlpatterns = [ | ||
path("polls/", include("polls.urls")), | ||
path("admin/", admin.site.urls), | ||
path("",views.homepage) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
WSGI config for mysite 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/4.2/howto/deployment/wsgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.wsgi import get_wsgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') | ||
|
||
application = get_wsgi_application() |
Oops, something went wrong.