This repository has been archived by the owner on Jul 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
78 lines (56 loc) · 2.01 KB
/
Dockerfile
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# installs deps, used for caching
FROM node:16-alpine as dependencies
# install for deps that need it
RUN apk add --no-cache libc6-compat
# create working directory
WORKDIR /usr/src/salve
# copy files needed for dependencies
COPY package.json yarn.lock ./
# copy over prisma folder
COPY prisma prisma
# install dependencies
# also generates prisma client after install
RUN yarn install --immutable --inline-builds
# image that builds the project
FROM node:16-alpine as build
# create working directory
WORKDIR /usr/src/salve
# set db file location for prisma
ENV DATABASE_URL file:database/prod.db
# copy over dependencies from dependencies
COPY --from=dependencies /usr/src/salve/node_modules node_modules
# Bundle app source
COPY . .
# build app
RUN yarn build
# Setup db for prisma
RUN mkdir prisma/database
RUN yarn prisma migrate deploy
# clear cache & prune unnecessary dependencies for production
RUN yarn pruneDeps && \
yarn cache clean --mirror
# main image
FROM node:16-alpine as distribution
# define a bunch of metadata for the image
LABEL org.opencontainers.image.url="https://github.com/Huskydog9988/Salve"
LABEL org.opencontainers.image.documentation="https://github.com/Huskydog9988/Salve"
LABEL org.opencontainers.image.source="https://github.com/Huskydog9988/Salve"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.title="Salve"
LABEL org.opencontainers.image.description="An opensource and automated sign-in sheet"
# create working directory
WORKDIR /usr/src/salve
ENV PORT 8000
ENV NODE_ENV production
ENV DATABASE_URL file:database/prod.db
# user
# USER node
COPY --from=build /usr/src/salve/next.config.js next.config.js
COPY --from=build /usr/src/salve/public public
COPY --from=build /usr/src/salve/node_modules node_modules
COPY --from=build /usr/src/salve/dist dist
COPY --from=build /usr/src/salve/.next .next
COPY --from=build /usr/src/salve/prisma prisma
VOLUME [ "/usr/src/salve", "/usr/src/salve/prisma/database" ]
EXPOSE ${PORT}
CMD ["node", "dist/server/index.js"]