Giter VIP home page Giter VIP logo

Comments (5)

serranomorante avatar serranomorante commented on May 16, 2024 2

@serranomorante did you suceed ?

Maybe. I'm using this on production, but I did it almost in a hurry. I still hope it can help you to have something until saleor releases an official version.

# Step 1. Rebuild the source code only when needed
FROM node:18-alpine AS builder

RUN npm install -g pnpm

WORKDIR /app

# Copy lock files if file exists
COPY ./frontend/package.json ./frontend/pnpm-lock.yaml ./

# Omit --production flag for TypeScript devDependencies
RUN pnpm install

COPY ./frontend/ ./

# Run eslint
RUN pnpm run lint

# Environment variables must be present at build time
# https://github.com/vercel/next.js/discussions/14030
ARG API_URI
ENV API_URI ${API_URI:-http://localhost:8000/graphql/}

# Uncomment the following line to disable telemetry at build time
# ENV NEXT_TELEMETRY_DISABLED 1

# Build app
RUN pnpm run build

# Step 2. Production image, copy all the files and run next
FROM node:18-alpine AS runner

WORKDIR /app

# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

# My custom start and entrypoint files
COPY ./compose/production/frontend/start /start
RUN sed -i 's/\r$//g' /start
RUN chmod +x /start

COPY ./compose/production/frontend/entrypoint /entrypoint
RUN sed -i 's/\r$//g' /entrypoint
RUN chmod +x /entrypoint

# USER nextjs

# COPY --from=builder /app/public ./public
# COPY --from=builder /app/next.config.js .
# COPY --from=builder /app/package.json .
COPY --from=builder /app ./

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
# COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

# Environment variables must be redefined at run time
# ARG ENV_VARIABLE
# ENV ENV_VARIABLE=${ENV_VARIABLE}
# ARG NEXT_PUBLIC_ENV_VARIABLE
# ENV NEXT_PUBLIC_ENV_VARIABLE=${NEXT_PUBLIC_ENV_VARIABLE}
ARG API_URI
# -> the backend app
ENV API_URI ${API_URI:-http://localhost:8000/graphql/}

ENV NEXT_PUBLIC_STOREFRONT_NAME="Your app name"

ARG NEXT_PUBLIC_API_URI
ENV NEXT_PUBLIC_API_URI=${NEXT_PUBLIC_API_URI:-https://vercel.saleor.cloud/graphql/}

ARG NEXT_PUBLIC_API_URI_INSECURE
ENV NEXT_PUBLIC_API_URI_INSECURE=${NEXT_PUBLIC_API_URI_INSECURE:-http://vercel.saleor.cloud/graphql/}

ENV NEXT_PUBLIC_DEFAULT_CHANNEL=default-channel
ENV NEXT_PUBLIC_HOMEPAGE_MENU=navbar
# -> the frontend app
ENV NEXT_PUBLIC_VERCEL_URL=https://localhost:3001
ENV NEXT_PUBLIC_DEMO_MODE=false
ENV NEXT_PUBLIC_GEOLOCATION=false
ENV NEXT_PUBLIC_ALLOWED_IMAGE_DOMAINS=img.youtube.com,i.ytimg.com,s3.amazonaws.com
ENV NEXT_PUBLIC_IMAGE_CONVERSION_FORMATS=image/avif,image/webp
ENV NEXT_PUBLIC_CHECKOUT_URL=

# Uncomment the following line to disable telemetry at run time
# ENV NEXT_TELEMETRY_DISABLED 1

# ENTRYPOINT ["/entrypoint"]
CMD ["node_modules/.bin/next", "start"]

from storefront.

serranomorante avatar serranomorante commented on May 16, 2024 1

Why is this closed? I'm going to try to create my own production Dockerfile and share it here later.

from storefront.

mmiszy avatar mmiszy commented on May 16, 2024 1

It was closed automatically by GitHub when we merged the repositories of Checkout and React Storefront.

Maintaining a docker image is something we definitely have on our roadmap.

from storefront.

matteius avatar matteius commented on May 16, 2024

I too have run into this issue, and would prefer not to deploy this way with pnpm run start but rather the built assets.

from storefront.

slamer59 avatar slamer59 commented on May 16, 2024

@serranomorante did you suceed ?

from storefront.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.