Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Banjofox/build scripts #303

Merged
merged 14 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 28 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions aardwolf-models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ strum = "0.25.0"
strum_macros = "0.25.1"
thiserror = "1.0"
url = "2.1"
dotenv="0.15"
dotenvy ="0.15"
BanjoFox marked this conversation as resolved.
Show resolved Hide resolved


[dependencies.uuid]
version = "1.3"
Expand All @@ -36,4 +37,4 @@ features = ["chrono", "postgres", "serde_json", "uuid"]

[dev-dependencies]
env_logger = "0.10"
serde_derive = "1.0"
serde_derive = "1.0"
BanjoFox marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions aardwolf-models/examples/local_user_auth.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate aardwolf_models;
extern crate diesel;
extern crate dotenv;
extern crate dotenvy;
extern crate env_logger;
extern crate serde;
#[macro_use]
Expand All @@ -16,7 +16,7 @@ use aardwolf_models::user::{
NewUser, UnauthenticatedUser, UserLike,
};
use diesel::{pg::PgConnection, prelude::*};
use dotenv::dotenv;
use dotenvy::dotenv;

#[derive(Deserialize)]
struct Payload {
Expand Down
2 changes: 1 addition & 1 deletion aardwolf-models/src/test_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::env;
use chrono::{offset::Utc, DateTime, Duration as OldDuration};
use chrono_tz::Tz;
use diesel::{pg::PgConnection, Connection};
use dotenv::dotenv;
use dotenvy::dotenv;
use mime::TEXT_PLAIN;
use openssl::rsa::Rsa;
use rand::{distributions::Alphanumeric, rngs::OsRng, Rng};
Expand Down
3 changes: 0 additions & 3 deletions aardwolf-templates/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ path = "../aardwolf-types"
version = "0.1"
path = "../aardwolf-models"

[dev-dependencies]
ructe = "0.16"

#-
# Start of Yew Migration?
[dependencies.aardwolf-yew-frontend]
Expand Down
10 changes: 0 additions & 10 deletions db-init.sh
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
#!/bin/bash
set -e
echo "Creating DB"
psql <<- EOSQL
CREATE USER aardwolf_user;
CREATE DATABASE aardwolf;
GRANT ALL PRIVILEGES ON DATABASE aardwolf_user TO aardwolf;
EOSQL
echo "Done Creating DB"

62 changes: 62 additions & 0 deletions dev-setup/debian-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

# First we should go home
cd ~/

# Add PostgreSQL's repository to your system:
echo "Adding PostgreSQL's repository to your system..."
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

# Import the repository signing key:
echo "Importing the PostgreSQL's repository signing key..."
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

# Update the package lists:
echo "Updating package lists..."
sudo apt update

# Install Rust build tools and dependencies:
echo "Installing development tools and dependencies..."
sudo apt install -y build-essential libssl-dev pkg-config gettext gcc g++ curl git

# Install PostgreSQL:
echo "Installing PostgreSQL..."
sudo apt install postgresql libpq-dev

# Install Rust:
echo "Installing Rust..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Install Rust toolchain:
echo "Installing Rust stable toolchain..."
rustup install stable

# Install Rust tools:
echo "Installing Rust tools..."
rustup component add rustfmt clippy cargo-watch
cargo install diesel_cli --no-default-features --features "postgres"

# Setup PostgreSQL
echo "Setting up PostgreSQL..."
sudo systemctl enable postgresql.service
sudo systemctl start postgresql.service

# Create the aardwolf database
DB_NAME=aardwolf
DB_USER=aardwolf_user
DB_PASS=changeme

sudo -u postgres psql -c "CREATE DATABASE $DB_NAME;"
sudo -u postgres psql -c "CREATE DATABASE ${DB_NAME}_testing;"
sudo -u postgres psql -c "CREATE USER $DB_USER WITH PASSWORD '$DB_PASS';"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE aardwolf TO aardwolf_user;"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE aardwolf_testing TO aardwolf_user;"

# Set up environment variables for database URLs
echo "Setting up environment variables..."
echo "DATABASE_URL=postgresql://aardwolf_user:[email protected]:5432/aardwolf" > ~/aardwolf/.env
echo "TEST_DATABASE_URL=postgresql://aardwolf_user:[email protected]:5432/aardwolf_testing" >> ~/aardwolf/.env

# Setup aardwolf
echo "Setting up aardwolf..."
cargo run --bin setup
51 changes: 51 additions & 0 deletions dev-setup/macos-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

# Update the package lists:
echo "Updating package lists..."
brew update

# Install PostgreSQL:
echo "Installing PostgreSQL..."
brew install postgres

# Start PostgreSQL, and create default user:
brew service start postgresql@15
/usr/local/opt/postgresql@15/bin/createuser -s postgres

# Install Rust:
echo "Installing Rust..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Install Rust toolchain:
echo "Installing Rust stable toolchain..."
rustup install stable

# Set RUSTFLAGS to point linker to libpq
echo "Setting RUSTFLAGS for libpq..."
brew link postgresql@15
export RUSTFLAGS="-L/usr/local/opt/postgresql@15/lib"

# Install Rust tools:
echo "Installing Rust tools..."
rustup component add rustfmt clippy
cargo instal diesel_cli --no-default-features --features "postgres"

# Create the aardwolf database
echo "Creating the aardwolf database..."
DB_NAME=aardwolf
DB_USER=aardwolf_user
DB_PASS=changeme

sudo -u postgres psql -c "CREATE DATABASE $DB_NAME;"
sudo -u postgres psql -c "CREATE DATABASE ${DB_NAME}_testing;"
sudo -u postgres psql -c "CREATE USER $DB_USER WITH PASSWORD '$DB_PASS';"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE aardwolf_testing TO aardwolf_user;"

# Set up environment variables for database URLs
echo "Setting up environment variables..."
echo "DATABASE_URL=postgresql://aardwolf_user:[email protected]:5432/aardwolf" > ~/aardwolf/.env
echo "TEST_DATABASE_URL=postgresql://aardwolf_user:[email protected]:5432/aardwolf_testing" >> ~/aardwolf/.env

# Setup aardwolf
echo "Setting up aardwolf..."
cargo run --bin setup
14 changes: 10 additions & 4 deletions doc/AARDWOLF-SETUP.MD
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ Then, download the [rustup installer](https://www.rust-lang.org/en-US/install.ht

### Install Rust Toolchain

Once you have `rustup` installed, make sure you have the `nightly` rust
Once you have `rustup` installed, make sure you have the `stable` rust
toolchain installed:

nicholasguyett marked this conversation as resolved.
Show resolved Hide resolved
$ rustup toolchain install nightly
$ rustup toolchain install stable

### Install Rust Toolchain Components

(Optional) - These tools are useful for development and testing

$ rustup component add rustfmt clippy cargo-watch

### Installing Rust database functionality

Expand All @@ -65,9 +71,9 @@ among other things.

To install it, run the following command:

$ cargo +nightly install -f diesel_cli --no-default-features --features "postgres"
$ cargo install diesel_cli --no-default-features --features "postgres"

This command will use the `nightly` version of `cargo` (the rust package
This command will use the `stable` version of `cargo` (the rust package
manager) to install the newest version of the `diesel_cli` crate. The
`--no-default-features --features "postgres"` options tell `cargo` to
skip installing the `mysql` and `sqlite` parts of `diesel`, which
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion doc/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ error: could not compile `aardwolf` (bin "aardwolf-server" test) due to previous
**Resolution:**
The key here after the wall of text --> `note: ld: library not found for -lpq`. The `lpq` package is normally installed as part of PostgreSQL (Lib PQ)

Debian/Ubunutu: `apt install libpq`
Debian/Ubuntu: `apt install libpq-dev`
Mac OS (Homebrew):
- Option 1: Install complete Postgres: `brew install postgres`
- Option 2: Install the libpq library only, and use `RUSTFLAGS="-L /usr/local/opt/libpq/lib" cargo [command] [package-name]`
Loading
Loading