This repository has been archived by the owner on Mar 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 95
Deploy to Google Cloud Run
Hiroki Toyokawa edited this page Dec 3, 2022
·
1 revision
You can also run easy-notion-blog on Google Cloud Run instead of Vercel.
You should execute Next.js as SSR(Server-Side Rendering) not ISR(Incremental Static Regeneration).
- Replace
getStaticProps({ props })
togetServerSideProps({ res, props })
from all pages - Place
res.setHeader("Cache-Control", "public, s-maxage=300, stale-while-revalidate=86400")
intogetServerSideProps()
- Remove
revalidate
property from return object of the pages - Remove
getStaticPaths()
from all pages
Dockerfile
FROM node:16 AS builder
ARG NEXT_PUBLIC_URL
ARG NEXT_PUBLIC_GA_TRACKING_ID
ENV NEXT_PUBLIC_URL=${NEXT_PUBLIC_URL}
ENV NEXT_PUBLIC_GA_TRACKING_ID=${NEXT_PUBLIC_GA_TRACKING_ID}
ENV NODE_ENV=development
WORKDIR /app
COPY package.json ./
COPY yarn.lock ./
RUN yarn install
COPY . .
RUN yarn build
FROM node:16-slim AS runner
ENV NODE_ENV=production
WORKDIR /app
COPY package.json ./
COPY yarn.lock ./
RUN yarn install
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
CMD ["yarn", "start"]
Build Docker image and push to Container Registry or Artifact Registry.
And deploy to Cloud Run.