Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.git
.github
.next
node_modules
npm-debug.log*
.dockerignore
.env
.env.*
!.env.example
!.env.local.example
coverage
dist
tmp
.DS_Store
8 changes: 6 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Spree API Configuration (server-side only - not exposed to browser)
SPREE_API_URL=http://localhost:3000
SPREE_PUBLISHABLE_KEY=your_publishable_api_key
# SPREE_API_URL=http://localhost:3000
# SPREE_PUBLISHABLE_KEY=your_publishable_api_key

# Olitt tenant config API (host-based store config lookup)
OLITT_API_URL=https://api.olitt.example.com
OLITT_LOOKUP_PATH=api/shop/configuration

# Store defaults (should match your Spree store settings)
# These are used by the middleware for initial redirects before API data is loaded
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Docker Publish

on:
push:
branches:
- main
- dev
workflow_dispatch:

concurrency:
group: docker-publish-${{ github.ref }}
cancel-in-progress: true

env:
IMAGE_NAME: storefront

jobs:
docker:
name: Build and Push Docker Image
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=prod,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=prod-${{ github.sha }},enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }}
type=raw,value=dev-${{ github.sha }},enable=${{ github.ref == 'refs/heads/dev' }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM node:20-bookworm-slim AS base

ENV NEXT_TELEMETRY_DISABLED=1

FROM base AS deps
WORKDIR /app

COPY package.json package-lock.json ./
RUN npm ci

FROM base AS builder
WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .

RUN npm run build

FROM node:20-bookworm-slim AS runner
WORKDIR /app

ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV HOSTNAME=0.0.0.0
ENV PORT=3001

RUN groupadd --system --gid 1001 nodejs \
&& useradd --system --uid 1001 --gid nodejs nextjs

COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static

USER nextjs

EXPOSE 3001

CMD ["node", "server.js"]
2 changes: 1 addition & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"cart": "Cart",
"policies": "Policies",
"poweredBy": "Powered by",
"copyright": "© {year} {storeName}. Powered by Spree Commerce."
"copyright": "© {year} {storeName}. Powered by Olitt"
},
"home": {
"welcome": "{storeName} Storefront",
Expand Down
16 changes: 16 additions & 0 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const withNextIntl = createNextIntlPlugin();

const nextConfig: NextConfig = {
allowedDevOrigins: ["shop.lvh.me", "*.trycloudflare.com"],
output: "standalone",
env: {
NEXT_PUBLIC_SENTRY_DSN: process.env.SENTRY_DSN || "",
},
Expand All @@ -22,6 +23,7 @@ const nextConfig: NextConfig = {
root: __dirname,
},
cacheComponents: true,
// cacheComponents: process.env.NODE_ENV === "production",
cacheLife: {
tenMinutes: {
stale: 300, // 5 minutes client stale window
Expand Down Expand Up @@ -55,6 +57,20 @@ const nextConfig: NextConfig = {
hostname: "**.trycloudflare.com",
pathname: "/rails/active_storage/**",
},
{
protocol: "https",
hostname: "olitt.store",
pathname: "/rails/active_storage/**",
},
{
protocol: "https",
hostname: "**.olitt.store",
pathname: "/rails/active_storage/**",
},
{
protocol: "https",
hostname: "images.unsplash.com",
},
],
},
};
Expand Down
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading