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
45 changes: 45 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM node:22-slim AS base

FROM base AS build

WORKDIR /app

RUN corepack enable
COPY ./package.json ./pnpm-lock.yaml ./pnpm-workspace.yaml ./.npmrc ./

COPY ./turbo.json ./.eslintrc.js ./.lighthouserc.js ./
COPY ./apps/ ./apps/
COPY ./packages/ ./packages/

ARG NEXT_PUBLIC_SALEOR_API_URL
ENV NEXT_PUBLIC_SALEOR_API_URL=${NEXT_PUBLIC_SALEOR_API_URL}

ARG NEXT_PUBLIC_DEFAULT_CHANNEL
ENV NEXT_PUBLIC_DEFAULT_CHANNEL=${NEXT_PUBLIC_DEFAULT_CHANNEL}

ARG NEXT_PUBLIC_STRIPE_PUBLIC_KEY
ENV NEXT_PUBLIC_STRIPE_PUBLIC_KEY=${NEXT_PUBLIC_STRIPE_PUBLIC_KEY}

ENV NEXT_TELEMETRY_DISABLED=1
ENV TURBO_TELEMETRY_DISABLED=1

# Installs late due to needing --recursive flag
ENV PNPM_HOME="/pnpm"
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm i --recursive --frozen-lockfile

# Env vars SALEOR_APP_TOKEN and STRIPE_SECRET_KEY are required env vars but not
# used during build. Instead they can be set directly at runtime in the server.
# As these are secrets we are not passing them in the build.
RUN \
SALEOR_APP_TOKEN= \
STRIPE_SECRET_KEY= \
NEXT_OUTPUT=standalone \
pnpm run build:storefront

FROM base AS final

WORKDIR /app
COPY --from=build /app/apps/storefront/.next/standalone/ ./
COPY --from=build /app/apps/storefront/.next/static ./apps/storefront/.next/static

CMD ["node", "/app/apps/storefront/server.js"]
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,31 @@ pnpm run codegen

The app is now running at `http://localhost:3000`.

## Docker Compose

1. Create the required environment variables, e.g., in `.env.secret`:

```env
# Required:
NEXT_PUBLIC_SALEOR_API_URL=https://store.example.com/graphql/
NEXT_PUBLIC_STRIPE_PUBLIC_KEY=pk_test_XXX
SALEOR_APP_TOKEN=XXX
STRIPE_SECRET_KEY=sk_test_XXX

# Optional:
NEXT_PUBLIC_DEFAULT_CHANNEL=eu
```

Refer to [environment variable guide] for more info.

2. Start the stack using:

```shell
$ docker-compose --env-file .env.secret up --build
```

[environment variable guide]: ./apps/docs/pages/quickstart/environment-variables.mdx

## ❤️ Community & Contribution

Join Nimara community on [GitHub Discussions](https://github.com/mirumee/nimara-ecommerce/discussions) and [Discord server](https://discord.gg/w4V3PZxGDj). You can ask questions, report bugs, participate in discussions, share ideas or make feature requests.
Expand Down
1 change: 1 addition & 0 deletions apps/storefront/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const isSentryAvailable =
/** @type {import('next').NextConfig} */
const nextConfig = withAnalyzer(
withNextIntl({
output: process.env.NEXT_OUTPUT === "standalone" ? "standalone" : undefined,
redirects: async () => {
return [
{
Expand Down
16 changes: 16 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
services:
storefront:
build:
context: .
dockerfile: ./Dockerfile
args:
- NEXT_PUBLIC_DEFAULT_CHANNEL=${NEXT_PUBLIC_DEFAULT_CHANNEL:-eu}
- NEXT_PUBLIC_SALEOR_API_URL=${NEXT_PUBLIC_SALEOR_API_URL}
- NEXT_PUBLIC_STRIPE_PUBLIC_KEY=${NEXT_PUBLIC_STRIPE_PUBLIC_KEY}

environment:
STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY}
SALEOR_APP_TOKEN: ${SALEOR_APP_TOKEN}

ports:
- "127.0.0.1:3001:3000"
Loading