mirror of https://github.com/snachodog/mybuddy.git
Switch to dev containers
This commit is contained in:
parent
3b93bb8861
commit
0d76868e6e
|
@ -1,23 +1,39 @@
|
|||
{
|
||||
"name": "babybuddy",
|
||||
"image": "mcr.microsoft.com/devcontainers/python:3",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/github-cli:1": {},
|
||||
"ghcr.io/devcontainers/features/node:1": {
|
||||
"version": "18"
|
||||
},
|
||||
"ghcr.io/devcontainers-contrib/features/gulp-cli:2": {},
|
||||
"ghcr.io/devcontainers-contrib/features/pipenv:2": {}
|
||||
},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"bbenoist.Nix",
|
||||
"ms-python.python",
|
||||
"batisteo.vscode-django",
|
||||
"ms-python.black-formatter"
|
||||
"donjayamanne.python-environment-manager",
|
||||
"ms-python.black-formatter",
|
||||
"ms-python.python",
|
||||
"samuelcolvin.jinjahtml"
|
||||
],
|
||||
"settings": {
|
||||
"[python]": {
|
||||
"defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
|
||||
"editor": {
|
||||
"defaultFormatter": "ms-python.black-formatter"
|
||||
},
|
||||
"pipenvPath": "pipenv"
|
||||
}
|
||||
},
|
||||
"terminal.integrated.defaultProfile.linux": "zsh"
|
||||
}
|
||||
}
|
||||
},
|
||||
"image": "ghcr.io/cachix/devenv:latest",
|
||||
"overrideCommand": false,
|
||||
"updateContentCommand": "devenv ci"
|
||||
"containerEnv": {
|
||||
"DJANGO_SETTINGS_MODULE": "babybuddy.settings.development",
|
||||
"PIPENV_VENV_IN_PROJECT": "1"
|
||||
},
|
||||
"postCreateCommand": "pipenv install --dev && npm install --include=dev && gulp migrate",
|
||||
"forwardPorts": [8000]
|
||||
}
|
||||
|
|
3
.envrc
3
.envrc
|
@ -1,3 +0,0 @@
|
|||
source_url "https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6dee421cfd0f51481d17f77586997/direnvrc" "sha256-YBzqskFZxmNb3kYVoKD9ZixoPXJh1C9ZvTLGFRkauZ0="
|
||||
|
||||
use devenv
|
|
@ -1,20 +1,19 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: Django",
|
||||
"type": "python",
|
||||
"name": "Debug Baby Buddy",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/manage.py",
|
||||
"python": "${workspaceFolder}/.venv/bin/python",
|
||||
"env": {
|
||||
"DEBUG": "False"
|
||||
},
|
||||
"args": [
|
||||
"runserver"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"django": true,
|
||||
"justMyCode": true
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ for information about how to create/update translations.
|
|||
|
||||
### Available languages
|
||||
|
||||
:brazil: Brazilian Portuguese, :es: Catalan, :cn: Chinese (simplified), :czech_republic: Czech, :denmark: Danish, :netherlands: Dutch, :uk: English (U.K.), :us: English (U.S.) _(base)_, :finland: Finnish, :fr: French, :de: German, :israel: Hebrew, :hungary: Hungarian, :it: Italian, :norway: Norwegian Bokmål, :poland: Polish, :portugal: Portuguese, :ru: Russian, :mexico: :es: Spanish, :sweden: Swedish, :tr: Turkish, :ukraine: Ukrainian
|
||||
:brazil: Brazilian Portuguese, :es: Catalan, :cn: Chinese (simplified), :czech*republic: Czech, :denmark: Danish, :netherlands: Dutch, :uk: English (U.K.), :us: English (U.S.) *(base)\_, :finland: Finnish, :fr: French, :de: German, :israel: Hebrew, :hungary: Hungarian, :it: Italian, :norway: Norwegian Bokmål, :poland: Polish, :portugal: Portuguese, :ru: Russian, :mexico: :es: Spanish, :sweden: Swedish, :tr: Turkish, :ukraine: Ukrainian
|
||||
|
||||
## 🌐 Baby Buddy on the Web
|
||||
|
||||
|
|
|
@ -1,9 +1,20 @@
|
|||
import os
|
||||
from distutils.util import strtobool
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from dotenv import load_dotenv, find_dotenv
|
||||
|
||||
|
||||
# Convert common string values to boolean.
|
||||
def strtobool(val):
|
||||
val = val.lower()
|
||||
if val in ("y", "yes", "t", "true", "on", "1"):
|
||||
return 1
|
||||
elif val in ("n", "no", "f", "false", "off", "0"):
|
||||
return 0
|
||||
else:
|
||||
raise ValueError("invalid truth value {!r}".format(val))
|
||||
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
|
|
209
devenv.lock
209
devenv.lock
|
@ -1,209 +0,0 @@
|
|||
{
|
||||
"nodes": {
|
||||
"devenv": {
|
||||
"locked": {
|
||||
"dir": "src/modules",
|
||||
"lastModified": 1694422554,
|
||||
"narHash": "sha256-s5NTPzT66yIMmau+ZGP7q9z4NjgceDETL4xZ6HJ/TBg=",
|
||||
"owner": "cachix",
|
||||
"repo": "devenv",
|
||||
"rev": "63d20fe09aa09060ea9ec9bb6d582c025402ba15",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"dir": "src/modules",
|
||||
"owner": "cachix",
|
||||
"repo": "devenv",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1673956053,
|
||||
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1653893745,
|
||||
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1685518550,
|
||||
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gitignore": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"pre-commit-hooks",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1660459072,
|
||||
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"mk-shell-bin": {
|
||||
"locked": {
|
||||
"lastModified": 1677004959,
|
||||
"narHash": "sha256-/uEkr1UkJrh11vD02aqufCxtbF5YnhRTIKlx5kyvf+I=",
|
||||
"owner": "rrbutani",
|
||||
"repo": "nix-mk-shell-bin",
|
||||
"rev": "ff5d8bd4d68a347be5042e2f16caee391cd75887",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "rrbutani",
|
||||
"repo": "nix-mk-shell-bin",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix2container": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1688922987,
|
||||
"narHash": "sha256-RnQwrCD5anqWfyDAVbfFIeU+Ha6cwt5QcIwIkaGRzQw=",
|
||||
"owner": "nlewo",
|
||||
"repo": "nix2container",
|
||||
"rev": "ab381a7d714ebf96a83882264245dbd34f0a7ec8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nlewo",
|
||||
"repo": "nix2container",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1694760568,
|
||||
"narHash": "sha256-3G07BiXrp2YQKxdcdms22MUx6spc6A++MSePtatCYuI=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "46688f8eb5cd6f1298d873d4d2b9cf245e09e88e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-stable": {
|
||||
"locked": {
|
||||
"lastModified": 1685801374,
|
||||
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-23.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"pre-commit-hooks": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"nixpkgs-stable": "nixpkgs-stable"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1694364351,
|
||||
"narHash": "sha256-oadhSCqopYXxURwIA6/Anpe5IAG11q2LhvTJNP5zE6o=",
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"rev": "4f883a76282bc28eb952570afc3d8a1bf6f481d7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"devenv": "devenv",
|
||||
"mk-shell-bin": "mk-shell-bin",
|
||||
"nix2container": "nix2container",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"pre-commit-hooks": "pre-commit-hooks"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
54
devenv.nix
54
devenv.nix
|
@ -1,54 +0,0 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
# https://devenv.sh/basics/
|
||||
env.DJANGO_SETTINGS_MODULE = "babybuddy.settings.development";
|
||||
|
||||
# https://devenv.sh/packages/
|
||||
packages = [
|
||||
pkgs.pipenv
|
||||
pkgs.nodejs_18
|
||||
pkgs.nodePackages.gulp
|
||||
pkgs.sqlite
|
||||
];
|
||||
|
||||
# https://devenv.sh/scripts/
|
||||
|
||||
enterShell = ''
|
||||
pipenv install --dev
|
||||
npm i
|
||||
gulp migrate
|
||||
'';
|
||||
|
||||
processes = {
|
||||
gulp.exec = "gulp";
|
||||
};
|
||||
|
||||
# https://devenv.sh/languages/
|
||||
languages.python.enable = true;
|
||||
languages.javascript = {
|
||||
enable = true;
|
||||
npm.install.enable = true;
|
||||
};
|
||||
|
||||
devcontainer = {
|
||||
enable = true;
|
||||
settings.customizations.vscode.settings."[python]".editor.defaultFormatter = "ms-python.black-formatter";
|
||||
settings.customizations.vscode.settings."[python]".pipenvPath = "pipenv";
|
||||
settings.customizations.vscode.extensions = [
|
||||
"bbenoist.Nix"
|
||||
"ms-python.python"
|
||||
"batisteo.vscode-django"
|
||||
"ms-python.black-formatter"
|
||||
];
|
||||
};
|
||||
|
||||
# services.nginx.enable = true;
|
||||
|
||||
pre-commit.hooks = {
|
||||
# format Python code
|
||||
black.enable = true;
|
||||
};
|
||||
|
||||
# See full reference at https://devenv.sh/reference/options/
|
||||
}
|
10
devenv.yaml
10
devenv.yaml
|
@ -1,10 +0,0 @@
|
|||
inputs:
|
||||
nixpkgs:
|
||||
url: github:NixOS/nixpkgs/nixpkgs-unstable
|
||||
nix2container:
|
||||
url: github:nlewo/nix2container
|
||||
inputs:
|
||||
nixpkgs:
|
||||
follows: nixpkgs
|
||||
mk-shell-bin:
|
||||
url: github:rrbutani/nix-mk-shell-bin
|
|
@ -77,46 +77,17 @@ information and steps below to set up a local development environment for Baby B
|
|||
Open [http://127.0.0.1:8000](http://127.0.0.1:8000) and log in with the default
|
||||
username and password (`admin`/`admin`).
|
||||
|
||||
## Alternative: https://devenv.sh/
|
||||
## Alternative: [Dev Container](https://containers.dev/)
|
||||
|
||||
1. Install devenv (linux/mac/windows subsystem for linux/docker) via https://devenv.sh/getting-started/
|
||||
1. git clone the repo
|
||||
1. here you have two options
|
||||
1. run `devenv shell` and then run `gulp`
|
||||
1. _OR_ run `devenv up` which automatically runs gulp/nodejs/python as well
|
||||
1. Open [http://127.0.0.1:8000](http://127.0.0.1:8000) and log in with the default
|
||||
username and password (`admin`/`admin`).
|
||||
1. Add Dev Container support to your preferred IDE: https://containers.dev/supporting
|
||||
2. Clone the Baby Buddy repo
|
||||
3. Open the cloned repo in the dev container
|
||||
|
||||
Devenv also generates the **.devcontainer for vscode**, and sets up **github codespaces support**. To run babybuddy in the devcontainer or codespaces, open a terminal after opening this repo in the devcontainer, which causes the dependencies to be installed via `devenv shell`. Then, run `gulp` to start the baby buddy server.
|
||||
Run `gulp` to start the Baby Buddy development server.
|
||||
|
||||
### Debugging in devenv + vscode
|
||||
### Debugging in VSCode
|
||||
|
||||
To debug in devenv + vscode/codespaces:
|
||||
|
||||
1. add a `.vscode/launch.json` file like this:
|
||||
|
||||
```json
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: Django",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/manage.py",
|
||||
"env": {
|
||||
"DEBUG": "False"
|
||||
},
|
||||
"args": ["runserver"],
|
||||
"django": true,
|
||||
"justMyCode": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
2. Consider running `gulp fake --children 5 --days 7` as explained in the [gulp command reference](./gulp-command-reference.md) to add some fake data to the database
|
||||
3. Click Run -> Start Debugging (F5) and set your breakpoints in the python as desired
|
||||
1. Copy `.vscode/launch.template.json` as `.vscode/launch.json` file like this:
|
||||
2. Click Run -> Start Debugging (F5) and set your breakpoints in the python as desired
|
||||
|
|
Loading…
Reference in New Issue