diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0492bc0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,17 @@ +node_modules/ +dist/ +build/ +.git/ +.github/ +.lighthouseci/ +.vscode/ +.idea/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +.env +.env.* +Dockerfile +docker-compose.yml +README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6283bb5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# Stage 1: Build the React application +FROM node:22-alpine AS build + +WORKDIR /app + +# Copy package files and install dependencies +COPY package*.json ./ +RUN npm ci + +# Copy the rest of the application source code +COPY . . + +# Build the application for production +RUN npm run build + +# Stage 2: Serve the application using Nginx +FROM nginx:stable-alpine + +# Copy the build output to Nginx HTML directory +COPY --from=build /app/dist /usr/share/nginx/html + +# Copy custom Nginx configuration for client-side routing support +COPY nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 + +HEALTHCHECK --interval=30s --timeout=3s \ + CMD curl -f http://localhost/ || exit 1 + +CMD ["nginx", "-g", "daemon off;"] + diff --git a/README.md b/README.md index 7cb9cea..ddc88dd 100644 --- a/README.md +++ b/README.md @@ -310,6 +310,30 @@ We welcome contributions from developers, designers, and open-source enthusiasts - Pull request guidelines - Community communication +## 🐳 Docker Support + +You can run OrgExplorer in a containerized environment using Docker or Docker Compose. This is useful for self-hosting in your own infrastructure. + +### Build and Run with Docker Compose (Recommended) + +1. Build and start the container: + ```bash + docker compose up --build -d + ``` +2. Access the application in your browser at http://localhost:8080. + +### Build and Run with Docker CLI + +1. Build the Docker image: + ```bash + docker build -t orgexplorer . + ``` +2. Run the container: + ```bash + docker run -d -p 8080:80 orgexplorer + ``` +3. Access the application in your browser at http://localhost:8080. + ## 📍 License This project is licensed under the GNU General Public License v3.0. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2de8512 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +services: + orgexplorer: + build: + context: . + dockerfile: Dockerfile + container_name: orgexplorer-app + ports: + - "8080:80" + restart: unless-stopped diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..4bb9a42 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,23 @@ +server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + # Enable gzip compression for better performance + gzip on; + gzip_vary on; + gzip_min_length 10240; + gzip_proxied expired no-cache no-store private auth; + gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/javascript; + gzip_disable "MSIE [1-6]\."; + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +}