diff --git a/search-engine/Dockerfile b/search-engine/Dockerfile new file mode 100644 index 0000000..f6e6992 --- /dev/null +++ b/search-engine/Dockerfile @@ -0,0 +1,48 @@ +FROM rustlang/rust:nightly-alpine AS builder + +RUN apk add --no-cache \ + musl-dev \ + openssl-dev \ + openssl-libs-static \ + pkgconfig \ + postgresql-dev + +ENV OPENSSL_STATIC=1 +ENV OPENSSL_DIR=/usr +ENV PKG_CONFIG_ALLOW_CROSS=1 + +WORKDIR /app + +COPY protocol/library ../protocol/library +COPY search-engine/Cargo.toml ./ +COPY search-engine/src ./src + +RUN cargo build --release + +FROM alpine:3.19 + +RUN apk add --no-cache \ + ca-certificates \ + postgresql-client \ + wget + +RUN addgroup -g 1001 -S appgroup && \ + adduser -u 1001 -S appuser -G appgroup + +WORKDIR /app + +COPY --from=builder /app/target/release/gurted-search-engine /app/gurted-search-engine +COPY search-engine/frontend ./frontend + +RUN mkdir -p /app/config /app/data /app/search_indexes /app/certs && \ + chown -R appuser:appgroup /app + +USER appuser + +EXPOSE 8081 + +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:8081/health || exit 1 + +# Default command - runs the server subcommand +CMD ["./gurted-search-engine", "--config", "/app/config/config.toml", "server"] \ No newline at end of file diff --git a/search-engine/build.sh b/search-engine/build.sh new file mode 100644 index 0000000..d55d24e --- /dev/null +++ b/search-engine/build.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +echo "Building Gurted Search Engine Server..." + +echo "Stopping existing container..." +docker compose down + +echo "Building Docker image..." +docker compose build --no-cache --parallel + +echo "Starting services..." +docker compose up -d + +echo "Container logs (press Ctrl+C to stop following):" +docker compose logs -f search-engine \ No newline at end of file diff --git a/search-engine/docker-compose.yml b/search-engine/docker-compose.yml new file mode 100644 index 0000000..817d9e8 --- /dev/null +++ b/search-engine/docker-compose.yml @@ -0,0 +1,14 @@ +services: + search-engine: + build: + context: .. + dockerfile: search-engine/Dockerfile + container_name: gurted-search-engine + network_mode: host + environment: + RUST_LOG: info + volumes: + - ./config.toml:/app/config/config.toml:ro + - ./search_indexes:/app/search_indexes + - ./certs:/app/certs:ro + restart: unless-stopped \ No newline at end of file