Skip to content

Commit a6612f0

Browse files
Merge pull request #271 from DefangLabs/linda-golang2
Minor changes to golang-slackbot readme
0 parents  commit a6612f0

30 files changed

+1018
-0
lines changed

.github/workflows/deploy.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
environment: playground
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
id-token: write
15+
16+
steps:
17+
- name: Checkout Repo
18+
uses: actions/checkout@v4
19+
20+
- name: Deploy
21+
uses: DefangLabs/[email protected]

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Django & Postgres
2+
3+
[![1-click-deploy](https://defang.io/deploy-with-defang.png)](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-django-postgres-template%26template_owner%3DDefangSamples)
4+
5+
This template is a customer relationship management list project developed using Python Django framework, offering a starting point to help you quickly build your customer management system. We use PostgreSQL as the database. We have prepared all the essential files for deployment. By spending less than 10 minutes setting up the environment, as detailed in the prerequisites, and executing the commands in our step-by-step guide, your website will be ready to go live to the world!
6+
7+
## NOTE
8+
9+
This sample showcases how you could deploy a full-stack application with Defang and Django. However, it deploys postgres as a defang service. Defang [services](https://12factor.net/processes) are ephemeral and should not be used to run stateful workloads in production as they will be reset on every deployment. For production use cases you should use a managed database like RDS, Aiven, or others. If you stick to Rail's default SQLite database, your stored data will be lost on every deployment, and in some other situations. In the future, Defang will help you provision and connect to managed databases.
10+
11+
## Essential Setup Files
12+
13+
1. A [Dockerfile](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/) to describe the basic image of your applications.
14+
2. A [docker-compose file](https://docs.defang.io/docs/concepts/compose) to define and run multi-container Docker applications.
15+
3. A [.dockerignore](https://docs.docker.com/build/building/context/#dockerignore-files) file to comply with the size limit (10MB).
16+
17+
## Prerequisite
18+
19+
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
20+
2. If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc), make sure you have properly [authenticated your AWS account](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html)
21+
Plus, make sure that you have properly set your environment variables like `AWS_PROFILE`, `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`.
22+
23+
## A Step-by-Step Guide for Deployment
24+
25+
1. Open the terminal and type `defang login`
26+
2. Type `defang compose up` in the CLI
27+
3. Now your application will be launched
28+
29+
---
30+
31+
Title: Django & PostgreSQL
32+
33+
Short Description: A customer relationship management list project developed using the Python Django framework, offering a starting point to help you quickly build your customer management system.
34+
35+
Tags: Django, PostgreSQL, Python, SQL
36+
37+
Languages: python

app/.dockerignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Ignore version control directories
2+
.git
3+
.gitignore
4+
5+
# Ignore all bytecode
6+
*.pyc
7+
__pycache__/
8+
9+
# Ignore various log and data directories that are created while running locally
10+
logs/
11+
data/
12+
13+
# Ignore virtual environment directories
14+
virt/
15+
16+
# Ignore test, documentation, and CI configuration
17+
tests/
18+
docs/
19+
*.md
20+
.circleci/
21+
.travis.yml
22+
.gitlab-ci.yml
23+
24+
# Ignore PostgreSQL specific files
25+
*.sql
26+
*.dump
27+
28+
# Ignore other unnecessary files
29+
*.log
30+
*.tar.gz
31+
*.zip
32+
tmp/

app/.gitignore

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
tmp
2+
3+
# Django #
4+
*.log
5+
*.pot
6+
*.pyc
7+
__pycache__
8+
db.sqlite3
9+
media
10+
11+
# Backup files #
12+
*.bak
13+
14+
# If using celery-beat with pickle as serializer #
15+
celerybeat-schedule.bak
16+
17+
# PyCharm #
18+
.idea/
19+
20+
# VS Code #
21+
.vscode/
22+
23+
# Python #
24+
*.py[cod]
25+
*$py.class
26+
27+
# Distribution / packaging #
28+
.Python
29+
env/
30+
build/
31+
develop-eggs/
32+
dist/
33+
downloads/
34+
eggs/
35+
.eggs/
36+
lib/
37+
lib64/
38+
parts/
39+
sdist/
40+
var/
41+
wheels/
42+
*.egg-info/
43+
.installed.cfg
44+
*.egg
45+
46+
# Installer logs #
47+
pip-log.txt
48+
pip-delete-this-directory.txt
49+
50+
# Unit test / coverage reports #
51+
htmlcov/
52+
.tox/
53+
.coverage
54+
.coverage.*
55+
.cache
56+
nosetests.xml
57+
coverage.xml
58+
*.cover
59+
.hypothesis/
60+
61+
# Translations #
62+
*.mo
63+
*.pot
64+
65+
# Django stuff #
66+
*.log
67+
local_settings.py
68+
db.sqlite3
69+
db.sqlite3-journal
70+
71+
# Flask stuff #
72+
instance/
73+
.webassets-cache
74+
75+
# Scrapy stuff #
76+
.scrapy
77+
78+
# Sphinx documentation #
79+
docs/_build/
80+
81+
# PyBuilder #
82+
target/
83+
84+
# Jupyter Notebook #
85+
.ipynb_checkpoints
86+
87+
# IPython #
88+
profile_default/
89+
ipython_config.py
90+
91+
# pyenv #
92+
.python-version
93+
94+
# celery beat schedule file #
95+
celerybeat-schedule
96+
97+
# SageMath parsed files #
98+
*.sage.py
99+
100+
# dotenv #
101+
.env
102+
103+
# virtualenv #
104+
venv/
105+
ENV/
106+
107+
# Spyder project settings #
108+
.spyderproject
109+
.spyproject
110+
111+
# Rope project settings #
112+
.ropeproject
113+
114+
# mkdocs documentation #
115+
/site
116+
117+
# mypy #
118+
.mypy_cache/
119+
.dmypy.json
120+
dmypy.json
121+
122+
# Pyre type checker #
123+
.pyre/
124+
125+
# pytype static type analyzer #
126+
.pytype/
127+
128+
# Cython debug symbols #
129+
cython_debug/
130+
131+
# Profiling data #
132+
.prof
133+
134+
# Ignore the static files
135+
staticfiles/

app/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use an official Python runtime as a parent image
2+
FROM python:3.11-slim
3+
4+
RUN apt-get update -qq \
5+
&& apt-get install -y curl \
6+
&& apt-get clean \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
# Set environment variables
10+
ENV PYTHONDONTWRITEBYTECODE 1
11+
ENV PYTHONUNBUFFERED 1
12+
13+
# Set work directory
14+
WORKDIR /code
15+
16+
# Install dependencies
17+
COPY ./requirements.txt .
18+
RUN pip install -r requirements.txt
19+
20+
# Copy project
21+
COPY . /code/
22+
23+
# Collect static files
24+
RUN python manage.py collectstatic --noinput
25+
26+
# Start server
27+
CMD python manage.py migrate && python manage.py createsuperuser && gunicorn crm_platform.wsgi:application --bind 0.0.0.0:8000

app/crm_platform/__init__.py

Whitespace-only changes.

app/crm_platform/asgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for crm_platform project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'crm_platform.settings')
15+
16+
application = get_asgi_application()

0 commit comments

Comments
 (0)