diff --git a/.sqlx/query-4e27c5a65eddddc6e4e8e416da9717d5e618266ddeae440a6298ee3e6c74afa8.json b/.sqlx/query-4e27c5a65eddddc6e4e8e416da9717d5e618266ddeae440a6298ee3e6c74afa8.json new file mode 100644 index 0000000..bb9df73 --- /dev/null +++ b/.sqlx/query-4e27c5a65eddddc6e4e8e416da9717d5e618266ddeae440a6298ee3e6c74afa8.json @@ -0,0 +1,28 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT id, author_id\n FROM proposals\n WHERE id = $1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int4" + }, + { + "ordinal": 1, + "name": "author_id", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Int4" + ] + }, + "nullable": [ + false, + false + ] + }, + "hash": "4e27c5a65eddddc6e4e8e416da9717d5e618266ddeae440a6298ee3e6c74afa8" +} diff --git a/.sqlx/query-4e9ee3214db6178565dbcd05e7bb8b04c1f0d140104e1593b8a38b7a67dca7c1.json b/.sqlx/query-4e9ee3214db6178565dbcd05e7bb8b04c1f0d140104e1593b8a38b7a67dca7c1.json new file mode 100644 index 0000000..963cd6d --- /dev/null +++ b/.sqlx/query-4e9ee3214db6178565dbcd05e7bb8b04c1f0d140104e1593b8a38b7a67dca7c1.json @@ -0,0 +1,34 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO proposal_snapshots (\n proposal_id,\n block_height,\n ts,\n editor_id,\n social_db_post_block_height,\n labels,\n proposal_version,\n proposal_body_version,\n name,\n category,\n summary,\n description,\n linked_proposals,\n linked_rfp,\n requested_sponsorship_usd_amount,\n requested_sponsorship_paid_in_currency,\n requested_sponsor,\n receiver_account,\n supervisor,\n timeline,\n views\n ) VALUES (\n $1, $2, $3, $4, $5, $6, $7, $8,\n $9, $10, $11, $12, $13, $14,\n $15, $16, $17, $18, $19, $20, $21\n ) ON CONFLICT (proposal_id, ts) DO UPDATE SET\n block_height = $2,\n editor_id = $4,\n social_db_post_block_height = $5,\n labels = $6,\n proposal_version = $7,\n proposal_body_version = $8,\n name = $9,\n category = $10,\n summary = $11,\n description = $12,\n linked_proposals = $13,\n linked_rfp = $14,\n requested_sponsorship_usd_amount = $15,\n requested_sponsorship_paid_in_currency = $16,\n requested_sponsor = $17,\n receiver_account = $18,\n supervisor = $19,\n timeline = $20,\n views = $21\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int4", + "Int8", + "Int8", + "Varchar", + "Int8", + "Jsonb", + "Varchar", + "Varchar", + "Text", + "Varchar", + "Text", + "Text", + "Jsonb", + "Int4", + "Int4", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Jsonb", + "Int4" + ] + }, + "nullable": [] + }, + "hash": "4e9ee3214db6178565dbcd05e7bb8b04c1f0d140104e1593b8a38b7a67dca7c1" +} diff --git a/.sqlx/query-6b4e4a2e8ba4a7acc740015d1a602978868b21b3f9e211ec824964241b65616c.json b/.sqlx/query-6b4e4a2e8ba4a7acc740015d1a602978868b21b3f9e211ec824964241b65616c.json new file mode 100644 index 0000000..484e788 --- /dev/null +++ b/.sqlx/query-6b4e4a2e8ba4a7acc740015d1a602978868b21b3f9e211ec824964241b65616c.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE rfps SET author_id = $1 WHERE id = $2\n RETURNING id\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Varchar", + "Int4" + ] + }, + "nullable": [ + false + ] + }, + "hash": "6b4e4a2e8ba4a7acc740015d1a602978868b21b3f9e211ec824964241b65616c" +} diff --git a/.sqlx/query-93c3ea57599a2ff19b025f98bb351746d9d5e2dca9632a608632cd897fcf5421.json b/.sqlx/query-93c3ea57599a2ff19b025f98bb351746d9d5e2dca9632a608632cd897fcf5421.json new file mode 100644 index 0000000..79799a5 --- /dev/null +++ b/.sqlx/query-93c3ea57599a2ff19b025f98bb351746d9d5e2dca9632a608632cd897fcf5421.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE proposals SET author_id = $1 WHERE id = $2\n RETURNING id\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Varchar", + "Int4" + ] + }, + "nullable": [ + false + ] + }, + "hash": "93c3ea57599a2ff19b025f98bb351746d9d5e2dca9632a608632cd897fcf5421" +} diff --git a/.sqlx/query-9496950dbb64351b32b320720014df7c2fc6c2ba9523c3d2d261d58d3e9bade6.json b/.sqlx/query-9496950dbb64351b32b320720014df7c2fc6c2ba9523c3d2d261d58d3e9bade6.json new file mode 100644 index 0000000..f5a4161 --- /dev/null +++ b/.sqlx/query-9496950dbb64351b32b320720014df7c2fc6c2ba9523c3d2d261d58d3e9bade6.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO rfps (id, author_id)\n VALUES ($1, $2)\n ON CONFLICT (id) DO NOTHING\n RETURNING id\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Int4", + "Varchar" + ] + }, + "nullable": [ + false + ] + }, + "hash": "9496950dbb64351b32b320720014df7c2fc6c2ba9523c3d2d261d58d3e9bade6" +} diff --git a/.sqlx/query-9f175e11a61077053db3b2fbbdd668f76628df37f965633a3f1daf35ac3f6ff1.json b/.sqlx/query-9f175e11a61077053db3b2fbbdd668f76628df37f965633a3f1daf35ac3f6ff1.json new file mode 100644 index 0000000..a1ed1b4 --- /dev/null +++ b/.sqlx/query-9f175e11a61077053db3b2fbbdd668f76628df37f965633a3f1daf35ac3f6ff1.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT after_date FROM after_date\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "after_date", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false + ] + }, + "hash": "9f175e11a61077053db3b2fbbdd668f76628df37f965633a3f1daf35ac3f6ff1" +} diff --git a/.sqlx/query-c5e0f339e624d5f3ee4c138ff70e23adfdb644ce39e9e86765250fe92516a10c.json b/.sqlx/query-c5e0f339e624d5f3ee4c138ff70e23adfdb644ce39e9e86765250fe92516a10c.json new file mode 100644 index 0000000..1311f06 --- /dev/null +++ b/.sqlx/query-c5e0f339e624d5f3ee4c138ff70e23adfdb644ce39e9e86765250fe92516a10c.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO proposals (id, author_id)\n VALUES ($1, $2)\n ON CONFLICT (id) DO NOTHING\n RETURNING id\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Int4", + "Varchar" + ] + }, + "nullable": [ + false + ] + }, + "hash": "c5e0f339e624d5f3ee4c138ff70e23adfdb644ce39e9e86765250fe92516a10c" +} diff --git a/.sqlx/query-cb41d33b41fdfecc3ee8f19cc4742b7c29890ee26f9be729dbd603b94a0e4545.json b/.sqlx/query-cb41d33b41fdfecc3ee8f19cc4742b7c29890ee26f9be729dbd603b94a0e4545.json new file mode 100644 index 0000000..4f2f779 --- /dev/null +++ b/.sqlx/query-cb41d33b41fdfecc3ee8f19cc4742b7c29890ee26f9be729dbd603b94a0e4545.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE after_date SET after_date = $1\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "cb41d33b41fdfecc3ee8f19cc4742b7c29890ee26f9be729dbd603b94a0e4545" +} diff --git a/Dockerfile b/Dockerfile index 28c4423..99f6ee5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,55 @@ -FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef +# --- Cargo Chef Stage (for caching dependencies) --- +FROM rust:1.78.0-bookworm as chef WORKDIR /app - -FROM chef AS planner +RUN cargo install cargo-chef COPY . . RUN cargo chef prepare --recipe-path recipe.json -FROM chef AS builder -COPY --from=planner /app/recipe.json recipe.json -# Build dependencies - this is the caching Docker layer! +# --- Dependency Caching Stage --- +FROM chef as cache +WORKDIR /app + +RUN apt-get update -y && apt-get install -y \ + libssl-dev \ + ca-certificates \ + libudev-dev \ + libusb-1.0-0-dev \ + pkg-config \ + libudev-dev \ + build-essential + +COPY --from=chef /app/recipe.json recipe.json RUN cargo chef cook --release --recipe-path recipe.json -# Build application + +# --- Application Build Stage --- +FROM cache as builder +WORKDIR /app +RUN apt-get update -y && apt-get install -y \ + libssl-dev \ + ca-certificates \ + libudev-dev \ + libusb-1.0-0-dev \ + pkg-config \ + libudev-dev \ + build-essential COPY . . -RUN cargo build --release --bin devhub-cache-api +COPY --from=cache /app/target target +ENV SQLX_OFFLINE=true +RUN cargo build --release -# We do not need the Rust toolchain to run the binary! -FROM debian:bookworm-slim AS runtime +# --- Final Stage with Minimal Base Image --- +FROM debian:bookworm-slim +RUN apt-get update -y && apt-get install -y \ + libssl-dev \ + ca-certificates \ + libudev-dev \ + libusb-1.0-0-dev \ + pkg-config \ + libudev-dev \ + build-essential +RUN useradd -ms /bin/bash app +USER app WORKDIR /app -COPY --from=builder /app/target/release/devhub-cache-api /usr/local/bin -ENTRYPOINT ["/usr/local/bin/devhub-cache-api"] +COPY --from=builder /app/target/release/devhub-cache-api . +EXPOSE 8000 +CMD ["./devhub-cache-api"] diff --git a/fly.toml b/fly.toml index 1e8c016..1f46723 100644 --- a/fly.toml +++ b/fly.toml @@ -1,20 +1,15 @@ -# fly.toml app configuration file generated for devhub-cache-api-rs on 2024-10-29T10:00:35-05:00 +# fly.toml app configuration file generated for devhub-cache-api-rs on 2024-11-06T08:54:33+07:00 # # See https://fly.io/docs/reference/configuration/ for information about how to use this file. # app = 'devhub-cache-api-rs' -primary_region = 'dfw' +primary_region = 'ams' [build] -[env] - PORT = '8080' - ROCKET_ADDRESS = '0.0.0.0' - ROCKET_PORT = '8080' - [http_service] - internal_port = 8080 + internal_port = 8000 force_https = true auto_stop_machines = 'stop' auto_start_machines = true