diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..26e16cc071 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,20 @@ +# Dependency dirs +node_modules +npm-debug.log +yarn.lock + +# Build artifacts +dist +coverage +*.log + +# Git and configs +.git +.gitignore +.dockerignore + +# Env and secrets +.env +*.pem +*.key + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..a765491876 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +#BASE IMAGE + +FROM node:18-alpine + +#WORKDIR + +WORKDIR /app + +#COPY + +#COPY DEPENDENCIES FIRST +COPY package*.json ./ + +#ClEAN INSTALL DEPENDENCIES +RUN npm install + +#COPY WHAT IS NEEDED (MUST HAVE FOLDERS) +COPY src ./src +COPY scripts ./scripts + +#NON-ROOT USER +RUN addgroup -S appgroup && adduser -S appuser -G appgroup \ + && chown -R appuser:appgroup /app +USER appuser + +#BUILD +RUN npm run build + + +#EXPOSE +EXPOSE 3000 + +#CMD +CMD ["node", "scripts/start.js"] + + diff --git a/README.md b/README.md index 50bef28e6a..5946392423 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,38 @@ [Creative](https://startbootstrap.com/theme/creative/) is a one page, creative website theme built with [Bootstrap](https://getbootstrap.com/) created by [Start Bootstrap](https://startbootstrap.com/). + +# StartBootstrap Creative - Dockerized Version + +This project is a Dockerized version of the StartBootstrap Creative template. Now you can run it anywhere using Docker or Docker Compose without manual setup. + +## Features +- Fully containerized single-stage build (multi-stage optional). +- Non-root user for secure builds. +- Build and serve handled inside Docker. +- Easy deployment using Docker Compose. + +## Prerequisites +- Docker >= 20.x +- Docker Compose (optional for local dev) + +Screenshot 2025-08-17 142714 + +Screenshot 2025-08-17 142732 + +Screenshot 2025-08-17 143716 +Screenshot 2025-08-17 143733 + + + +## How to Run +### Using Docker +```bash +docker build -t my-app:latest . +docker run -d -p 8080:8080 my-app:latest + + + ## Preview [![Creative Preview](https://assets.startbootstrap.com/img/screenshots/themes/creative.png)](https://startbootstrap.github.io/startbootstrap-creative/) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..5fd43218be --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +services: + myapp2: + build: + context: . + dockerfile: multi-Dockerfile + container_name: myapp2 + restart: always + ports: + - "8080:80" diff --git a/multi-Dockerfile b/multi-Dockerfile new file mode 100644 index 0000000000..7bf81215c9 --- /dev/null +++ b/multi-Dockerfile @@ -0,0 +1,30 @@ +# Stage 1: Build +FROM node:18-alpine AS builder + +# Set working directory +WORKDIR /app + +# Copy package.json and package-lock.json +COPY package*.json ./ + +# Install dependencies +RUN npm ci + +# Copy source code +COPY . . + +# Build app +RUN npm run build + +# Stage 2: Serve with nginx +FROM nginx:alpine + +# Copy build output from builder +COPY --from=builder /app/dist /usr/share/nginx/html + +# Expose port 80 +EXPOSE 80 + +# Start nginx +CMD ["nginx", "-g", "daemon off;"] +