diff --git a/.gitignore b/.gitignore index 0b9d5f3..a1c35a2 100755 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ yarn-error.log* # prisma prisma/dev.db* + +data/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..adccff8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,67 @@ +FROM node:18-alpine + +RUN yarn global add pnpm + +WORKDIR /app + +# Install dependencies based on the preferred package manager +COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ +RUN pnpm install + +COPY src ./src +COPY components ./components +COPY pages ./pages +COPY prisma ./prisma +COPY styles ./styles +COPY public ./public +COPY *.config.js . +COPY tsconfig.json . +COPY next-*.d.ts ./ + +# Environment variables must be present at build time +# https://github.com/vercel/next.js/discussions/14030 +ARG KEYCLOAK_ID +ENV KEYCLOAK_ID=${KEYCLOAK_ID} +ARG KEYCLOAK_SECRET +ENV KEYCLOAK_SECRET=${KEYCLOAK_SECRET} +ARG KEYCLOAK_ISSUER +ENV KEYCLOAK_ISSUER=${KEYCLOAK_ISSUER} + +ARG DISCORD_CLIENT_ID +ENV DISCORD_CLIENT_ID=${DISCORD_CLIENT_ID} +ARG DISCORD_CLIENT_SECRET +ENV DISCORD_CLIENT_SECRET=${DISCORD_CLIENT_SECRET} + +ARG GITHUB_CLIENT_ID +ENV GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID} +ARG GITHUB_CLIENT_SECRET +ENV GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET} + +ARG AUDIT_WEBHOOK +ENV AUDIT_WEBHOOK=${AUDIT_WEBHOOK} + +ARG MEILISEARCH_URL +ENV MEILISEARCH_URL=${MEILISEARCH_URL} +ARG NEXT_PUBLIC_MEILISEARCH_URL +ENV NEXT_PUBLIC_MEILISEARCH_URL=${NEXT_PUBLIC_MEILISEARCH_URL} + +ARG MEILISEARCH_KEY +ENV MEILISEARCH_KEY=${MEILISEARCH_KEY} +ARG NEXT_PUBLIC_MEILISEARCH_SEARCH_KEY +ENV NEXT_PUBLIC_MEILISEARCH_SEARCH_KEY=${NEXT_PUBLIC_MEILISEARCH_SEARCH_KEY} + +ARG NEXTAUTH_URL +ENV NEXTAUTH_URL=${NEXTAUTH_URL} +ARG NEXTAUTH_SECRET +ENV NEXTAUTH_SECRET=${NEXTAUTH_SECRET} + +ENV DATABASE_URL="file:/data/database.db" + +ENV NEXT_TELEMETRY_DISABLED 1 + +RUN pnpm prisma generate +RUN pnpm build + +COPY entry.sh ./ + +CMD ./entry.sh diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2f5923b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,25 @@ +version: '3' + +services: + comicbox: + build: + context: . + args: + KEYCLOAK_ID: ${KEYCLOAK_ID} + KEYCLOAK_SECRET: ${KEYCLOAK_SECRET} + KEYCLOAK_ISSUER: ${KEYCLOAK_ISSUER} + DISCORD_CLIENT_ID: ${DISCORD_CLIENT_ID} + DISCORD_CLIENT_SECRET: ${DISCORD_CLIENT_SECRET} + GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID} + GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET} + AUDIT_WEBHOOK: ${AUDIT_WEBHOOK} + MEILISEARCH_URL: ${MEILISEARCH_URL} + NEXT_PUBLIC_MEILISEARCH_URL: ${NEXT_PUBLIC_MEILISEARCH_URL} + MEILISEARCH_KEY: ${MEILISEARCH_KEY} + NEXT_PUBLIC_MEILISEARCH_SEARCH_KEY: ${NEXT_PUBLIC_MEILISEARCH_SEARCH_KEY} + NEXTAUTH_SECRET: ${NEXTAUTH_SECRET:-changeme} + NEXTAUTH_URL: ${NEXTAUTH_URL:-http://localhost:3030} + volumes: + - ./data:/data + ports: + - 3030:3000/tcp diff --git a/entry.sh b/entry.sh new file mode 100755 index 0000000..a4011eb --- /dev/null +++ b/entry.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +echo 'Running database migrations...' +pnpm prisma migrate deploy + +echo 'Seeding database...' +pnpm prisma db seed + +echo 'Starting server...' +pnpm start diff --git a/tsconfig.json b/tsconfig.json index 8e11ef7..c493b8c 100755 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,6 @@ "jsx": "preserve", "incremental": true }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], + "include": ["next-env.d.ts", "next-auth.d.ts", "**/*.ts", "**/*.tsx"], "exclude": ["node_modules"] }