forked from nemanjam/nextjs-prisma-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.test
52 lines (37 loc) · 1.17 KB
/
Dockerfile.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# use alpine for tests like prod
ARG BASE=node:16-alpine
# simplified prod build
# migrate, seed, build
#---------------------
FROM ${BASE} AS dependencies
RUN whoami && id
# openssl for prisma client, bash for jest-preview
RUN apk update && apk add --no-cache openssl libc6-compat bash
WORKDIR /app
ENV NODE_ENV development
# prepare only node_modules and prisma client
# src will be mounted via volume
# build at runtime, not here
COPY package.json yarn.lock ./
COPY prisma ./prisma
# dev dependencies for api integration testing
RUN yarn install
RUN npx prisma generate
RUN rm -rf prisma
ENV NODE_ENV test
# volumes folders must be created and chowned before docker-compose creates them as root
# create them during docker build
RUN mkdir -p .next dist
RUN chown node:node . node_modules .next dist
RUN chown -R node:node node_modules/.prisma
USER node
# on container
EXPOSE 3001
# env for app
ENV PORT 3001
# build app at runtime, not here
# api integration tests dont need built prod app, Jest runs code
# 1. migrate prod, 2. build app, 3. start prod
# default: just 1. migrate and shut down - for integration tests
# for e2e: 1, 2 and 3
CMD [ "yarn", "prisma:migrate:prod" ]