From b7d9d9e82ff0dfa764564d6f3cdf7016574c15b9 Mon Sep 17 00:00:00 2001 From: Ivar Flakstad <69173633+ivarflakstad@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:52:38 +0200 Subject: [PATCH 1/5] Docker install git because of dspy fork --- backend/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 7e400ec0..d99a74b2 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,8 +1,8 @@ # pull official base image -FROM python:3.11-slim +FROM python:3.11.8-slim # install system dependencies -RUN apt-get update && apt-get -y install libpq-dev gcc +RUN apt-get update && apt-get -y install libpq-dev gcc git # install python dependencies From afcf63e70b40d96590144417482ad92b09d9a08b Mon Sep 17 00:00:00 2001 From: Ivar Flakstad <69173633+ivarflakstad@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:53:26 +0200 Subject: [PATCH 2/5] Fix rust docker image --- server/Dockerfile | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/server/Dockerfile b/server/Dockerfile index 5a5c2044..d3f51784 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,22 +1,34 @@ -FROM lukemathwalker/cargo-chef:latest-rust-1.77-slim-bookworm as chef -WORKDIR /app +FROM rust:1.77 AS planner +WORKDIR app -FROM chef AS planner +RUN cargo install cargo-chef COPY . . -RUN cargo chef prepare --recipe-path recipe.json +RUN cargo chef prepare --recipe-path recipe.json -FROM chef AS builder -RUN apt-get update -y && apt-get install -y make perl +FROM rust:1.77 AS cacher +WORKDIR app +RUN cargo install cargo-chef COPY --from=planner /app/recipe.json recipe.json +# Build our project dependencies, not our application! RUN cargo chef cook --release --recipe-path recipe.json + +FROM rust:1.77 AS builder +WORKDIR app +COPY --from=cacher /app/target target +COPY --from=cacher /usr/local/cargo /usr/local/cargo COPY . . +COPY .sqlx .sqlx ENV SQLX_OFFLINE true RUN cargo build --release --bin server FROM debian:bookworm-slim AS runtime -WORKDIR /app +WORKDIR app +COPY config config COPY --from=builder /app/target/release/server /usr/local/bin -COPY ./config ./config +RUN apt-get update -y \ + && apt-get install -y --no-install-recommends openssl \ + # Clean up + && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* RUN useradd -u 1000 server @@ -24,4 +36,4 @@ USER server EXPOSE 3030 -CMD ["server"] +ENTRYPOINT ["/usr/local/bin/server"] From 4111c3e9a0119940bd2b7d1b7985a0b2faf4a566 Mon Sep 17 00:00:00 2001 From: AsmiKloud <163518413+AsmiKloud@users.noreply.github.com> Date: Thu, 11 Apr 2024 13:01:19 +0530 Subject: [PATCH 3/5] Create build_docker.yaml --- .github/workflows/build_docker.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/build_docker.yaml diff --git a/.github/workflows/build_docker.yaml b/.github/workflows/build_docker.yaml new file mode 100644 index 00000000..2f0b81d1 --- /dev/null +++ b/.github/workflows/build_docker.yaml @@ -0,0 +1,17 @@ +name: Build Docker Image + +on: + push: + branches: + - docker-fixes + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Build Docker Image + run: docker build -t curieo/search-rustserver:latest server/ From 039095482d28e04e2301538361ad0725ccca4ab2 Mon Sep 17 00:00:00 2001 From: Ivar Flakstad <69173633+ivarflakstad@users.noreply.github.com> Date: Thu, 11 Apr 2024 12:22:15 +0200 Subject: [PATCH 4/5] unignore sqlx query cache --- server/.gitignore | 3 - ...301acd854ff1669e6b6a70c81fd50c952e998.json | 72 ++++++++++++++++++ ...fe07202b5c5f4de22a80fd504364c130cb496.json | 74 +++++++++++++++++++ ...fc8a0a8686a250812fe534bce9bd610c15867.json | 72 ++++++++++++++++++ server/Dockerfile | 1 - 5 files changed, 218 insertions(+), 4 deletions(-) create mode 100644 server/.sqlx/query-29ef534c8dec3b0822559ee28a5301acd854ff1669e6b6a70c81fd50c952e998.json create mode 100644 server/.sqlx/query-a101d3708b8506c9af02ee42596fe07202b5c5f4de22a80fd504364c130cb496.json create mode 100644 server/.sqlx/query-a3300cb44e90f76b4f9acefc227fc8a0a8686a250812fe534bce9bd610c15867.json diff --git a/server/.gitignore b/server/.gitignore index a63b034d..9481ce52 100644 --- a/server/.gitignore +++ b/server/.gitignore @@ -27,6 +27,3 @@ target/ # MSVC Windows builds of rustc generate these, which store debugging information *.pdb - -# These will be created by the sqlx CLI -*.sqlx diff --git a/server/.sqlx/query-29ef534c8dec3b0822559ee28a5301acd854ff1669e6b6a70c81fd50c952e998.json b/server/.sqlx/query-29ef534c8dec3b0822559ee28a5301acd854ff1669e6b6a70c81fd50c952e998.json new file mode 100644 index 00000000..62b4158e --- /dev/null +++ b/server/.sqlx/query-29ef534c8dec3b0822559ee28a5301acd854ff1669e6b6a70c81fd50c952e998.json @@ -0,0 +1,72 @@ +{ + "db_name": "PostgreSQL", + "query": "select * from search_history where user_id = $1 order by created_at desc limit $2 offset $3", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "search_history_id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "user_id", + "type_info": "Uuid" + }, + { + "ordinal": 2, + "name": "session_id", + "type_info": "Uuid" + }, + { + "ordinal": 3, + "name": "query", + "type_info": "Text" + }, + { + "ordinal": 4, + "name": "result", + "type_info": "Text" + }, + { + "ordinal": 5, + "name": "sources", + "type_info": "TextArray" + }, + { + "ordinal": 6, + "name": "reaction", + "type_info": "Bool" + }, + { + "ordinal": 7, + "name": "created_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 8, + "name": "updated_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Int8" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + false, + true, + false, + false + ] + }, + "hash": "29ef534c8dec3b0822559ee28a5301acd854ff1669e6b6a70c81fd50c952e998" +} diff --git a/server/.sqlx/query-a101d3708b8506c9af02ee42596fe07202b5c5f4de22a80fd504364c130cb496.json b/server/.sqlx/query-a101d3708b8506c9af02ee42596fe07202b5c5f4de22a80fd504364c130cb496.json new file mode 100644 index 00000000..69763604 --- /dev/null +++ b/server/.sqlx/query-a101d3708b8506c9af02ee42596fe07202b5c5f4de22a80fd504364c130cb496.json @@ -0,0 +1,74 @@ +{ + "db_name": "PostgreSQL", + "query": "insert into search_history (user_id, session_id, query, result, sources) values ($1, $2, $3, $4, $5) returning *", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "search_history_id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "user_id", + "type_info": "Uuid" + }, + { + "ordinal": 2, + "name": "session_id", + "type_info": "Uuid" + }, + { + "ordinal": 3, + "name": "query", + "type_info": "Text" + }, + { + "ordinal": 4, + "name": "result", + "type_info": "Text" + }, + { + "ordinal": 5, + "name": "sources", + "type_info": "TextArray" + }, + { + "ordinal": 6, + "name": "reaction", + "type_info": "Bool" + }, + { + "ordinal": 7, + "name": "created_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 8, + "name": "updated_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Text", + "Text", + "TextArray" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + false, + true, + false, + false + ] + }, + "hash": "a101d3708b8506c9af02ee42596fe07202b5c5f4de22a80fd504364c130cb496" +} diff --git a/server/.sqlx/query-a3300cb44e90f76b4f9acefc227fc8a0a8686a250812fe534bce9bd610c15867.json b/server/.sqlx/query-a3300cb44e90f76b4f9acefc227fc8a0a8686a250812fe534bce9bd610c15867.json new file mode 100644 index 00000000..bd83e33b --- /dev/null +++ b/server/.sqlx/query-a3300cb44e90f76b4f9acefc227fc8a0a8686a250812fe534bce9bd610c15867.json @@ -0,0 +1,72 @@ +{ + "db_name": "PostgreSQL", + "query": "update search_history set reaction = $1 where search_history_id = $2 and user_id = $3 returning *", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "search_history_id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "user_id", + "type_info": "Uuid" + }, + { + "ordinal": 2, + "name": "session_id", + "type_info": "Uuid" + }, + { + "ordinal": 3, + "name": "query", + "type_info": "Text" + }, + { + "ordinal": 4, + "name": "result", + "type_info": "Text" + }, + { + "ordinal": 5, + "name": "sources", + "type_info": "TextArray" + }, + { + "ordinal": 6, + "name": "reaction", + "type_info": "Bool" + }, + { + "ordinal": 7, + "name": "created_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 8, + "name": "updated_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Bool", + "Uuid", + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + false, + true, + false, + false + ] + }, + "hash": "a3300cb44e90f76b4f9acefc227fc8a0a8686a250812fe534bce9bd610c15867" +} diff --git a/server/Dockerfile b/server/Dockerfile index d3f51784..2a7a6080 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -17,7 +17,6 @@ WORKDIR app COPY --from=cacher /app/target target COPY --from=cacher /usr/local/cargo /usr/local/cargo COPY . . -COPY .sqlx .sqlx ENV SQLX_OFFLINE true RUN cargo build --release --bin server From 68307a974da3384a53fbf8f7330a577c49033559 Mon Sep 17 00:00:00 2001 From: Ivar Flakstad <69173633+ivarflakstad@users.noreply.github.com> Date: Thu, 11 Apr 2024 12:40:41 +0200 Subject: [PATCH 5/5] update actions/checkout to v4 --- .github/workflows/build_docker.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_docker.yaml b/.github/workflows/build_docker.yaml index 2f0b81d1..09ee1143 100644 --- a/.github/workflows/build_docker.yaml +++ b/.github/workflows/build_docker.yaml @@ -10,8 +10,8 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@v2 + - name: Checkout Repository + uses: actions/checkout@v4 - - name: Build Docker Image - run: docker build -t curieo/search-rustserver:latest server/ + - name: Build Docker Image + run: docker build -t curieo/search-rustserver:latest server/