sdadfadas

Форк
0
/
Dockerfile 
179 строк · 6.9 Кб
1
#
2
# Licensed to the Apache Software Foundation (ASF) under one or more
3
# contributor license agreements.  See the NOTICE file distributed with
4
# this work for additional information regarding copyright ownership.
5
# The ASF licenses this file to You under the Apache License, Version 2.0
6
# (the "License"); you may not use this file except in compliance with
7
# the License.  You may obtain a copy of the License at
8
#
9
#    http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS,
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
# See the License for the specific language governing permissions and
15
# limitations under the License.
16
#
17

18
######################################################################
19
# Node stage to deal with static asset construction
20
######################################################################
21
ARG PY_VER=3.10-slim-bookworm
22

23
# if BUILDPLATFORM is null, set it to 'amd64' (or leave as is otherwise).
24
ARG BUILDPLATFORM=${BUILDPLATFORM:-amd64}
25
FROM --platform=${BUILDPLATFORM} node:18-bullseye-slim AS superset-node
26

27
ARG NPM_BUILD_CMD="build"
28

29
# Somehow we need python3 + build-essential on this side of the house to install node-gyp
30
RUN apt-get update -qq \
31
    && apt-get install \
32
        -yqq --no-install-recommends \
33
        build-essential \
34
        python3
35

36
ENV BUILD_CMD=${NPM_BUILD_CMD} \
37
    PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
38
# NPM ci first, as to NOT invalidate previous steps except for when package.json changes
39

40
RUN --mount=type=bind,target=/frontend-mem-nag.sh,src=./docker/frontend-mem-nag.sh \
41
    /frontend-mem-nag.sh
42

43
WORKDIR /app/superset-frontend
44
RUN --mount=type=bind,target=./package.json,src=./superset-frontend/package.json \
45
    --mount=type=bind,target=./package-lock.json,src=./superset-frontend/package-lock.json \
46
    npm ci
47

48
# Runs the webpack build process
49
COPY superset-frontend /app/superset-frontend
50
RUN npm run ${BUILD_CMD}
51

52
# This copies the .po files needed for translation
53
RUN mkdir -p /app/superset/translations
54
COPY superset/translations /app/superset/translations
55
# Compiles .json files from the .po files, then deletes the .po files
56
RUN npm run build-translation
57
RUN rm /app/superset/translations/*/LC_MESSAGES/*.po
58
RUN rm /app/superset/translations/messages.pot
59

60
######################################################################
61
# Final lean image...
62
######################################################################
63
FROM python:${PY_VER} AS lean
64

65
WORKDIR /app
66
ENV LANG=C.UTF-8 \
67
    LC_ALL=C.UTF-8 \
68
    SUPERSET_ENV=production \
69
    FLASK_APP="superset.app:create_app()" \
70
    PYTHONPATH="/app/pythonpath" \
71
    SUPERSET_HOME="/app/superset_home" \
72
    SUPERSET_PORT=8088
73

74
RUN mkdir -p ${PYTHONPATH} superset/static requirements superset-frontend apache_superset.egg-info requirements \
75
    && useradd --user-group -d ${SUPERSET_HOME} -m --no-log-init --shell /bin/bash superset \
76
    && apt-get update -qq && apt-get install -yqq --no-install-recommends \
77
        curl \
78
        default-libmysqlclient-dev \
79
        libsasl2-dev \
80
        libsasl2-modules-gssapi-mit \
81
        libpq-dev \
82
        libecpg-dev \
83
        libldap2-dev \
84
    && touch superset/static/version_info.json \
85
    && chown -R superset:superset ./* \
86
    && rm -rf /var/lib/apt/lists/*
87

88
COPY --chown=superset:superset pyproject.toml setup.py MANIFEST.in README.md ./
89
# setup.py uses the version information in package.json
90
COPY --chown=superset:superset superset-frontend/package.json superset-frontend/
91
COPY --chown=superset:superset requirements/base.txt requirements/
92
RUN --mount=type=cache,target=/root/.cache/pip \
93
    apt-get update -qq && apt-get install -yqq --no-install-recommends \
94
      build-essential \
95
    && pip install --upgrade setuptools pip \
96
    && pip install -r requirements/base.txt \
97
    && apt-get autoremove -yqq --purge build-essential \
98
    && rm -rf /var/lib/apt/lists/*
99

100
# Copy the compiled frontend assets
101
COPY --chown=superset:superset --from=superset-node /app/superset/static/assets superset/static/assets
102

103
## Lastly, let's install superset itself
104
COPY --chown=superset:superset superset superset
105
RUN --mount=type=cache,target=/root/.cache/pip \
106
    pip install -e .
107

108
# Copy the .json translations from the frontend layer
109
COPY --chown=superset:superset --from=superset-node /app/superset/translations superset/translations
110

111
# Compile translations for the backend - this generates .mo files, then deletes the .po files
112
COPY ./scripts/translations/generate_mo_files.sh ./scripts/translations/
113
RUN ./scripts/translations/generate_mo_files.sh \
114
    && chown -R superset:superset superset/translations \
115
    && rm superset/translations/messages.pot \
116
    && rm superset/translations/*/LC_MESSAGES/*.po
117

118
COPY --chmod=755 ./docker/run-server.sh /usr/bin/
119
USER superset
120

121
HEALTHCHECK CMD curl -f "http://localhost:${SUPERSET_PORT}/health"
122

123
EXPOSE ${SUPERSET_PORT}
124

125
CMD ["/usr/bin/run-server.sh"]
126

127
######################################################################
128
# Dev image...
129
######################################################################
130
FROM lean AS dev
131

132
USER root
133
RUN apt-get update -qq \
134
    && apt-get install -yqq --no-install-recommends \
135
        libnss3 \
136
        libdbus-glib-1-2 \
137
        libgtk-3-0 \
138
        libx11-xcb1 \
139
        libasound2 \
140
        libxtst6 \
141
        git \
142
        pkg-config \
143
        && rm -rf /var/lib/apt/lists/*
144

145
RUN --mount=type=cache,target=/root/.cache/pip \
146
    pip install playwright
147
RUN playwright install-deps
148
RUN playwright install chromium
149

150
# Install GeckoDriver WebDriver
151
ARG GECKODRIVER_VERSION=v0.34.0 \
152
    FIREFOX_VERSION=125.0.3
153

154
RUN apt-get update -qq \
155
    && apt-get install -yqq --no-install-recommends wget bzip2 \
156
    && wget -q https://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz -O - | tar xfz - -C /usr/local/bin \
157
    # Install Firefox
158
    && wget -q https://download-installer.cdn.mozilla.net/pub/firefox/releases/${FIREFOX_VERSION}/linux-x86_64/en-US/firefox-${FIREFOX_VERSION}.tar.bz2 -O - | tar xfj - -C /opt \
159
    && ln -s /opt/firefox/firefox /usr/local/bin/firefox \
160
    && apt-get autoremove -yqq --purge wget bzip2 && rm -rf /var/[log,tmp]/* /tmp/* /var/lib/apt/lists/*
161
# Cache everything for dev purposes...
162

163
COPY --chown=superset:superset requirements/development.txt requirements/
164
RUN --mount=type=cache,target=/root/.cache/pip \
165
    apt-get update -qq && apt-get install -yqq --no-install-recommends \
166
      build-essential \
167
    && pip install -r requirements/development.txt \
168
    && apt-get autoremove -yqq --purge build-essential \
169
    && rm -rf /var/lib/apt/lists/*
170

171
USER superset
172
######################################################################
173
# CI image...
174
######################################################################
175
FROM lean AS ci
176

177
COPY --chown=superset:superset --chmod=755 ./docker/*.sh /app/docker/
178

179
CMD ["/app/docker/docker-ci.sh"]
180

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.