-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
87 lines (59 loc) · 2.06 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
79
80
81
82
83
84
85
86
87
# base node image
FROM node:18-bullseye-slim as base
# set for base and all layer that inherit from it
ENV NODE_ENV production
# Install openssl for Prisma
RUN apt-get update && apt-get install -y openssl curl
# Install all node_modules, including dev dependencies
FROM base as deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install --production=false
# Setup production node_modules
FROM base as production-deps
WORKDIR /app
COPY --from=deps /app/node_modules /app/node_modules
COPY package.json package-lock.json ./
RUN npm prune --production
# Build the app
FROM base as build
WORKDIR /app
COPY --from=deps /app/node_modules /app/node_modules
COPY prisma .
RUN npx prisma generate
ADD . .
RUN npm run build
FROM python:3.9-buster as python-docs-builder
WORKDIR /src/deltares_datasuite
ENV POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_VIRTUALENVS_IN_PROJECT=false \
POETRY_NO_INTERACTION=1 \
POETRY_VERSION=1.6.1
ENV PATH="$PATH:$POETRY_HOME/bin"
RUN pip install "poetry==$POETRY_VERSION"
COPY /utils/deltares_datasuite/poetry.lock /src/deltares_datasuite
COPY /utils/deltares_datasuite/pyproject.toml /src/deltares_datasuite
RUN poetry install
COPY /utils/deltares_datasuite /src/deltares_datasuite
RUN mkdocs build
# Build the dev image with dev dependencies
FROM base as dev
WORKDIR /app
COPY --from=deps /app/node_modules /app/node_modules
COPY --from=build /app/node_modules/.prisma /app/node_modules/.prisma
COPY --from=build /app/build /app/build
COPY --from=build /app/public /app/public
COPY --from=python-docs-builder /src/deltares_datasuite/site /app/public/docs
COPY . .
CMD ["npx", "remix", "dev"]
# Finally, build the production image with minimal footprint
FROM base as prod
WORKDIR /app
COPY --from=production-deps /app/node_modules /app/node_modules
COPY --from=build /app/node_modules/.prisma /app/node_modules/.prisma
COPY --from=build /app/build /app/build
COPY --from=build /app/public /app/public
COPY --from=python-docs-builder /src/deltares_datasuite/site /app/public/docs
COPY . .
CMD ["npm", "start"]