2019-12-03 13:37:18 -05:00
|
|
|
#
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
|
|
# this work for additional information regarding copyright ownership.
|
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
# (the "License"); you may not use this file except in compliance with
|
|
|
|
# the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
|
2019-12-05 19:47:22 -05:00
|
|
|
######################################################################
|
|
|
|
# Node stage to deal with static asset construction
|
|
|
|
######################################################################
|
2023-06-23 13:23:51 -04:00
|
|
|
ARG PY_VER=3.9-slim-bookworm
|
2023-03-17 10:24:19 -04:00
|
|
|
|
|
|
|
# if BUILDPLATFORM is null, set it to 'amd64' (or leave as is otherwise).
|
|
|
|
ARG BUILDPLATFORM=${BUILDPLATFORM:-amd64}
|
2023-09-25 16:08:21 -04:00
|
|
|
FROM --platform=${BUILDPLATFORM} node:16-bookworm-slim AS superset-node
|
2021-02-15 14:45:29 -05:00
|
|
|
|
2020-03-13 12:25:54 -04:00
|
|
|
ARG NPM_BUILD_CMD="build"
|
2023-09-11 16:40:49 -04:00
|
|
|
|
2023-09-25 16:08:21 -04:00
|
|
|
RUN apt-get update -qq \
|
|
|
|
&& apt-get install -yqq --no-install-recommends \
|
|
|
|
build-essential \
|
|
|
|
python3
|
2023-09-11 16:40:49 -04:00
|
|
|
|
2023-08-28 14:07:07 -04:00
|
|
|
ENV BUILD_CMD=${NPM_BUILD_CMD} \
|
|
|
|
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
2019-12-05 19:47:22 -05:00
|
|
|
# NPM ci first, as to NOT invalidate previous steps except for when package.json changes
|
2023-06-24 14:41:57 -04:00
|
|
|
WORKDIR /app/superset-frontend
|
2022-10-06 11:08:10 -04:00
|
|
|
|
2023-08-28 14:07:07 -04:00
|
|
|
RUN --mount=type=bind,target=/frontend-mem-nag.sh,src=./docker/frontend-mem-nag.sh \
|
|
|
|
/frontend-mem-nag.sh
|
2019-12-03 13:37:18 -05:00
|
|
|
|
2023-09-25 16:08:21 -04:00
|
|
|
RUN --mount=type=bind,target=./package.json,src=./superset-frontend/package.json \
|
|
|
|
--mount=type=bind,target=./package-lock.json,src=./superset-frontend/package-lock.json \
|
|
|
|
npm ci
|
2022-10-06 11:08:10 -04:00
|
|
|
|
2023-06-24 14:41:57 -04:00
|
|
|
COPY ./superset-frontend ./
|
2022-10-06 11:08:10 -04:00
|
|
|
# This seems to be the most expensive step
|
|
|
|
RUN npm run ${BUILD_CMD}
|
2019-12-05 19:47:22 -05:00
|
|
|
|
|
|
|
######################################################################
|
2019-12-03 13:37:18 -05:00
|
|
|
# Final lean image...
|
2019-12-05 19:47:22 -05:00
|
|
|
######################################################################
|
|
|
|
FROM python:${PY_VER} AS lean
|
2019-12-03 13:37:18 -05:00
|
|
|
|
2023-06-24 14:41:57 -04:00
|
|
|
WORKDIR /app
|
2019-12-03 13:37:18 -05:00
|
|
|
ENV LANG=C.UTF-8 \
|
|
|
|
LC_ALL=C.UTF-8 \
|
2023-06-29 15:04:32 -04:00
|
|
|
SUPERSET_ENV=production \
|
2019-12-03 13:37:18 -05:00
|
|
|
FLASK_APP="superset.app:create_app()" \
|
|
|
|
PYTHONPATH="/app/pythonpath" \
|
|
|
|
SUPERSET_HOME="/app/superset_home" \
|
2021-03-12 11:13:11 -05:00
|
|
|
SUPERSET_PORT=8088
|
2019-12-03 13:37:18 -05:00
|
|
|
|
2023-12-07 07:54:59 -05:00
|
|
|
RUN mkdir -p ${PYTHONPATH} superset/static superset-frontend apache_superset.egg-info requirements \
|
2023-04-13 12:31:36 -04:00
|
|
|
&& useradd --user-group -d ${SUPERSET_HOME} -m --no-log-init --shell /bin/bash superset \
|
2023-09-25 16:08:21 -04:00
|
|
|
&& apt-get update -qq && apt-get install -yqq --no-install-recommends \
|
2023-04-13 12:31:36 -04:00
|
|
|
build-essential \
|
|
|
|
curl \
|
|
|
|
default-libmysqlclient-dev \
|
|
|
|
libsasl2-dev \
|
|
|
|
libsasl2-modules-gssapi-mit \
|
|
|
|
libpq-dev \
|
|
|
|
libecpg-dev \
|
2023-06-23 12:15:57 -04:00
|
|
|
libldap2-dev \
|
2023-08-28 14:07:07 -04:00
|
|
|
&& touch superset/static/version_info.json \
|
2023-12-07 07:54:59 -05:00
|
|
|
&& chown -R superset:superset ./* \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2023-04-13 12:31:36 -04:00
|
|
|
|
|
|
|
COPY --chown=superset:superset setup.py MANIFEST.in README.md ./
|
2022-10-06 11:08:10 -04:00
|
|
|
# setup.py uses the version information in package.json
|
2023-04-13 12:31:36 -04:00
|
|
|
COPY --chown=superset:superset superset-frontend/package.json superset-frontend/
|
2023-09-25 16:08:21 -04:00
|
|
|
RUN --mount=type=bind,target=./requirements/local.txt,src=./requirements/local.txt \
|
|
|
|
--mount=type=bind,target=./requirements/development.txt,src=./requirements/development.txt \
|
|
|
|
--mount=type=bind,target=./requirements/base.txt,src=./requirements/base.txt \
|
|
|
|
--mount=type=cache,target=/root/.cache/pip \
|
|
|
|
pip install -r requirements/local.txt
|
2022-10-06 11:08:10 -04:00
|
|
|
|
2023-04-13 12:31:36 -04:00
|
|
|
COPY --chown=superset:superset --from=superset-node /app/superset/static/assets superset/static/assets
|
2019-12-05 19:47:22 -05:00
|
|
|
## Lastly, let's install superset itself
|
2023-04-13 12:31:36 -04:00
|
|
|
COPY --chown=superset:superset superset superset
|
2023-09-25 16:08:21 -04:00
|
|
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
|
|
|
pip install -e . \
|
2023-08-28 14:07:07 -04:00
|
|
|
&& flask fab babel-compile --target superset/translations \
|
|
|
|
&& chown -R superset:superset superset/translations
|
2019-12-05 19:47:22 -05:00
|
|
|
|
2023-06-24 14:41:57 -04:00
|
|
|
COPY --chmod=755 ./docker/run-server.sh /usr/bin/
|
2019-12-03 13:37:18 -05:00
|
|
|
USER superset
|
|
|
|
|
2023-09-25 16:08:21 -04:00
|
|
|
HEALTHCHECK CMD curl -f "http://localhost:${SUPERSET_PORT}/health"
|
2019-12-03 13:37:18 -05:00
|
|
|
|
|
|
|
EXPOSE ${SUPERSET_PORT}
|
|
|
|
|
2023-04-13 12:31:36 -04:00
|
|
|
CMD ["/usr/bin/run-server.sh"]
|
2019-12-05 19:47:22 -05:00
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Dev image...
|
|
|
|
######################################################################
|
|
|
|
FROM lean AS dev
|
2023-09-14 17:23:48 -04:00
|
|
|
ARG GECKODRIVER_VERSION=v0.33.0 \
|
|
|
|
FIREFOX_VERSION=117.0.1
|
2019-12-05 19:47:22 -05:00
|
|
|
|
|
|
|
USER root
|
2021-04-22 12:42:52 -04:00
|
|
|
|
2023-12-07 07:54:59 -05:00
|
|
|
RUN apt-get update -qq \
|
|
|
|
&& apt-get install -yqq --no-install-recommends \
|
2023-04-13 12:31:36 -04:00
|
|
|
libnss3 \
|
|
|
|
libdbus-glib-1-2 \
|
|
|
|
libgtk-3-0 \
|
|
|
|
libx11-xcb1 \
|
|
|
|
libasound2 \
|
|
|
|
libxtst6 \
|
2023-06-24 14:41:57 -04:00
|
|
|
wget \
|
|
|
|
# Install GeckoDriver WebDriver
|
2023-09-25 16:08:21 -04:00
|
|
|
&& wget -q https://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz -O - | tar xfz - -C /usr/local/bin \
|
2023-06-24 14:41:57 -04:00
|
|
|
# Install Firefox
|
2023-09-25 16:08:21 -04:00
|
|
|
&& 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 \
|
2023-06-24 14:41:57 -04:00
|
|
|
&& ln -s /opt/firefox/firefox /usr/local/bin/firefox \
|
2023-12-07 07:54:59 -05:00
|
|
|
&& apt-get autoremove -yqq --purge wget && rm -rf /var/[log,tmp]/* /tmp/* /var/lib/apt/lists/*
|
2020-05-19 11:46:52 -04:00
|
|
|
# Cache everything for dev purposes...
|
2023-09-25 16:08:21 -04:00
|
|
|
RUN --mount=type=bind,target=./requirements/base.txt,src=./requirements/base.txt \
|
|
|
|
--mount=type=bind,target=./requirements/docker.txt,src=./requirements/docker.txt \
|
|
|
|
--mount=type=cache,target=/root/.cache/pip \
|
|
|
|
pip install -r requirements/docker.txt
|
2021-02-24 13:50:52 -05:00
|
|
|
|
2023-06-24 14:41:57 -04:00
|
|
|
USER superset
|
2021-02-24 13:50:52 -05:00
|
|
|
######################################################################
|
|
|
|
# CI image...
|
|
|
|
######################################################################
|
|
|
|
FROM lean AS ci
|
|
|
|
|
2023-08-28 14:07:07 -04:00
|
|
|
COPY --chown=superset:superset --chmod=755 ./docker/*.sh /app/docker/
|
2021-02-24 13:50:52 -05:00
|
|
|
|
2023-06-24 14:41:57 -04:00
|
|
|
CMD ["/app/docker/docker-ci.sh"]
|