Use process-compose directly
This commit is contained in:
parent
bb2772cf67
commit
429a57d89a
|
@ -182,3 +182,4 @@ db_data
|
||||||
/result
|
/result
|
||||||
/static/
|
/static/
|
||||||
/.devenv/
|
/.devenv/
|
||||||
|
/process-compose.yml
|
||||||
|
|
59
dev.sh
59
dev.sh
|
@ -6,9 +6,30 @@ _init() {
|
||||||
python ./src/manage.py loaddata src/network_inventory.yaml
|
python ./src/manage.py loaddata src/network_inventory.yaml
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_open_url() {
|
||||||
|
if [[ ! -z "${DEFAULT_BROWSER}" ]]; then
|
||||||
|
$DEFAULT_BROWSER $url
|
||||||
|
elif type explorer.exe &>/dev/null; then
|
||||||
|
explorer.exe $url
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_create_url() {
|
||||||
|
if [ -f /etc/wsl.conf ]; then
|
||||||
|
echo "http://localhost:$WEBPORT"
|
||||||
|
else
|
||||||
|
echo "http://$(hostname -f):$WEBPORT"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Main tasks start
|
||||||
|
declare -A tasks
|
||||||
|
declare -A descriptions
|
||||||
|
|
||||||
# Setup the database
|
# Setup the database
|
||||||
_setup() {
|
setup() {
|
||||||
sleep 5
|
find . -name __pycache__ -o -name "*.pyc" -delete
|
||||||
if [ -f .direnv/first_run ]; then
|
if [ -f .direnv/first_run ]; then
|
||||||
python ./src/manage.py collectstatic --noinput
|
python ./src/manage.py collectstatic --noinput
|
||||||
python ./src/manage.py makemigrations
|
python ./src/manage.py makemigrations
|
||||||
|
@ -36,35 +57,15 @@ _setup() {
|
||||||
_init
|
_init
|
||||||
touch .direnv/first_run
|
touch .direnv/first_run
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
_open_url() {
|
|
||||||
if [[ ! -z "${DEFAULT_BROWSER}" ]]; then
|
|
||||||
$DEFAULT_BROWSER $url
|
|
||||||
elif type explorer.exe &>/dev/null; then
|
|
||||||
explorer.exe $url
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
_create_url() {
|
|
||||||
if [ -f /etc/wsl.conf ]; then
|
|
||||||
echo "http://localhost:$WEBPORT"
|
|
||||||
else
|
|
||||||
echo "http://$(hostname -f):$WEBPORT"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
#}
|
|
||||||
|
|
||||||
# Main tasks start
|
|
||||||
declare -A tasks
|
|
||||||
declare -A descriptions
|
|
||||||
|
|
||||||
run() {
|
|
||||||
_setup
|
|
||||||
find . -name __pycache__ -o -name "*.pyc" -delete
|
|
||||||
url=$(_create_url)
|
url=$(_create_url)
|
||||||
printf "\n---\n webserver: $url\n---\n"
|
printf "\n---\n webserver: $url\n---\n"
|
||||||
_open_url $url
|
_open_url $url sleep 5
|
||||||
|
}
|
||||||
|
descriptions["setup"]="Setup the database and load example data."
|
||||||
|
tasks["setup"]=setup
|
||||||
|
|
||||||
|
run() {
|
||||||
|
process-compose up
|
||||||
}
|
}
|
||||||
descriptions["run"]="Start the webserver."
|
descriptions["run"]="Start the webserver."
|
||||||
tasks["run"]=run
|
tasks["run"]=run
|
||||||
|
|
|
@ -15,9 +15,6 @@
|
||||||
forEachSystem = nixpkgs.lib.genAttrs (import systems);
|
forEachSystem = nixpkgs.lib.genAttrs (import systems);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages = forEachSystem (system: {
|
|
||||||
devenv-up = self.devShells.${system}.default.config.procfileScript;
|
|
||||||
});
|
|
||||||
devShells = forEachSystem
|
devShells = forEachSystem
|
||||||
(system:
|
(system:
|
||||||
let
|
let
|
||||||
|
@ -30,6 +27,10 @@
|
||||||
{
|
{
|
||||||
packages = [
|
packages = [
|
||||||
(pkgs.writeScriptBin "dev" "${builtins.readFile ./dev.sh}")
|
(pkgs.writeScriptBin "dev" "${builtins.readFile ./dev.sh}")
|
||||||
|
config = self.devShells.${system}.default.config;
|
||||||
|
enterShell = ''
|
||||||
|
ln -sf ${config.process-managers.process-compose.configFile} ${config.env.DEVENV_ROOT}/process-compose.yml
|
||||||
|
'';
|
||||||
];
|
];
|
||||||
env = {
|
env = {
|
||||||
DJANGO_SETTINGS_MODULE = "network_inventory.settings.local";
|
DJANGO_SETTINGS_MODULE = "network_inventory.settings.local";
|
||||||
|
@ -55,7 +56,7 @@
|
||||||
# https://github.com/cachix/devenv/blob/main/examples/process-compose/devenv.nix
|
# https://github.com/cachix/devenv/blob/main/examples/process-compose/devenv.nix
|
||||||
processes = {
|
processes = {
|
||||||
webserver.exec = "poetry run python ./src/manage.py runserver 0.0.0.0:$WEBPORT";
|
webserver.exec = "poetry run python ./src/manage.py runserver 0.0.0.0:$WEBPORT";
|
||||||
setup.exec = "dev start";
|
setup.exec = "dev setup";
|
||||||
};
|
};
|
||||||
services.postgres = {
|
services.postgres = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
Loading…
Reference in New Issue