-
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 #5 from linea-it/3-django-and-drf
Django and Django Rest Framework
- Loading branch information
Showing
135 changed files
with
5,070 additions
and
104 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 @@ | ||
# FROM mcr.microsoft.com/devcontainers/python:0-3.12 | ||
FROM mcr.microsoft.com/devcontainers/python:3.12-bookworm | ||
|
||
ENV PYTHONUNBUFFERED 1 | ||
|
||
ARG BUILD_ENVIRONMENT=local | ||
|
||
# [Optional] Uncomment this section to install additional OS packages. | ||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get -y install --no-install-recommends \ | ||
# dependencies for building Python packages | ||
build-essential \ | ||
# psycopg dependencies | ||
libpq-dev \ | ||
# python dev | ||
python3-dev \ | ||
# Cleaning up | ||
&& apt-get clean \ | ||
&& apt-get autoclean \ | ||
&& apt-get autoremove --purge -y \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# [Optional] If your requirements rarely change, uncomment this section to add them to the image. | ||
COPY ./backend/requirements /tmp/pip-tmp/ | ||
RUN pip install --upgrade pip wheel setuptools \ | ||
&& pip --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/${BUILD_ENVIRONMENT}.txt \ | ||
&& rm -rf /tmp/pip-tmp | ||
|
||
ENV DJANGO_SETTINGS_MODULE=config.settings.production |
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,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)" |
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,76 @@ | ||
// For format details, see https://containers.dev/implementors/json_reference/ | ||
{ | ||
"name": "sky_viewer_dev", | ||
"dockerComposeFile": [ | ||
"../docker-compose.local.yml", | ||
"docker-compose.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" | ||
}, | ||
{ | ||
"source": "..", | ||
"target": "/workspaces", | ||
"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": "vscode", | ||
// "remoteEnv": {"PATH": "/home/dev-user/.local/bin:${containerEnv:PATH}"}, | ||
// "remoteUser": "dev-user", | ||
// The optional 'workspaceFolder' property is the path VS Code should open by default when | ||
// connected. This is typically a file mount in .devcontainer/docker-compose.yml | ||
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", | ||
// 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" | ||
} |
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,24 @@ | ||
services: | ||
# Update this to the name of the service you want to work with in your docker-compose.yml file | ||
vscode: | ||
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer | ||
# folder. Note that the path of the Dockerfile and context is relative to the *primary* | ||
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile" | ||
# array). The sample below assumes your primary file is in the root of your project. | ||
# | ||
build: | ||
context: . | ||
dockerfile: .devcontainer/Dockerfile | ||
|
||
# volumes: | ||
# # Update this to wherever you want VS Code to mount the folder of your project | ||
# - ..:/workspaces:cached | ||
|
||
# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust. | ||
# cap_add: | ||
# - SYS_PTRACE | ||
# security_opt: | ||
# - seccomp:unconfined | ||
|
||
# Overrides default command so things don't shut down after the process ends. | ||
command: /bin/sh -c "while sleep 1000; do :; done" |
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,12 @@ | ||
.editorconfig | ||
.gitattributes | ||
.github | ||
.gitignore | ||
.gitlab-ci.yml | ||
.idea | ||
.pre-commit-config.yaml | ||
.readthedocs.yml | ||
.travis.yml | ||
venv | ||
.git | ||
.envs/ |
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,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 |
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,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 |
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,7 @@ | ||
# PostgreSQL | ||
# ------------------------------------------------------------------------------ | ||
POSTGRES_HOST=postgres | ||
POSTGRES_PORT=5432 | ||
POSTGRES_DB=sky_viewer | ||
POSTGRES_USER=debug | ||
POSTGRES_PASSWORD=debug |
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 @@ | ||
* text=auto |
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,91 @@ | ||
# Config for Dependabot updates. See Documentation here: | ||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
# Update GitHub actions in workflows | ||
- package-ecosystem: 'github-actions' | ||
directory: '/' | ||
# Every weekday | ||
schedule: | ||
interval: 'daily' | ||
|
||
# Enable version updates for Docker | ||
# We need to specify each Dockerfile in a separate entry because Dependabot doesn't | ||
# support wildcards or recursively checking subdirectories. Check this issue for updates: | ||
# https://github.com/dependabot/dependabot-core/issues/2178 | ||
- package-ecosystem: 'docker' | ||
# Look for a `Dockerfile` in the `compose/local/django` directory | ||
directory: 'compose/local/django/' | ||
# Every weekday | ||
schedule: | ||
interval: 'daily' | ||
# Ignore minor version updates (3.10 -> 3.11) but update patch versions | ||
ignore: | ||
- dependency-name: '*' | ||
update-types: | ||
- 'version-update:semver-major' | ||
- 'version-update:semver-minor' | ||
|
||
- package-ecosystem: 'docker' | ||
# Look for a `Dockerfile` in the `compose/local/docs` directory | ||
directory: 'compose/local/docs/' | ||
# Every weekday | ||
schedule: | ||
interval: 'daily' | ||
# Ignore minor version updates (3.10 -> 3.11) but update patch versions | ||
ignore: | ||
- dependency-name: '*' | ||
update-types: | ||
- 'version-update:semver-major' | ||
- 'version-update:semver-minor' | ||
|
||
- package-ecosystem: 'docker' | ||
# Look for a `Dockerfile` in the `compose/local/node` directory | ||
directory: 'compose/local/node/' | ||
# Every weekday | ||
schedule: | ||
interval: 'daily' | ||
|
||
- package-ecosystem: 'docker' | ||
# Look for a `Dockerfile` in the `compose/production/aws` directory | ||
directory: 'compose/production/aws/' | ||
# Every weekday | ||
schedule: | ||
interval: 'daily' | ||
|
||
- package-ecosystem: 'docker' | ||
# Look for a `Dockerfile` in the `compose/production/django` directory | ||
directory: 'compose/production/django/' | ||
# Every weekday | ||
schedule: | ||
interval: 'daily' | ||
# Ignore minor version updates (3.10 -> 3.11) but update patch versions | ||
ignore: | ||
- dependency-name: '*' | ||
update-types: | ||
- 'version-update:semver-major' | ||
- 'version-update:semver-minor' | ||
|
||
- package-ecosystem: 'docker' | ||
# Look for a `Dockerfile` in the `compose/production/postgres` directory | ||
directory: 'compose/production/postgres/' | ||
# Every weekday | ||
schedule: | ||
interval: 'daily' | ||
|
||
- package-ecosystem: 'docker' | ||
# Look for a `Dockerfile` in the `compose/production/traefik` directory | ||
directory: 'compose/production/traefik/' | ||
# Every weekday | ||
schedule: | ||
interval: 'daily' | ||
|
||
# Enable version updates for Python/Pip - Production | ||
- package-ecosystem: 'pip' | ||
# Look for a `requirements.txt` in the `root` directory | ||
# also 'setup.cfg', 'runtime.txt' and 'requirements/*.txt' | ||
directory: '/' | ||
# Every weekday | ||
schedule: | ||
interval: 'daily' |
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
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,60 @@ | ||
name: CI | ||
|
||
# Enable Buildkit and let compose use it to speed up image building | ||
env: | ||
DOCKER_BUILDKIT: 1 | ||
COMPOSE_DOCKER_CLI_BUILD: 1 | ||
|
||
on: | ||
pull_request: | ||
branches: ['master', 'main'] | ||
paths-ignore: ['docs/**'] | ||
|
||
push: | ||
branches: ['master', 'main'] | ||
paths-ignore: ['docs/**'] | ||
|
||
concurrency: | ||
group: ${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
linter: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
# Consider using pre-commit.ci for open source project | ||
- name: Run pre-commit | ||
uses: pre-commit/[email protected] | ||
|
||
# With no caching at all the entire ci process takes 3m to complete! | ||
pytest: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build the Stack | ||
run: docker compose -f docker-compose.local.yml build django | ||
|
||
- name: Build the docs | ||
run: docker compose -f docker-compose.docs.yml build docs | ||
|
||
- name: Check DB Migrations | ||
run: docker compose -f docker-compose.local.yml run --rm django python manage.py makemigrations --check | ||
|
||
- name: Run DB Migrations | ||
run: docker compose -f docker-compose.local.yml run --rm django python manage.py migrate | ||
|
||
- name: Run Django Tests | ||
run: docker compose -f docker-compose.local.yml run django pytest | ||
|
||
- name: Tear down the Stack | ||
run: docker compose -f docker-compose.local.yml down |
Oops, something went wrong.