From b3322636a9c411dd1a9b09001995ff0029c7ce9c Mon Sep 17 00:00:00 2001 From: Xevion Date: Sat, 13 Sep 2025 15:47:43 -0500 Subject: [PATCH] feat: setup frontend build code, tune .dockerignore patterns also removed diesel.toml --- .dockerignore | 68 +++++++-------------------------------------------- Dockerfile | 36 ++++++++++++++++++++++++--- diesel.toml | 9 ------- 3 files changed, 41 insertions(+), 72 deletions(-) delete mode 100644 diesel.toml diff --git a/.dockerignore b/.dockerignore index c78f4ed..e3156ee 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,72 +2,22 @@ target/ **/target/ -# Development files -.env -.env.local -.env.*.local - -# IDE and editor files -.vscode/ -.idea/ -*.swp -*.swo -*~ - -# OS generated files -.DS_Store -.DS_Store? -._* -.Spotlight-V100 -.Trashes -ehthumbs.db -Thumbs.db - -# Git -.git/ -.gitignore - # Documentation README.md docs/ *.md -# Go files (since this is a Rust project) +# Old Go codebase go/ -# Database migrations (if not needed at runtime) -migrations/ -diesel_migrations/ -diesel.toml - # Development configuration bacon.toml -.cargo/config.toml +.env -# Logs -*.log -logs/ - -# Temporary files -tmp/ -temp/ -*.tmp - -# Test files -tests/ -**/tests/ -*_test.rs -*_tests.rs - -# Coverage reports -coverage/ -*.gcov -*.gcno -*.gcda - -# Profiling -*.prof - -# Backup files -*.bak -*.backup +# Frontend build artifacts and cache +web/node_modules/ +web/dist/ +web/.vite/ +web/.tanstack/ +web/.vscode/ +.vscode/ diff --git a/Dockerfile b/Dockerfile index 5822eda..94b6cc3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,27 @@ -# Build Stage +# Build arguments ARG RUST_VERSION=1.89.0 + +# Frontend Build Stage +FROM node:22-bookworm-slim AS frontend-builder + +# Install pnpm +RUN npm install -g pnpm + +WORKDIR /app + +# Copy frontend package files +COPY ./web/package.json ./web/pnpm-lock.yaml ./ + +# Install dependencies +RUN pnpm install --frozen-lockfile + +# Copy frontend source code +COPY ./web ./ + +# Build frontend +RUN pnpm run build + +# Rust Build Stage FROM rust:${RUST_VERSION}-bookworm AS builder # Install build dependencies @@ -18,9 +40,14 @@ COPY ./Cargo.toml ./Cargo.lock* ./ # Build empty app with downloaded dependencies to produce a stable image layer for next build RUN cargo build --release -# Build web app with own code +# Copy source code RUN rm src/*.rs COPY ./src ./src + +# Copy built frontend assets +COPY --from=frontend-builder /app/dist ./web/dist + +# Build web app with embedded assets RUN rm ./target/release/deps/banner* RUN cargo build --release @@ -50,7 +77,7 @@ RUN addgroup --gid $GID $APP_USER \ && adduser --uid $UID --disabled-password --gecos "" --ingroup $APP_USER $APP_USER \ && mkdir -p ${APP} -# Copy application files +# Copy application binary COPY --from=builder --chown=$APP_USER:$APP_USER /usr/src/banner/target/release/banner ${APP}/banner # Set proper permissions @@ -73,4 +100,5 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ ENV HOSTS=0.0.0.0,[::] # Implicitly uses PORT environment variable -CMD ["sh", "-c", "exec ./banner --server ${HOSTS}"] \ No newline at end of file +# temporary: running without 'scraper' service +CMD ["sh", "-c", "exec ./banner --services web,bot"] \ No newline at end of file diff --git a/diesel.toml b/diesel.toml deleted file mode 100644 index 83e0517..0000000 --- a/diesel.toml +++ /dev/null @@ -1,9 +0,0 @@ -# For documentation on how to configure this file, -# see https://diesel.rs/guides/configuring-diesel-cli - -[print_schema] -file = "src/data/schema.rs" -custom_type_derives = ["diesel::query_builder::QueryId", "Clone"] - -[migrations_directory] -dir = "migrations" \ No newline at end of file