JuneC
JuneC

Reputation: 69

Successfully deployed dockerized NextJS through GitHub Workflow to Github page, open website Get 200 but response weird

I dockerize a NextJs repository and deploy to Github Page.

all follow step-by-step with tutorial link here

Although deploy successfully and website Get 200,

but..., the Get has wrong response as below:

enter image description here

It should response the website UI.

Anyone could help :)

Upvotes: 0

Views: 539

Answers (1)

JuneC
JuneC

Reputation: 69

I fixed after setting DockerFile to:


# Install dependencies only when needed
FROM node:16-alpine AS deps

# Set label maintainer, version & description
LABEL maintainer="[email protected]"
LABEL version="0.1.0"
LABEL description="Unofficial Next.js + Typescript + Tailwind CSS starter with a latest package"

# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN yarn && yarn cache clean


# Rebuild the source code only when needed
FROM node:16-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN yarn build

# If using npm comment out above and use below instead
# RUN npm run build

# Production image, copy all the files and run next
FROM node:16-alpine AS runner
WORKDIR /app

ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/out ./


and .yml file to

name: Docker Image CI

on:
  push:
    branches: [ "master" ]

jobs:
  build-and-deploy:
    concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
    runs-on: ubuntu-latest
    steps:
      - name: Checkout 🛎️
        uses: actions/checkout@v3

      - name: Build and export
        uses: docker/build-push-action@v3
        with:
          context: .
          tags: myimage:latest
          outputs: type=local,dest=build
          secrets: |
            GIT_AUTH_TOKEN=${{ secrets.ACCESS_TOKEN }}

      - name: Deploy 🚀
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          folder: build/app # The folder the action should deploy.
          token: ${{ secrets.ACCESS_TOKEN }}
          BRANCH: gh-pages
          # clean: true

Upvotes: 0

Related Questions