Docker 수정

This commit is contained in:
JongYeob Sheen 2023-11-13 12:16:57 +09:00
parent d8a5c1c0e4
commit 3c45282455
9 changed files with 49 additions and 17 deletions

View File

@ -1,5 +1,5 @@
//DATABASE_URL="mysql://root:fbOgZ6Xxn5VXBYihjqygRXyaK6ZUgKL6@db/learnsteam_quiz"
DATABASE_URL="mysql://learnsteam:fbOgZ6Xxn5VXBYihjqygRXyaK6ZUgKL6@127.0.0.1/learnsteam_quiz"
DATABASE_URL="mysql://root:fbOgZ6Xxn5VXBYihjqygRXyaK6ZUgKL6@db/learnsteam_quiz"
//DATABASE_URL="mysql://learnsteam:fbOgZ6Xxn5VXBYihjqygRXyaK6ZUgKL6@127.0.0.1/learnsteam_quiz"
NEXTAUTH_URL=https://learnsteam-quiz.jongyeob.com
NEXT_PUBLIC_API_ENDPOINT=https://learnsteam-quiz.jongyeob.com
NEXTAUTH_SECRET=dd87d8220ed9535d3152910f62ca40fb8ae292ac527e9528425118406aebbce0

View File

@ -1,6 +1,6 @@
//DATABASE_URL="mysql://learnsteam:fbOgZ6Xxn5VXBYihjqygRXyaK6ZUgKL6@jongyeob.com/learnsteam_quiz"
//DATABASE_URL="mysql://root:fbOgZ6Xxn5VXBYihjqygRXyaK6ZUgKL6@db/learnsteam_quiz"
DATABASE_URL="mysql://learnsteam:fbOgZ6Xxn5VXBYihjqygRXyaK6ZUgKL6@127.0.0.1/learnsteam_quiz"
DATABASE_URL="mysql://root:fbOgZ6Xxn5VXBYihjqygRXyaK6ZUgKL6@db/learnsteam_quiz"
//DATABASE_URL="mysql://learnsteam:fbOgZ6Xxn5VXBYihjqygRXyaK6ZUgKL6@127.0.0.1/learnsteam_quiz"
NEXTAUTH_URL=http://localhost:3000
NEXT_PUBLIC_HOST=http://localhost:3000
NEXT_PUBLIC_API_ENDPOINT=http://localhost:3000

View File

@ -1,3 +1,4 @@
DATABASE_URL="mysql://root:fbOgZ6Xxn5VXBYihjqygRXyaK6ZUgKL6@db/learnsteam_quiz"
//DATABASE_URL="mysql://learnsteam:fbOgZ6Xxn5VXBYihjqygRXyaK6ZUgKL6@jongyeob.com/learnsteam_quiz"
NEXTAUTH_URL=https://learnsteam-quiz.jongyeob.com
NEXT_PUBLIC_HOST=https://learnsteam-quiz.jongyeob.com

View File

@ -18,10 +18,14 @@ RUN yarn upgrade
RUN npx prisma generate
RUN yarn build
RUN npm prune --production
COPY ./script/start.sh .
RUN chmod +x start.sh
FROM alpine AS runner
RUN apk add --no-cache nodejs
RUN apk add --no-cache nodejs npm
RUN npm install npx -g
WORKDIR /app
ENV NODE_ENV production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
@ -31,9 +35,9 @@ COPY --from=builder --chown=nextjs:nodejs /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
# COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
# COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
# COPY --from=builder --chown=nextjs:nodejs /app/start.sh .
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
COPY --from=builder --chown=nextjs:nodejs /app/start.sh .
USER nextjs
EXPOSE 3000

View File

@ -1,10 +1,30 @@
version: "3"
services:
db:
image: mysql:latest
environment:
MYSQL_ROOT_PASSWORD: fbOgZ6Xxn5VXBYihjqygRXyaK6ZUgKL6
MYSQL_DATABASE: learnsteam_quiz
ports:
- "33062:3306"
volumes:
- db-data:/var/lib/mysql
app:
build:
context: ../../
dockerfile: docker/dev/Dockerfile
image: learnsteam/learnsteam-quiz:dev
ports:
- "3000:3000"
- "3100:3000"
environment:
DB_HOST: db
DB_PORT: 3306
DB_USER: root
DB_PASSWORD: fbOgZ6Xxn5VXBYihjqygRXyaK6ZUgKL6
DB_NAME: learnsteam_quiz
depends_on:
- db
restart: always
volumes:
db-data:

View File

@ -1,4 +1,4 @@
FROM node:alpine AS base
FROM node:21-alpine AS base
FROM base AS deps
RUN apk add --no-cache libc6-compat
@ -11,18 +11,20 @@ RUN yarn --frozen-lockfile
FROM base AS builder
WORKDIR /app
COPY .env.local.sample .env.production
COPY . .
COPY .env.local.sample .env
ENV NEXT_TELEMETRY_DISABLED 0
RUN yarn upgrade
RUN npx prisma generate
RUN yarn build
RUN npm prune --production
COPY ./script/start.sh .
RUN chmod +x start.sh
# FROM alpine AS runner
# RUN apk add --no-cache nodejs npm
# RUN npm install npx -g
# WORKDIR /app
FROM alpine AS runner
RUN apk add --no-cache nodejs npm
RUN npm install npx -g
WORKDIR /app
ENV NODE_ENV production
RUN addgroup --system --gid 1001 nodejs
@ -33,6 +35,7 @@ COPY --from=builder --chown=nextjs:nodejs /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
COPY --from=builder --chown=nextjs:nodejs /app/start.sh .

View File

@ -36,7 +36,6 @@ model Program {
@@map("program")
@@index([course])
@@index([tag])
@@index([status])
@@index([updated_at])
@@index([created_at])

5
script/start.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
npx prisma generate
npx prisma db push
node server.js

View File

@ -72,7 +72,7 @@ const QuizCheckPanel = (props: Props) => {
<Checkbox> </Checkbox>
</Form.Item>
<Flex gap="middle" wrap="wrap" style={{ flex: 1 }}>
<Preview source={quiz?.choice[1]} style={{ width: "100%" }} />
<Preview source={c} style={{ width: "100%" }} />
</Flex>
</Flex>
</Card>