Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rhixecompany committed Jan 8, 2025
0 parents commit 6dedada
Show file tree
Hide file tree
Showing 911 changed files with 160,427 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .devcontainer/bashrc.override.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

#
# .bashrc.override.sh
#

# persistent bash history
HISTFILE=~/.bash_history
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"

# set some django env vars
source /entrypoint

# restore default shell options
set +o errexit
set +o pipefail
set +o nounset

# start ssh-agent
# https://code.visualstudio.com/docs/remote/troubleshooting
eval "$(ssh-agent -s)"
68 changes: 68 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// For format details, see https://containers.dev/implementors/json_reference/
{
"name": "api_dev",
"dockerComposeFile": [
"../docker-compose.local.yml"
],
"init": true,
"mounts": [
{
"source": "./.devcontainer/bash_history",
"target": "/home/dev-user/.bash_history",
"type": "bind"
},
{
"source": "~/.ssh",
"target": "/home/dev-user/.ssh",
"type": "bind"
}
],
// Tells devcontainer.json supporting services / tools whether they should run
// /bin/sh -c "while sleep 1000; do :; done" when starting the container instead of the container’s default command
"overrideCommand": false,
"service": "django",
// "remoteEnv": {"PATH": "/home/dev-user/.local/bin:${containerEnv:PATH}"},
"remoteUser": "dev-user",
"workspaceFolder": "/app",
// Set *default* container specific settings.json values on container create.
"customizations": {
"vscode": {
"settings": {
"editor.formatOnSave": true,
"[python]": {
"analysis.autoImportCompletions": true,
"analysis.typeCheckingMode": "basic",
"defaultInterpreterPath": "/usr/local/bin/python",
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
},
"editor.defaultFormatter": "charliermarsh.ruff",
"languageServer": "Pylance",
"linting.enabled": true,
"linting.mypyEnabled": true,
"linting.mypyPath": "/usr/local/bin/mypy",
}
},
// https://code.visualstudio.com/docs/remote/devcontainerjson-reference#_vs-code-specific-properties
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"davidanson.vscode-markdownlint",
"mrmlnc.vscode-duplicate",
"visualstudioexptteam.vscodeintellicode",
"visualstudioexptteam.intellicode-api-usage-examples",
// python
"ms-python.python",
"ms-python.vscode-pylance",
"charliermarsh.ruff",
// django
"batisteo.vscode-django"
]
}
},
// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",
// Uncomment the next line to run commands after the container is created.
"postCreateCommand": "cat .devcontainer/bashrc.override.sh >> ~/.bashrc"
}
97 changes: 97 additions & 0 deletions .do/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
databases:
- engine: PG
name: db
num_nodes: 1
size: db-s-dev-database
version: "12"
envs:
- key: DISABLE_COLLECTSTATIC
scope: RUN_AND_BUILD_TIME
value: "1"
- key: DEBUG
scope: RUN_AND_BUILD_TIME
value: "0"
- key: DJANGO_ALLOWED_HOST
scope: RUN_AND_BUILD_TIME
value: .ondigitalocean.app
- key: DJANGO_SUPERUSER_EMAIL
scope: RUN_AND_BUILD_TIME
value: [email protected]
- key: DJANGO_SUPERUSER_USERNAME
scope: RUN_AND_BUILD_TIME
value: cfe
- key: DJANGO_SECRET_KEY
scope: RUN_AND_BUILD_TIME
type: SECRET
value: EV[1:w8aaS/4qnhOJoLOQW4JnsmcjMQWF9Xfv:ZC08ZkUwFhkEzqXYlgtlwh260FWLbe6Zy+c0dqH4nyaqPFDKNF03wFs4D/51604nC0/xkOfDlHf+ldmkzyEsL68S]
- key: DJANGO_SUPERUSER_PASSWORD
scope: RUN_AND_BUILD_TIME
type: SECRET
value: EV[1:O3RwT5emlMu5NlM0wjtqMug22+ojOpid:g/J7lCHyfbL1rdkRTKjLNG6irSM93bZR09h/riIykQw1pCULIsmPCGmWd2S2oxA5dwrRIhAx43UnMw==]
- key: POSTGRES_DB
scope: RUN_AND_BUILD_TIME
value: ${db.DATABASE}
- key: POSTGRES_HOST
scope: RUN_AND_BUILD_TIME
value: ${db.HOSTNAME}
- key: POSTGRES_USER
scope: RUN_AND_BUILD_TIME
value: ${db.USERNAME}
- key: POSTGRES_PASSWORD
scope: RUN_AND_BUILD_TIME
value: ${db.PASSWORD}
- key: POSTGRES_PORT
scope: RUN_AND_BUILD_TIME
value: ${db.PORT}
- key: AWS_ACCESS_KEY_ID
scope: RUN_AND_BUILD_TIME
type: SECRET
value: EV[1:MvVp4xFdM2EpA5q/NrOF4/0lNMoh/ZXE:E63UbQTTyx9eVTb7nS5D14m/e8K7a+3xt8d9xDV7v82KBImy]
- key: AWS_SECRET_ACCESS_KEY
scope: RUN_AND_BUILD_TIME
type: SECRET
value: EV[1:7m7Qtz9CU81/yRLPx/e/8yv0pMXbvSEc:f6iprDbF7oFPdo1tjTADVm28+gih9LehaGJaKRnSeIYXPGysfU6aM58YU8S+wIcnJxPw4NZdXyqcex4=]
- key: AWS_STORAGE_BUCKET_NAME
scope: RUN_AND_BUILD_TIME
value: trydjango32
- key: OCR_API_TOKEN_HEADER
scope: RUN_AND_BUILD_TIME
type: SECRET
value: EV[1:SjjuB8C+3JScJkhDe6NFYOS19d04Iiw/:LGp9KjNKfBdfHoAZjiVqSmREXLK65XwR/RIFgZYwFi98ayV3ySuQj6je7vNyjPpFzc7RKl4raCmoTvw=]
- key: OCR_API_ENDPOINT
scope: RUN_AND_BUILD_TIME
value: https://fastapi-microservice-for-django-d3kjd.ondigitalocean.app
jobs:
- environment_slug: python
envs:
- key: DATABASE_URL
scope: RUN_TIME
value: ${db.DATABASE_URL}
git:
branch: production-3
repo_clone_url: https://github.com/codingforentrepreneurs/Try-Django-3.2.git
instance_count: 1
instance_size_slug: basic-xxs
kind: PRE_DEPLOY
name: django-migrate-job
run_command: python manage.py migrate --noinput
source_dir: /
name: try-django-3-2
region: nyc
services:
- environment_slug: python
envs:
- key: DATABASE_URL
scope: RUN_TIME
value: ${db.DATABASE_URL}
git:
branch: production-3
repo_clone_url: https://github.com/codingforentrepreneurs/Try-Django-3.2.git
http_port: 8080
instance_count: 1
instance_size_slug: basic-xxs
name: try-django-3-2
routes:
- path: /
run_command: gunicorn --worker-tmp-dir /dev/shm trydjango.wsgi
source_dir: /
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.editorconfig
.gitattributes
.github
.gitignore
.gitlab-ci.yml
.idea
.pre-commit-config.yaml
.readthedocs.yml
.travis.yml
venv
.git
.envs/
27 changes: 27 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# http://editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{py,rst,ini}]
indent_style = space
indent_size = 4

[*.{html,css,scss,json,yml,xml}]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab

[default.conf]
indent_style = space
indent_size = 2
14 changes: 14 additions & 0 deletions .envs/.local/.django
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# General
# ------------------------------------------------------------------------------
USE_DOCKER=yes
IPYTHONDIR=/app/.ipython
# Redis
# ------------------------------------------------------------------------------
REDIS_URL=redis://redis:6379/0

# Celery
# ------------------------------------------------------------------------------

# Flower
CELERY_FLOWER_USER=debug
CELERY_FLOWER_PASSWORD=debug
7 changes: 7 additions & 0 deletions .envs/.local/.postgres
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# PostgreSQL
# ------------------------------------------------------------------------------
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_DB=api
POSTGRES_USER=debug
POSTGRES_PASSWORD=debug
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
38 changes: 38 additions & 0 deletions .github/workflows/collectstatic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This is a basic workflow to help you get started with Actions

name: Collectstatic for Django Static Files

# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install requirements
run: |
pip install -r requirements.txt
- name: Run Collectstatic
continue-on-error: true
env:
DEBUG: "0"
DJANGO_SECRET_KEY: CI_CD_TEST_KEY
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_STORAGE_BUCKET_NAME: ${{ secrets.AWS_STORAGE_BUCKET_NAME }}
run: |
python manage.py collectstatic --noinput
32 changes: 32 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This is a basic workflow to help you get started with Actions

name: Example CD Django to DigitalOcean

# Controls when the workflow will run
on:
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Push Main Branch into Production
uses: codingforentrepreneurs/action-branch-to-branch@main
with:
dest_branch: production-3
source_branch: main
commit_message: "Release production version"
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DO_ACCESS_TOKEN }}
- name: Run a DOCTL Command
run: |
doctl apps update ${{ secrets.DO_APP_ID }} --spec .do/app.yaml
62 changes: 62 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# This is a basic workflow to help you get started with Actions

name: Example CI Django & Postgres Tests

# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
services:
postgres_main:
image: postgres:12
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: djtesting
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install requirements
run: |
pip install -r requirements.txt
- name: Run Tests
env:
DEBUG: "0"
DJANGO_SECRET_KEY: CI_CD_TEST_KEY
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: djtesting
POSTGRES_PORT: 5432
run: |
python manage.py test
# - name: Push Main Branch into Production
# uses: codingforentrepreneurs/action-branch-to-branch@main
# with:
# dest_branch: production-3
# source_branch: main
# commit_message: "Release production version"
# env:
# GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
# - name: Install doctl
# uses: digitalocean/action-doctl@v2
# with:
# token: ${{ secrets.DO_ACCESS_TOKEN }}
# - name: Run a DOCTL Command
# run: |
# doctl apps update ${{ secrets.DO_APP_ID }} --spec .do/app.yaml
Loading

0 comments on commit 6dedada

Please sign in to comment.