feat(deploy): add dockerfile and docker-compose.yml for deployment

This commit is contained in:
Ashhhleyyy 2022-08-06 23:53:23 +01:00
parent 89e3da539f
commit ee1fe019d5
Signed by: ash
GPG key ID: 83B789081A0878FB
5 changed files with 105 additions and 1 deletions

2
.gitignore vendored
View file

@ -37,3 +37,5 @@ yarn-error.log*
# prisma
prisma/dev.db*
data/

67
Dockerfile Normal file
View file

@ -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

25
docker-compose.yml Normal file
View file

@ -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

10
entry.sh Executable file
View file

@ -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

View file

@ -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"]
}