diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index e050751..e973f05 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -62,3 +62,4 @@ jobs: cache-to: type=gha,mode=max build-args: | VITE_FLASK_BACKEND_URL=${{ vars.VITE_FLASK_BACKEND_URL || '' }} + VITE_BASE_PATH=${{ vars.VITE_BASE_PATH || '/' }} diff --git a/Dockerfile b/Dockerfile index 82bce5f..ef0c9cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,9 @@ COPY . . ARG VITE_FLASK_BACKEND_URL ENV VITE_FLASK_BACKEND_URL=$VITE_FLASK_BACKEND_URL +ARG VITE_BASE_PATH +ENV VITE_BASE_PATH=$VITE_BASE_PATH + RUN npm run build # Production stage diff --git a/docs/CI-CD.md b/docs/CI-CD.md index 7012f5e..9d10ce1 100644 --- a/docs/CI-CD.md +++ b/docs/CI-CD.md @@ -32,13 +32,13 @@ This workflow automatically builds a Docker image of the application and pushes ```bash # Pull the latest image -docker pull ghcr.io/johndoe6345789/snippet-pastebin:latest +docker pull ghcr.io//:latest # Run the container -docker run -p 3000:3000 ghcr.io/johndoe6345789/snippet-pastebin:latest +docker run -p 3000:3000 ghcr.io//:latest # Pull a specific version -docker pull ghcr.io/johndoe6345789/snippet-pastebin:v1.0.0 +docker pull ghcr.io//:v1.0.0 ``` **Making Images Public:** @@ -67,12 +67,12 @@ This workflow builds the frontend application and deploys it to GitHub Pages. 2. **Configure Base Path:** Set the `VITE_BASE_PATH` repository variable for proper asset loading: - - For deployment at `https://.github.io//`, set: `/snippet-pastebin/` + - For deployment at `https://.github.io//`, set: `//` - For custom domain or root deployment, set: `/` Go to Settings → Secrets and variables → Actions → Variables → New repository variable - Name: `VITE_BASE_PATH` - - Value: `/snippet-pastebin/` (or your repository name) + - Value: `//` (or your repository name) 3. **Optional Configuration:** - Set `VITE_FLASK_BACKEND_URL` as a repository variable if you want to connect to a backend @@ -90,7 +90,7 @@ After the workflow runs successfully, your site will be available at: Set these variables in your repository settings (Settings → Secrets and variables → Actions → Variables): - `VITE_BASE_PATH` (recommended for GitHub Pages): Base path for the application - - Example: `/snippet-pastebin/` for `username.github.io/snippet-pastebin/` + - Example: `//` for `username.github.io//` - Use `/` for custom domains or root deployment - `VITE_FLASK_BACKEND_URL` (optional): URL of your Flask backend API - Example: `https://api.example.com` @@ -165,8 +165,8 @@ To test the workflows locally, you can: 1. **Build the Docker image:** ```bash - docker build -t snippet-pastebin . - docker run -p 3000:3000 snippet-pastebin + docker build -t . + docker run -p 3000:3000 ``` 2. **Build for GitHub Pages:** @@ -179,11 +179,11 @@ To test the workflows locally, you can: ## Workflow Status Badges -Add these badges to your README.md: +Add these badges to your README.md (replace `` and `` with your values): ```markdown -[![Docker Build](https://github.com/johndoe6345789/snippet-pastebin/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/johndoe6345789/snippet-pastebin/actions/workflows/docker-publish.yml) -[![Deploy to Pages](https://github.com/johndoe6345789/snippet-pastebin/actions/workflows/deploy-pages.yml/badge.svg)](https://github.com/johndoe6345789/snippet-pastebin/actions/workflows/deploy-pages.yml) +[![Docker Build](https://github.com///actions/workflows/docker-publish.yml/badge.svg)](https://github.com///actions/workflows/docker-publish.yml) +[![Deploy to Pages](https://github.com///actions/workflows/deploy-pages.yml/badge.svg)](https://github.com///actions/workflows/deploy-pages.yml) ``` ## Further Customization