Skip to content

Conversation

@hamo-o
Copy link
Contributor

@hamo-o hamo-o commented Apr 7, 2025

#️⃣ 연관된 이슈>

📝 작업 내용> 이번 PR에서 작업한 내용을 간략히 설명해주세요(이미지 첨부 가능)

🙏 여기는 꼭 봐주세요! > 리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

Summary by CodeRabbit

  • New Features

    • Enhanced production builds now combine client and server-side processing for increased performance.
    • The server dynamically adapts its configuration based on the environment, ensuring more reliable behavior.
  • Chores

    • The deployment process has been refined with an automated backup system for smoother and safer updates.

@hamo-o hamo-o requested a review from dioo1461 as a code owner April 7, 2025 03:09
@coderabbitai
Copy link

coderabbitai bot commented Apr 7, 2025

Walkthrough

This update refines the frontend build, server configuration, and deployment processes. The package.json now features separate commands for client and server builds with SSR support and a new dependency. The server code dynamically configures file paths, port, and static file serving based on the environment. Additionally, the deployment script now creates backups with timestamped filenames, targets specific client files during deployment, and references updated Nginx configuration paths.

Changes

File(s) Change Summary
frontend/package.json Added "build:server" for SSR builds; updated "build" to run client and server builds followed by TypeScript compilation; modified "preview" to build and start production server using cross-env; added cross-env dependency.
frontend/server/index.js Introduced environment variables (isProduction, PORT, htmlPath) to manage dynamic file paths and static file serving; updated server listener port and console log.
script/deploy/frontend_deploy.sh Revised deployment paths including SSR_DIR; added backup functionality with BACKUP_DIR and timestamp (TIMESTAMP); modified file copying and Nginx configuration paths; adjusted rollback process to use new backup directory.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant PM as Package Manager (pnpm)
    participant Vite as Vite
    participant TSC as TypeScript Compiler

    Dev->>PM: Run "build" command
    PM->>Vite: Execute "build:client"
    Vite-->>PM: Client build artifacts
    PM->>Vite: Execute "build:server" (SSR enabled)
    Vite-->>PM: Server build artifacts
    PM->>TSC: Run "tsc -b"
    TSC-->>PM: TypeScript compilation complete
Loading
sequenceDiagram
    participant Op as Operator
    participant DS as Deploy Script
    participant FS as File System
    participant Nginx as Nginx Server

    Op->>DS: Execute deployment script
    DS->>FS: Create backup directory and compress current frontend files
    DS->>FS: Copy new client files from dist/client
    DS->>Nginx: Update configuration with new config paths
    DS->>FS: Reference backups during rollback if necessary
Loading

Possibly related PRs

Suggested labels

🔮 ALL

Suggested reviewers

  • kwon204
  • efdao
  • dioo1461

Poem

I'm a rabbit coding in delight,
Hopping through scripts both day and night.
New builds and backups make my heart race,
As SSR hops into a brighter place.
Cheers to changes, swift and light! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d87bccc and 46da005.

⛔ Files ignored due to path filters (1)
  • frontend/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • frontend/package.json (2 hunks)
  • frontend/server/index.js (3 hunks)
  • script/deploy/frontend_deploy.sh (2 hunks)
🔇 Additional comments (13)
frontend/server/index.js (5)

3-3: Environment-aware configuration looks good!

Adding process import and environment detection with fallback port is a good practice. This makes the server more configurable and follows the principle of environment-based configuration.

Also applies to: 9-10


13-13: Improved dynamic path resolution

Using a conditional path based on the environment is a solid approach. This ensures the correct HTML file is served depending on whether you're in development or production.


25-27: Good conditional static file serving

Serving static files only in production mode is appropriate since Vite middleware handles this in development. This prevents potential conflicts between Vite's dev server and Express static serving.


32-32: Proper path resolution with dynamic path

The path resolution now correctly uses the dynamic htmlPath variable, ensuring the proper HTML file is loaded based on the environment.


44-44: Dynamic port usage enhances configurability

Using the environment-based PORT for both listening and logging improves configurability and makes the server more portable across different environments.

Also applies to: 46-46

frontend/package.json (2)

9-11: Enhanced build process with SSR support

The new build scripts appropriately separate client and server builds while maintaining the TypeScript build step. The preview script now properly builds and runs the server in production mode.


56-56: Appropriate addition of cross-env dependency

Adding cross-env as a dev dependency is necessary for the updated preview script to set environment variables in a cross-platform compatible way.

script/deploy/frontend_deploy.sh (6)

6-6: Updated SSR directory path

The SSR directory path now correctly points to the new server build location, aligning with the changes in the package.json build scripts.


9-16: Excellent addition of backup functionality

Adding backup capability with timestamped archives is a best practice for deployment scripts. This ensures you can easily rollback to previous versions if needed.


35-35: More specific copy command

The copy command now specifically targets the client build files, which aligns with the new build structure. This ensures only the necessary files are deployed.


39-40: Updated Nginx configuration paths

The Nginx configuration file paths have been updated to reflect the new directory structure. This aligns with the PR title about modifying Nginx configuration file paths.


48-48: Consistent rollback mechanism

The rollback process has been updated to use the new backup location and timestamp, ensuring consistency with the new backup structure.


54-55: Cleanup of old backups

The script includes a cleanup mechanism for old backups, keeping only the 5 most recent ones. This is good practice to prevent disk space issues.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@dioo1461 dioo1461 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✔

@hamo-o hamo-o merged commit eea2cb3 into dev Apr 7, 2025
4 of 5 checks passed
@hamo-o hamo-o deleted the bugfix/all/frontend-server-script branch April 7, 2025 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants