From 9fe2bd20c72fad4e6bdec81284f1b7b1ffe03aa5 Mon Sep 17 00:00:00 2001 From: Dylan Knutson Date: Tue, 26 Nov 2024 20:29:47 -0800 Subject: [PATCH] Initial commit --- .cargo/config.toml | 2 ++ .devcontainer/.env | 12 +++++++++ .devcontainer/Dockerfile | 7 +++++ .devcontainer/devcontainer.json | 31 +++++++++++++++++++++ .devcontainer/docker-compose.yml | 46 ++++++++++++++++++++++++++++++++ .env | 1 + .github/dependabot.yml | 12 +++++++++ .vscode/settings.json | 8 ++++++ 8 files changed, 119 insertions(+) create mode 100644 .cargo/config.toml create mode 100644 .devcontainer/.env create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml create mode 100644 .env create mode 100644 .github/dependabot.yml create mode 100644 .vscode/settings.json diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..f4d28a3 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +rustflags = ["-C", "link-arg=-fuse-ld=lld"] diff --git a/.devcontainer/.env b/.devcontainer/.env new file mode 100644 index 0000000..ba4ba10 --- /dev/null +++ b/.devcontainer/.env @@ -0,0 +1,12 @@ +RUST_BACKTRACE=full +RUST_LIB_BACKTRACE=1 + +POSTGRES_USER=postgres +POSTGRES_PASSWORD=postgres +POSTGRES_DB=postgres +POSTGRES_HOSTNAME=localhost +POSTGRES_PORT=5432 +DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOSTNAME}:${POSTGRES_PORT}/${POSTGRES_DB} + +PGADMIN_DEFAULT_EMAIL=admin@example.com +PGADMIN_DEFAULT_PASSWORD=password diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..9ca17a6 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,7 @@ +FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye + +# Include lld linker to improve build times either by using environment variable +# RUSTFLAGS="-C link-arg=-fuse-ld=lld" or with Cargo's configuration file (i.e see .cargo/config.toml). +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install clang lld \ + && apt-get autoremove -y && apt-get clean -y diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..614e6da --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,31 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/rust-postgres +{ + "name": "Rust and PostgreSQL", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "features": { + "ghcr.io/meaningful-ooo/devcontainer-features/fish:1": {}, + "ghcr.io/warrenbuckley/codespace-features/sqlite:1": {}, + "ghcr.io/nikobockerman/devcontainer-features/fish-persistent-data:2": {} + }, + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [ + 80 + ], + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "cargo install diesel_cli", + // Configure tool-specific properties. + "customizations": { + "vscode": { + "extensions": [ + "inferrinizzard.prettier-sql-vscode" + ] + } + }, + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} \ No newline at end of file diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..acf55fd --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,46 @@ +version: '3.8' + +volumes: + devcontainer-scraper-rs-postgres-data: + devcontainer-scraper-rs-cargo-cache: + +services: + app: + build: + context: . + dockerfile: Dockerfile + env_file: + # Ensure that the variables in .env match the same variables in devcontainer.json + - .env + + volumes: + - ../..:/workspaces:cached + - devcontainer-scraper-rs-cargo-cache:/usr/local/cargo + + # Overrides default command so things don't shut down after the process ends. + command: sleep infinity + + # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. + network_mode: service:db + + # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + + db: + image: pgvector/pgvector:pg17 + restart: unless-stopped + volumes: + - devcontainer-scraper-rs-postgres-data:/var/lib/postgresql/data + env_file: + # Ensure that the variables in .env match the same variables in devcontainer.json + - .env + + # Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + + pgadmin: + image: dpage/pgadmin4:8.13.0 + restart: unless-stopped + network_mode: service:db + env_file: + - .env diff --git a/.env b/.env new file mode 100644 index 0000000..c152c23 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +RUST_LOG=debug \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f33a02c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for more information: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +# https://containers.dev/guide/dependabot + +version: 2 +updates: + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ad23e41 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "Prettier-SQL.commaPosition": "before", + "Prettier-SQL.expressionWidth": 30, + "Prettier-SQL.keywordCase": "upper", + "Prettier-SQL.SQLFlavourOverride": "postgresql", + "Prettier-SQL.logicalOperatorNewline": "before", + "Prettier-SQL.tabulateAlias": true, +} \ No newline at end of file