-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
71 lines (56 loc) · 1.85 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
# --- BASE ---
FROM node:17-slim AS base
# set for base and all layer that inherit from it
ENV NODE_ENV production
# --- INSTALL EDGEDB-JS ---
FROM base as edgedb-deps
WORKDIR /build
COPY package.json .
RUN echo '{"dependencies": {' $(grep -E -o '"edgedb":\s"(.*)"' package.json) '}}' > package.json && yarn install
# --- GENERATE EDGEDB QUERY BUILDER ---
FROM edgedb/edgedb:1 AS edgedb
COPY --from=edgedb-deps /usr/local/bin/node /usr/local/bin/node
RUN mkdir /build && chown edgedb:edgedb /build
USER edgedb
WORKDIR /build
COPY --from=edgedb-deps /build .
COPY dbschema dbschema
# The generated edgeql-js client will be at /build/generated!
RUN edgedb-server \
-D /build/data \
--security insecure_dev_mode \
--runstate-dir /build/runstate \
& edgedb migration apply \
-H localhost \
--tls-security insecure \
--wait-until-available 2m \
&& node ./node_modules/.bin/edgeql-js \
-H localhost \
--target cjs \
--tls-security insecure \
--output-dir generated
# --- INSTALL ALL DEPENDENCIES ---
FROM base as deps
WORKDIR /app
COPY package.json yarn.lock ./
# Set env to dev so we can build the client app
RUN NODE_ENV=development yarn install --frozen-lockfile
# --- BUILD APP ---
FROM base as build
WORKDIR /app
ADD . .
COPY --from=deps /app/node_modules /app/node_modules
COPY --from=edgedb /build/generated /app/app/db/edgeql
# Prune out dev dependencies after building
# https://github.com/yarnpkg/yarn/issues/696#issuecomment-258418656
RUN yarn build && yarn install --production --ignore-scripts --prefer-offline
# --- PROD IMAGE ---
FROM base
WORKDIR /app
ADD . .
COPY --from=build /app/node_modules /app/node_modules
COPY --from=edgedb /build/generated /app/app/db/edgeql
COPY --from=edgedb /usr/bin/edgedb /usr/bin/edgedb
COPY --from=build /app/build /app/build
COPY --from=build /app/public /app/public
CMD ["yarn", "start"]