# whiteduck default project template

The default template with the recommended whiteduck python tech stack.

## Description

This template provides boilerplate for a small shiny application, with everything needed to get going quickly.

- deployment via docker
- quick run powershell and bash script
- vscode settings for debugging and formatting
- Classic modular service-based app architecture/structure
- Dependency Injection Container
- Appsettings support
- logging preconfigured

## Requirements

- **poetry**: https://python-poetry.org/docs/#installation
- **miniconda**(recommended): https://docs.anaconda.com/miniconda/miniconda-install/

`setup_and_run`scripts will install both

## Libraries Used

Following libraries are part of this template

- **Shiny package**: `shiny`, `shinyswatch`, `shiny-validate`, `shinywidgets` for all things shiny
- **loguru**: Logging
- **pendulum**: Datetime handling without insanity
- **python-decouple**: Appsettings
- **pandas**: Dateframes and tables

Following libraries are getting installed as dev environment

- **ruff**: Linting, formatting, all in one
- **pytest**: Test framework


## Run

a) Open in VSCode Press `F5`

b) `python app.py`

c) Run `setup_and_run.ps1` or `setup_and_run.sh`

## Static web app

Because why not, shiny apps are also deployable as static web sites on servers that don't even have python support

Export static website with shinylive

```
shinylive export . site
```

Host with IIS or your favorite http-server

```
python3 -m http.server --directory site 8008
```

## Docker


### Local Docker
```
poetry lock # only if no poetry.lock doesn't exist
docker build -t whiteduck .
docker run --rm -p 8000:8000 whiteduck
```

### Deploy to Azure Container Registry

#### Login
```
az login
az account set --subscription xxx
```

#### Create ACR (nur wenn noch nicht erstellt)
```
az acr create --resource-group MY_RESSOURCE_GROUP --name WHITEDUCK --sku Basic
```

#### Login to ACR
```
az acr login -n WHITEDUCK
```

#### Tag and Push
```
docker build -t whiteduck .
docker tag whiteduck whiteduck.azurecr.io/whiteduck:latest
docker push whiteduck.azurecr.io/whiteduck:latest
```
