summaryrefslogtreecommitdiff
path: root/storefront
diff options
context:
space:
mode:
authorertopogo <erwin.t.pombett@gmail.com>2026-01-18 20:32:59 +0100
committerertopogo <erwin.t.pombett@gmail.com>2026-01-18 20:32:59 +0100
commit09a949092c59856962e4a7d132bc5a5e76fe5e55 (patch)
tree990d6b8f24ff9c6dbc0fcb15b5512067d09b17fd /storefront
Initial commit: Medusa Backend + storefront + config
Diffstat (limited to 'storefront')
-rw-r--r--storefront/Dockerfile35
-rw-r--r--storefront/lib/medusa-client.js6
-rw-r--r--storefront/next.config.js10
-rw-r--r--storefront/package.json31
-rw-r--r--storefront/pages/_app.js17
-rw-r--r--storefront/pages/index.js26
6 files changed, 125 insertions, 0 deletions
diff --git a/storefront/Dockerfile b/storefront/Dockerfile
new file mode 100644
index 0000000..b6c1da8
--- /dev/null
+++ b/storefront/Dockerfile
@@ -0,0 +1,35 @@
+# Install dependencies only when needed
+FROM node:18-alpine AS deps
+WORKDIR /app
+COPY package.json yarn.lock* package-lock.json* ./
+RUN npm ci
+
+# Rebuild the source code only when needed
+FROM node:18-alpine AS builder
+WORKDIR /app
+COPY --from=deps /app/node_modules ./node_modules
+COPY . .
+# Disable telemetry during build
+ENV NEXT_TELEMETRY_DISABLED 1
+RUN npm run build
+
+# Production image, copy all the files and run next
+FROM node:18-alpine AS runner
+WORKDIR /app
+ENV NODE_ENV production
+ENV NEXT_TELEMETRY_DISABLED 1
+
+RUN addgroup --system --gid 1001 nodejs
+RUN adduser --system --uid 1001 nextjs
+
+COPY --from=builder /app/public ./public
+COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
+COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
+
+USER nextjs
+
+EXPOSE 8000
+ENV PORT 8000
+
+CMD ["node", "server.js"]
+
diff --git a/storefront/lib/medusa-client.js b/storefront/lib/medusa-client.js
new file mode 100644
index 0000000..0b78f76
--- /dev/null
+++ b/storefront/lib/medusa-client.js
@@ -0,0 +1,6 @@
+import Medusa from "@medusajs/medusa-js"
+
+const BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL || "http://localhost:9000"
+
+export const medusaClient = new Medusa({ baseUrl: BACKEND_URL, maxRetries: 3 })
+
diff --git a/storefront/next.config.js b/storefront/next.config.js
new file mode 100644
index 0000000..255e46c
--- /dev/null
+++ b/storefront/next.config.js
@@ -0,0 +1,10 @@
+/** @type {import('next').NextConfig} */
+const nextConfig = {
+ reactStrictMode: true,
+ images: {
+ domains: ["localhost", "medusa-public-images.s3.eu-west-1.amazonaws.com"],
+ },
+}
+
+module.exports = nextConfig
+
diff --git a/storefront/package.json b/storefront/package.json
new file mode 100644
index 0000000..fefa31c
--- /dev/null
+++ b/storefront/package.json
@@ -0,0 +1,31 @@
+{
+ "name": "medusa-storefront",
+ "version": "1.0.0",
+ "private": true,
+ "scripts": {
+ "dev": "next dev -p 8000",
+ "build": "next build",
+ "start": "next start -p 8000",
+ "lint": "next lint"
+ },
+ "dependencies": {
+ "@medusajs/medusa": "^1.20.0",
+ "@medusajs/medusa-js": "^6.1.7",
+ "@tanstack/react-query": "4.22.0",
+ "medusa-react": "^9.0.15",
+ "next": "13.4.12",
+ "react": "18.2.0",
+ "react-dom": "18.2.0",
+ "clsx": "^2.0.0",
+ "lucide-react": "^0.263.1"
+ },
+ "devDependencies": {
+ "autoprefixer": "^10.4.14",
+ "postcss": "^8.4.27",
+ "tailwindcss": "^3.3.3",
+ "typescript": "5.1.6",
+ "@types/react": "18.2.18",
+ "@types/node": "20.4.9"
+ }
+}
+
diff --git a/storefront/pages/_app.js b/storefront/pages/_app.js
new file mode 100644
index 0000000..1424c52
--- /dev/null
+++ b/storefront/pages/_app.js
@@ -0,0 +1,17 @@
+import { MedusaProvider } from "medusa-react"
+import { QueryClient } from "@tanstack/react-query"
+import { medusaClient } from "../lib/medusa-client"
+
+const queryClient = new QueryClient()
+
+export default function App({ Component, pageProps }) {
+ return (
+ <MedusaProvider
+ queryClientProviderProps={{ client: queryClient }}
+ baseUrl="http://localhost:9000"
+ >
+ <Component {...pageProps} />
+ </MedusaProvider>
+ )
+}
+
diff --git a/storefront/pages/index.js b/storefront/pages/index.js
new file mode 100644
index 0000000..fa4a592
--- /dev/null
+++ b/storefront/pages/index.js
@@ -0,0 +1,26 @@
+import { useProducts } from "medusa-react"
+
+export default function Home() {
+ const { products, isLoading } = useProducts()
+
+ return (
+ <div style={{ padding: "2rem", fontFamily: "sans-serif" }}>
+ <h1>Bienvenue sur la boutique Lucien-sens-bon</h1>
+ {isLoading && <span>Chargement des produits...</span>}
+
+ <div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(200px, 1fr))", gap: "1rem" }}>
+ {products && products.map((product) => (
+ <div key={product.id} style={{ border: "1px solid #ccc", padding: "1rem", borderRadius: "8px" }}>
+ <h3>{product.title}</h3>
+ <p>{product.description}</p>
+ </div>
+ ))}
+ </div>
+
+ {!isLoading && !products?.length && (
+ <p>Aucun produit trouvé. Connectez-vous à l'admin pour en ajouter !</p>
+ )}
+ </div>
+ )
+}
+