Skip to content

Commit

Permalink
chore(e2e): seed db before run
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogradov committed Aug 10, 2023
1 parent b6bb7d4 commit 065c274
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 15 deletions.
11 changes: 11 additions & 0 deletions .env.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
NODE_ENV=production

DATABASE_URL=postgresql://prisma:hilly-sand-pit@db:5432/prisma?schema=prisma-pg-test
NEXTAUTH_URL=http://localhost:3000
NEXT_PUBLIC_NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=ololo
ADMIN_EMAIL=test@taskany.org
ADMIN_PASSWORD=test
MAIL_USER=notify@taskany.org
SENTRY_DISABLED=1
SENTRY_IGNORE_API_RESOLUTION_ERROR=1
30 changes: 30 additions & 0 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM node:18.12.0-alpine as build

WORKDIR /app
COPY . .
RUN mv .env.ci .env
RUN npm ci --no-audit --progress=false
RUN npx next telemetry disable
RUN npm run build

FROM node:18.12.0-alpine AS runner

WORKDIR /app
COPY --from=build /app/.env ./
COPY --from=build /app/app_run.ci.sh ./
COPY --from=build /app/src ./src
COPY --from=build /app/package*.json ./
COPY --from=build /app/prisma ./prisma
COPY --from=build /app/public ./public
COPY --from=build /app/version ./public/version.txt
COPY --from=build /app/.next ./.next
COPY --from=build /app/next.config.js ./
COPY --from=build /app/.next/standalone ./
COPY --from=build /app/background ./background
COPY --from=build /app/node_modules ./node_modules

RUN npx prisma generate

EXPOSE 3000

CMD sh ./app_run.ci.sh
4 changes: 4 additions & 0 deletions app_run.ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
npx prisma migrate deploy
npx prisma db seed
node_modules/.bin/concurrently 'node background/worker/index.js' 'node server.js'
15 changes: 1 addition & 14 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,6 @@ services:
- 3000:3000
build:
context: .
dockerfile: Dockerfile
dockerfile: Dockerfile.ci
depends_on:
- db
environment:
- DATABASE_URL=postgresql://prisma:hilly-sand-pit@db:5432/prisma?schema=prisma-pg-test
- NEXTAUTH_URL=http://localhost:3000
- NEXT_PUBLIC_NEXTAUTH_URL=http://localhost:3000
- NEXTAUTH_SECRET=ololo
- ADMIN_EMAIL=test@taskany.org
- ADMIN_PASSWORD=test
- MAIL_USER=notify@taskany.org
- SENTRY_DISABLED=1
- SENTRY_IGNORE_API_RESOLUTION_ERROR=1
command: >
sh -c "node_modules/.bin/prisma migrate dev &&
node_modules/.bin/concurrently 'node background/worker/index.js' 'node server.js'"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"db:migrate": "npx prisma migrate deploy",
"db:seed": "npx prisma db seed",
"worker": "ts-node -r dotenv/config src/utils/worker/index.ts",
"build": "next build && npm run build:worker",
"build": "concurrently \"next build\" \"npm run build:worker\"",
"build:worker": "tsc -p ./src/utils/worker",
"build:analyze": "ANALYZE=true next build",
"start": "concurrently \"npm run worker\" \"next start\"",
Expand Down

0 comments on commit 065c274

Please sign in to comment.