From 4239125455ce31f13f5e9c2901eaa76992bac2fc Mon Sep 17 00:00:00 2001 From: MunchDev-oss Date: Sun, 4 Jan 2026 16:41:39 -0500 Subject: [PATCH] Update README with Docker deployment instructions and bump version to 0.0.1-beta in package.json --- .dockerignore | 19 ++++++ .github/workflows/docker-publish.yml | 95 ++++++++++++++++++++++++++++ Dockerfile | 38 +++++++++++ README.md | 61 ++++++++++++++++++ docker-compose-dev.yml | 17 +++++ docker-compose.yml | 9 +++ website/package.json | 2 +- 7 files changed, 240 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/docker-publish.yml create mode 100644 Dockerfile create mode 100644 docker-compose-dev.yml create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..42652bc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,19 @@ +node_modules +npm-debug.log +.git +.gitignore +README.md +.env +.env.local +.env.development.local +.env.test.local +.env.production.local +dist +.DS_Store +*.log +.vscode +.idea +Screen Shots +BOM.xlsx +~$BOM.xlsx +custom-covers diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..0aadfb2 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,95 @@ +name: Build and Publish Docker Image + +on: + push: + tags: + - '*' + branches: + - main + - master + workflow_dispatch: + inputs: + version: + description: 'Version tag (e.g., V0.0.1-BETA)' + required: true + default: 'V0.0.1-BETA' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Determine version tag + id: version + run: | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + echo "tag=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT + echo "create_release=true" >> $GITHUB_OUTPUT + elif [[ "${{ github.ref }}" == refs/tags/* ]]; then + echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + echo "create_release=true" >> $GITHUB_OUTPUT + else + echo "tag=latest" >> $GITHUB_OUTPUT + echo "create_release=false" >> $GITHUB_OUTPUT + fi + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=${{ steps.version.outputs.tag }} + type=raw,value=latest,enable=${{ steps.version.outputs.tag == 'latest' }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Create Release + if: steps.version.outputs.create_release == 'true' + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ steps.version.outputs.tag }} + name: Release ${{ steps.version.outputs.tag }} + body: | + ## Release ${{ steps.version.outputs.tag }} + + Docker image is available at: + - `${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.tag }}` + + ### Running the Docker image + + ```bash + docker run -d -p 80:80 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.tag }} + ``` + + The application will be available at http://localhost:80 + prerelease: true + draft: false diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ce53701 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +# Build stage +FROM node:20-alpine AS builder + +WORKDIR /app + +# Copy package files +COPY website/package*.json ./ + +# Install dependencies +RUN npm ci + +# Copy source code +COPY website/ ./ + +# Build the application +RUN npm run build + +# Production stage +FROM nginx:alpine + +# Copy built files from builder stage +COPY --from=builder /app/dist /usr/share/nginx/html + +# Copy nginx configuration for SPA routing +RUN echo 'server { \ + listen 80; \ + server_name _; \ + root /usr/share/nginx/html; \ + index index.html; \ + location / { \ + try_files $uri $uri/ /index.html; \ + } \ +}' > /etc/nginx/conf.d/default.conf + +# Expose port 80 +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/README.md b/README.md index 7fbaba8..8464b41 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,11 @@ The OSSM Configurator is a React-based single-page application built with Vite. ### Prerequisites +**Option 1: Using Docker (Recommended)** +- Docker Desktop or Docker Engine +- Docker Compose + +**Option 2: Local Development** - Node.js (v16 or higher recommended) - npm or yarn @@ -90,6 +95,62 @@ Preview the production build locally: npm run preview ``` +## Docker Deployment + +### Development with Docker Compose + +Run the application in development mode with hot reload: + +```bash +docker-compose -f docker-compose-dev.yml up +``` + +The application will be available at `http://localhost:5173` with hot module replacement enabled. + +To run in detached mode (background): +```bash +docker-compose -f docker-compose-dev.yml up -d +``` + +To stop the development container: +```bash +docker-compose -f docker-compose-dev.yml down +``` + +### Production with Docker Compose + +Build and run the production image: + +```bash +docker-compose up --build -d +``` + +The application will be available at `http://localhost:80` + +To run without rebuilding (if image already exists): +```bash +docker-compose up -d +``` + +To stop the production container: +```bash +docker-compose down +``` + +To view logs: +```bash +docker-compose logs -f +``` + +### Using Pre-built Docker Images + +The project includes GitHub Actions workflows that automatically build and publish Docker images to GitHub Container Registry (ghcr.io) on releases. You can pull and run the latest release image: + +```bash +docker pull ghcr.io//:V0.0.1-BETA +docker run -d -p 80:80 ghcr.io//:V0.0.1-BETA +``` + ## Configuration Data The application uses JSON data files located in `website/src/data/`: diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml new file mode 100644 index 0000000..3b2b42e --- /dev/null +++ b/docker-compose-dev.yml @@ -0,0 +1,17 @@ +version: '3.8' + +services: + ossm-configurator-dev: + image: node:20-alpine + container_name: ossm-configurator-dev + working_dir: /app + volumes: + - ./website:/app + - /app/node_modules + ports: + - "5173:5173" + command: sh -c "npm install && npm run dev -- --host" + environment: + - NODE_ENV=development + stdin_open: true + tty: true diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d8cc51b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +services: + ossm-configurator: + image: ghcr.io/munchdev-oss/ossm-configurator:latest + container_name: ossm-configurator + ports: + - "80:80" + restart: unless-stopped + environment: + - NODE_ENV=production diff --git a/website/package.json b/website/package.json index 9529a5b..ccca5cc 100644 --- a/website/package.json +++ b/website/package.json @@ -1,7 +1,7 @@ { "name": "ossm-configurator", "private": true, - "version": "0.0.0", + "version": "0.0.1-beta", "type": "module", "scripts": { "dev": "vite",