forked from lightdash/lightdash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerfile-prs
187 lines (157 loc) · 5.44 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# -----------------------------
# Stage 0: install dependencies
# -----------------------------
FROM node:20-bookworm-slim AS base
WORKDIR /usr/app
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
g++ \
libsasl2-modules-gssapi-mit \
python3 \
python3-psycopg2 \
python3-venv \
python3-dev \
software-properties-common \
unzip \
git \
&& apt-get clean
# Fix package vulnerabilities
RUN apt-get update && apt-get install -y --no-install-recommends \
libgnutls28-dev \
tar \
libsystemd0
# Installing multiple versions of dbt
# dbt 1.4 is the default
RUN python3 -m venv /usr/local/dbt1.4 \
&& /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.9.6"
RUN ln -s /usr/local/dbt1.4/bin/dbt /usr/local/bin/dbt\
&& python3 -m venv /usr/local/dbt1.5 \
&& /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.9.6" \
&& ln -s /usr/local/dbt1.5/bin/dbt /usr/local/bin/dbt1.5
RUN python3 -m venv /usr/local/dbt1.6 \
&& /usr/local/dbt1.6/bin/pip install \
"dbt-postgres~=1.6.0" \
"dbt-redshift~=1.6.0" \
"dbt-snowflake~=1.6.0" \
"dbt-bigquery~=1.6.0" \
"dbt-databricks~=1.6.0" \
"dbt-trino==1.6.0" \
"psycopg2-binary==2.9.6"\
&& ln -s /usr/local/dbt1.6/bin/dbt /usr/local/bin/dbt1.6
RUN python3 -m venv /usr/local/dbt1.7 \
&& /usr/local/dbt1.7/bin/pip install \
"dbt-postgres~=1.7.0" \
"dbt-redshift~=1.7.0" \
"dbt-snowflake~=1.7.0" \
"dbt-bigquery~=1.7.0" \
"dbt-databricks~=1.7.0" \
"dbt-trino==1.7.0" \
"psycopg2-binary==2.9.6" \
&& ln -s /usr/local/dbt1.7/bin/dbt /usr/local/bin/dbt1.7
RUN python3 -m venv /usr/local/dbt1.8 \
&& /usr/local/dbt1.8/bin/pip install \
"dbt-core~=1.8.0" \
"dbt-postgres~=1.8.0" \
"dbt-redshift~=1.8.0" \
"dbt-snowflake~=1.8.0" \
"dbt-bigquery~=1.8.0" \
"dbt-databricks~=1.8.0" \
"dbt-trino~=1.8.0" \
&& ln -s /usr/local/dbt1.8/bin/dbt /usr/local/bin/dbt1.8
# -----------------------------
# 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 \
&& 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:20-bookworm-slim 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 \
git \
&& 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/local/dbt1.6 /usr/local/dbt1.6
COPY --from=prod-builder /usr/local/dbt1.7 /usr/local/dbt1.7
COPY --from=prod-builder /usr/local/dbt1.8 /usr/local/dbt1.8
COPY --from=prod-builder /usr/app /usr/app
RUN ln -s /usr/local/dbt1.4/bin/dbt /usr/local/bin/dbt \
&& ln -s /usr/local/dbt1.5/bin/dbt /usr/local/bin/dbt1.5 \
&& ln -s /usr/local/dbt1.6/bin/dbt /usr/local/bin/dbt1.6 \
&& ln -s /usr/local/dbt1.7/bin/dbt /usr/local/bin/dbt1.7 \
&& ln -s /usr/local/dbt1.8/bin/dbt /usr/local/bin/dbt1.8
# 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 LIGHTDASH_MODE pr
ENV DBT_DEMO_DIR /usr/app
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"]