# Bid Scheduler
----------------------------------------
# Dev Setup
1. Install Docker (Desktop for Mac & Windows)
    1. If using Windows, make sure there are no available updates
    1. If using Windows, then follow [this guide](https://docs.microsoft.com/en-us/windows/wsl/install-win10) to turn on WSL 2
1. Install the [Remote Development](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) VSCode Extension
1. Clone the repo and open VSCode there
1. On opening VSCode there should be a prompt asking to open the project in a container
1. Open the project in the container, and wait a bit for it all to be set up

# Running dev-server
1. Launch VSCode and open the project, there should've been a prompt asking to open in a container
1. Click the prompt and wait to be inside the container, you'll know this happened once you can open a `zsh` shell and see the file in `/workspace`
1. Run `cargo run` to run the server, this can be done in `/workspace` or any of its subdirectories.
1. In another terminal switch to the `frontend` folder and run either `npm run-script build` or `npm start`
    1. If you ran `npm run-script build`, the server should be accesible when you control click the link in the `🚀 Rocket has launched from http://localhost:8000` message.
    1. If you ran `npm start`, got to `http://localhost:3000`.

# Setting up email service
1. PSB uses an smtp based email system that requires configuration during installation
1. To configure the email system, visit the Rocket.toml file and fill out each field
    1. server: Required by SMTP. This field determines what host emails are sent to. This should be just the hostname. As an example: google.com
        1. For testing purposes, the developer can use an smtp test suite like mailtrap.
    1. username: Required by SMTP, this is the username used to log into your email service
    1. password: Required by SMTP, This is the password for the username required to log into your email service.
    1. port: Required by SMTP. This field determines the port that your SMTP message will be forwarded to. Usually 25, 587, or 2525.
    1. sender: The email address that the messages will come from.
    1. schedule_reminder_list: Optional list of fields that determines cc address for schedule reminder emails. Leave blank if schedule reminders should not be cc'd to anyone
    1. selection_end_list: Optional list of emails that will receive a notification when a selection ends. Leave blank if this functionality is not wanted.
    1. schedule_end_list: Optional list of emails that will receive a notification when a schedule ends. Leave blank if this functionality is not wanted.
    1. starttls: Determines if email connection should be established over starttls or tls. Defaults to false for TLS
    1. url: The address of the machine running the service. ie: http://localhost:8000 or http://127.0.0.1

# Building the Release Bundle
1. Open the project on VSCode
1. Make a folder for the release bundle
1. Make a `public` folder inside the release bundle folder
1. Copy `Rocket.toml`, `Dockerfile`, and `docker-compose.yml` to the release bundle folder
1. Run `cargo build --release`
1. Copy the `server` executable from `/workspace/target/release/` to the release bundle folder
1. Enter the `frontend` folder
1. Run `npm run-script build`
1. Leave the `frontend` folder
1. Copy the contents of the `public` folder inside of the `server` folder into the `public` folder in the release bundle folder
1. Zip the release bundle folder.

# Deploying the Release Bundle
1. Get a release bundle
1. Unzip the release bundle
1. Go into the folder which has the contents of the release bundle
1. Run `docker-compose up -d`
