diff --git a/docker-compose.yml b/docker-compose.yml index 36f8ddb..a2b7d4c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,8 +2,6 @@ services: homepage: image: nginx:alpine container_name: homepage - ports: - - "9000:80" volumes: - ./dist:/usr/share/nginx/html restart: unless-stopped diff --git a/shell.nix b/shell.nix index 76aa2d1..7e5686c 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,4 @@ -{ pkgs ? import {} }: +{ pkgs ? import {}, isDev ? true, restartRemote ? false, remoteHost ? "hetzner" }: pkgs.mkShell { packages = with pkgs; [ @@ -7,19 +7,31 @@ pkgs.mkShell { python312Packages.virtualenv ]; - shellHook = '' + shellHook = let + venvPath = "$HOME/venv/homepage"; + in '' export PIP_REQUIRE_VIRTUALENV=1 - export VENV_PATH=$HOME/venv/homepage + export VENV_PATH=${venvPath} if [ ! -d $VENV_PATH ]; then python -m venv $VENV_PATH fi source $VENV_PATH/bin/activate pip install -r requirements.txt - pip install watchdog + + ${if isDev then '' + pip install watchdog + python watch.py + '' else '' + python parser/md.py + python generate.py - python parser/md.py - python generate.py - python watch.py + rsync -avP --delete ./dist/ ${remoteHost}:/root/homepage/dist + rsync -avP ./docker-compose.yml ${remoteHost}:/root/homepage/ + + ${if restartRemote then '' + ssh ${remoteHost} "cd /root/homepage && docker compose down && docker compose up -d" + '' else ""} + ''} ''; } diff --git a/sync.sh b/sync.sh deleted file mode 100644 index 11e859c..0000000 --- a/sync.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -REMOTE_HOST=hetzner - -python parser/md.py -python generate.py -rsync -avP --delete ./dist/ ${REMOTE_HOST}:/root/homepage/dist -rsync -avP ./docker-compose.yml ${REMOTE_HOST}:/root/homepage/ - -if [ "$1" = "--restart" ]; then - ssh ${REMOTE_HOST} "cd /root/homepage && docker compose down && docker compose up -d" -fi