frontend -

nextjs docker file

FROM node:20.10.0-alpine AS base
# Install dependencies only when needed
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /usr/src/app
# Install dependencies based on the preferred package manager
COPY package.json package-lock.json ./
RUN npm i -y
RUN rm -rf ./.next/cache
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /usr/src/app
COPY --from=deps /usr/src/app/node_modules ./node_modules
COPY . .
RUN npm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /usr/src/app
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /usr/src/app/public ./public
COPY --from=builder --chown=nextjs:nodejs /usr/src/app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /usr/src/app/.next/static ./.next/static
USER nextjs
# EXPOSE 3000
CMD ["node", "server.js"]

next.config.js

const nextConfig = {
  reactStrictMode: false,
  async rewrites() {
    return [
      {
        source: '/naver/:path*',
        destination: '<https://openapi.naver.com/:path*>',
      },
    ];
  },
  images: {
    remotePatterns: [
      {
        protocol: 'https',
        hostname: 'media1.jjalkey.com',
      },
      {
        protocol: 'https',
        hostname: 'ahwhew.site',
      },
      {
        protocol: 'https',
        hostname: 'example-bucket-seeun.s3.ap-northeast-2.amazonaws.com',
      },
    ],
  },
  output: 'standalone', // 이 줄을 추가하여 두 설정을 합침
};

module.exports = nextConfig;

.env.local

## API server
NEXT_PUBLIC_API_SERVER=http://3.39.126.198:8080
# NEXT_PUBLIC_API_SERVER=http:/ahwhew.shop:8080
# NEXT_PUBLIC_API_SERVER=http://localhost:8080

## profile
NEXT_PUBLIC_NAVER_API_CLIENT_ID=zU_PN2dzVWNX6xNUBsQe
NEXT_PUBLIC_NAVER_API_CLIENT_SECRET=LWe_w7kUpV
NEXT_PUBLIC_CHATGPT_API_KEY=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

## result
NEXT_PUBLIC_KAKAO_API_KEY=d65386a1ee38b21938fa479ee3c61b24

Backend

dockerfile

FROM openjdk:17

ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar

ENTRYPOINT ["java", "-Xmx512m", "-jar", "/app.jar"]