Public

In the larger context of the project structure, the public/ directory serves as the uncompiled static asset repository. Unlike source files inside src/, assets placed in public/ bypass Astro’s build pipeline transformations and are served directly at the root path (/) of the website.


  1. Contents and Purpose of public/

The public/ directory stores raw files that must maintain fixed filenames and public URL paths:

  • Profile & Branding Media: Stores profile photos such as public/profile.webp and social link preview cards such as public/social_img.webp.
  • Site Meta Files: Houses root-level files like favicons and robots.txt.

  1. Integration into Component Markup & Layouts

Files inside public/ can be referenced directly within .astro components without relative directory paths:

  • Sidebar Profile Image: src/components/SideBar.astro references /profile.webp to display the personal photo in the persistent navigation bar.
  • Social Sharing Preview: Meta headers in global layout files reference /social_img.webp for Open Graph and Twitter card link previews.

  1. Compilation & Docker Deployment Lifecycle

During compilation and deployment, public/ assets follow a simple static transfer path:

public/ (Raw Assets) ──> /app/dist/ (Build Stage) ──> /usr/share/caddy (Runner Stage)
  1. Build Compilation Stage: When running npm run build or pnpm run build (Stage 1 of the Dockerfile), Astro copies all files from public/ straight into the root of the output distribution folder (/app/dist/ or dist/).
  2. Production Serving: In Stage 2 of the multi-stage Docker build, Caddy or Nginx copies /app/dist into its serving directory (/usr/share/caddy or /usr/share/nginx/html) and serves those static files directly over HTTP on port 80.