Deploy NextJS on GCP

Create Docker Image

# Install dependencies only when needed
FROM node:alpine
ENV NODE_ENV production
WORKDIR /app
COPY . .
RUN npm install && npm run build
EXPOSE 3000
CMD ["npm", "start"]
#.dockerignore
node_modules
.next
npm-debug.log
.husky
.github

Setup GCP environment

  • Start New Project and push docker image to gcp container registry

gcloud auth login
gcloud auth configure-docker
docker push asia.gcr.io/${PROJECT_ID}/${IMAGE_NAME}
  • Create New Service for run the docker image

Setup Pipeline

  • Set pipeline by using github action

References

Last updated

Was this helpful?