forked from lightdash/lightdash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerfile-prs
147 lines (119 loc) · 4.06 KB
/
dockerfile-prs
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# -----------------------------
# Stage 0: install dependencies
# -----------------------------
FROM node:16-bullseye AS base
WORKDIR /usr/app
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
g++ \
libsasl2-modules-gssapi-mit \
nodejs \
python3 \
python3-psycopg2 \
python3-venv \
software-properties-common \
unzip \
wget \
&& apt-get clean
# Installing multiple versions of dbt
# dbt 1.4 is the default
RUN python3 -m venv /usr/local/dbt1.4
RUN /usr/local/dbt1.4/bin/pip install \
"dbt-postgres~=1.4.0" \
"dbt-redshift~=1.4.0" \
"dbt-snowflake~=1.4.0" \
"dbt-bigquery~=1.4.0" \
"dbt-databricks~=1.4.0" \
"dbt-trino~=1.4.0" \
"psycopg2-binary==2.8.6"
RUN ln -s /usr/local/dbt1.4/bin/dbt /usr/local/bin/dbt
RUN python3 -m venv /usr/local/dbt1.5
RUN /usr/local/dbt1.5/bin/pip install \
"dbt-postgres~=1.5.0" \
"dbt-redshift~=1.5.0" \
"dbt-snowflake~=1.5.0" \
"dbt-bigquery~=1.5.0" \
"dbt-databricks~=1.5.0" \
"dbt-trino~=1.5.0" \
"psycopg2-binary==2.8.6"
RUN ln -s /usr/local/dbt1.5/bin/dbt /usr/local/bin/dbt1.5
# -----------------------------
# Stage 1: stop here for dev environment
# -----------------------------
FROM base AS dev
EXPOSE 3000
EXPOSE 8080
# -----------------------------
# Stage 2: continue build for production environment
# -----------------------------
FROM base AS prod-builder
# Install development dependencies for all
COPY package.json .
COPY yarn.lock .
COPY tsconfig.json .
COPY .eslintrc.js .
COPY packages/common/package.json ./packages/common/
COPY packages/warehouses/package.json ./packages/warehouses/
COPY packages/backend/package.json ./packages/backend/
COPY packages/frontend/package.json ./packages/frontend/
RUN yarn install --pure-lockfile --non-interactive
# Build common
COPY packages/common/tsconfig.json ./packages/common/
COPY packages/common/src/ ./packages/common/src/
RUN yarn --cwd ./packages/common/ build
# Build warehouses
COPY packages/warehouses/tsconfig.json ./packages/warehouses/
COPY packages/warehouses/src/ ./packages/warehouses/src/
RUN yarn --cwd ./packages/warehouses/ build
# Build backend
COPY packages/backend/tsconfig.json ./packages/backend/
COPY packages/backend/src/ ./packages/backend/src
RUN yarn --cwd ./packages/backend/ build
# Build frontend
COPY packages/frontend ./packages/frontend
RUN yarn --cwd ./packages/frontend/ build
# Cleanup development dependencies
RUN rm -rf node_modules
RUN rm -rf packages/*/node_modules
# Install production dependencies
ENV NODE_ENV production
RUN yarn install --pure-lockfile --non-interactive --production
# -----------------------------
# Stage 3: execution environment for backend
# -----------------------------
FROM node:16-bullseye as prod
WORKDIR /usr/app
ENV NODE_ENV production
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
python3-psycopg2 \
python3-venv \
&& apt-get clean
COPY --from=prod-builder /usr/local/dbt1.4 /usr/local/dbt1.4
COPY --from=prod-builder /usr/local/dbt1.5 /usr/local/dbt1.5
COPY --from=prod-builder /usr/app /usr/app
RUN ln -s /usr/local/dbt1.4/bin/dbt /usr/local/bin/dbt
RUN ln -s /usr/local/dbt1.5/bin/dbt /usr/local/bin/dbt1.5
# Production config
COPY lightdash.yml /usr/app/lightdash.yml
ENV LIGHTDASH_CONFIG_FILE /usr/app/lightdash.yml
# Run backend
COPY ./docker/prod-entrypoint.sh /usr/bin/prod-entrypoint.sh
EXPOSE 8080
ENTRYPOINT ["/usr/bin/prod-entrypoint.sh"]
# -------------------------
# Stage 4: Extend with demo
# -------------------------
FROM prod as demo
# PR preview config
ENV NODE_ENV production
ENV DBT_DEMO_DIR /usr/app
COPY lightdash-pr.yml /usr/app/lightdash.yml
ENV LIGHTDASH_CONFIG_FILE /usr/app/lightdash.yml
ARG RENDER_EXTERNAL_URL
ENV SITE_URL=$RENDER_EXTERNAL_URL
COPY ./examples/full-jaffle-shop-demo/dbt /usr/app/dbt
COPY ./examples/full-jaffle-shop-demo/profiles /usr/app/profiles
COPY ./examples/full-jaffle-shop-demo/entrypoint.sh /usr/bin/entrypoint.sh
COPY ./examples/full-jaffle-shop-demo/renderDeployHook.sh /usr/bin/renderDeployHook.sh
CMD ["yarn", "start"]