From e88a186bd1da16f4d304b08aaeea91019d31b434 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Sun, 17 Aug 2025 09:07:17 +0000 Subject: [PATCH 1/3] Dockerized webapp --- .dockerignore | 20 ++++++++++++++++++++ Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ docker-compose.yml | 9 +++++++++ multi-Dockerfile | 30 ++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 multi-Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..26e16cc07 --- /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 000000000..a76549187 --- /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/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..5fd43218b --- /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 000000000..7bf81215c --- /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;"] + From 9425365b1d00ec488a3beb7fec8f187f56d1de4a Mon Sep 17 00:00:00 2001 From: Suyash Dahitule <139065167+suyash700@users.noreply.github.com> Date: Sun, 17 Aug 2025 14:43:18 +0530 Subject: [PATCH 2/3] Update README.md --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 50bef28e6..535773acb 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,36 @@ [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) + +## How to Run +### Using Docker +```bash +docker build -t my-app:latest . +docker run -d -p 8080:8080 my-app:latest + + +Screenshot 2025-08-17 142714 + +Screenshot 2025-08-17 142732 + +Screenshot 2025-08-17 143716 +Screenshot 2025-08-17 143733 + + ## Preview [![Creative Preview](https://assets.startbootstrap.com/img/screenshots/themes/creative.png)](https://startbootstrap.github.io/startbootstrap-creative/) From 9196305fde982ddd16e9f5ebe1b58f36182f6c3a Mon Sep 17 00:00:00 2001 From: Suyash Dahitule <139065167+suyash700@users.noreply.github.com> Date: Sun, 17 Aug 2025 14:44:04 +0530 Subject: [PATCH 3/3] Update README.md --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 535773acb..594639242 100644 --- a/README.md +++ b/README.md @@ -17,13 +17,6 @@ This project is a Dockerized version of the StartBootstrap Creative template. No - Docker >= 20.x - Docker Compose (optional for local dev) -## How to Run -### Using Docker -```bash -docker build -t my-app:latest . -docker run -d -p 8080:8080 my-app:latest - - Screenshot 2025-08-17 142714 Screenshot 2025-08-17 142732 @@ -32,6 +25,15 @@ docker run -d -p 8080:8080 my-app:latest 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/)