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
|
|
|
######################################################################
|
|
|
|
# PY stage that simply does a pip install on our requirements
|
|
|
|
######################################################################
|
2020-09-09 01:51:55 -04:00
|
|
|
ARG PY_VER=3.7.9
|
2019-12-03 13:37:18 -05:00
|
|
|
FROM python:${PY_VER} AS superset-py
|
|
|
|
|
|
|
|
RUN mkdir /app \
|
|
|
|
&& apt-get update -y \
|
|
|
|
&& apt-get install -y --no-install-recommends \
|
|
|
|
build-essential \
|
|
|
|
default-libmysqlclient-dev \
|
|
|
|
libpq-dev \
|
2020-08-08 21:56:20 -04:00
|
|
|
libsasl2-dev \
|
2020-12-04 22:17:23 -05:00
|
|
|
libecpg-dev \
|
2019-12-03 13:37:18 -05:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
2019-12-05 19:47:22 -05:00
|
|
|
# First, we just wanna install requirements, which will allow us to utilize the cache
|
|
|
|
# in order to only build if and only if requirements change
|
2020-08-08 21:56:20 -04:00
|
|
|
COPY ./requirements/*.txt /app/requirements/
|
|
|
|
COPY setup.py MANIFEST.in README.md /app/
|
|
|
|
COPY superset-frontend/package.json /app/superset-frontend/
|
2019-12-03 13:37:18 -05:00
|
|
|
RUN cd /app \
|
2020-08-08 21:56:20 -04:00
|
|
|
&& mkdir -p superset/static \
|
|
|
|
&& touch superset/static/version_info.json \
|
|
|
|
&& pip install --no-cache -r requirements/local.txt
|
2019-12-03 13:37:18 -05:00
|
|
|
|
|
|
|
|
2019-12-05 19:47:22 -05:00
|
|
|
######################################################################
|
|
|
|
# Node stage to deal with static asset construction
|
|
|
|
######################################################################
|
2021-02-20 12:42:51 -05:00
|
|
|
FROM node:14 AS superset-node
|
2019-12-03 13:37:18 -05:00
|
|
|
|
2021-02-15 14:45:29 -05:00
|
|
|
ARG NPM_VER=7
|
|
|
|
RUN npm install -g npm@${NPM_VER}
|
|
|
|
|
2020-03-13 12:25:54 -04:00
|
|
|
ARG NPM_BUILD_CMD="build"
|
|
|
|
ENV BUILD_CMD=${NPM_BUILD_CMD}
|
|
|
|
|
2019-12-05 19:47:22 -05:00
|
|
|
# NPM ci first, as to NOT invalidate previous steps except for when package.json changes
|
2020-02-09 20:53:56 -05:00
|
|
|
RUN mkdir -p /app/superset-frontend
|
2020-02-12 10:48:24 -05:00
|
|
|
RUN mkdir -p /app/superset/assets
|
2020-03-13 12:25:54 -04:00
|
|
|
COPY ./docker/frontend-mem-nag.sh /
|
2020-02-09 20:53:56 -05:00
|
|
|
COPY ./superset-frontend/package* /app/superset-frontend/
|
2020-03-13 12:25:54 -04:00
|
|
|
RUN /frontend-mem-nag.sh \
|
|
|
|
&& cd /app/superset-frontend \
|
2019-12-05 19:47:22 -05:00
|
|
|
&& npm ci
|
2019-12-03 13:37:18 -05:00
|
|
|
|
2019-12-05 19:47:22 -05:00
|
|
|
# Next, copy in the rest and let webpack do its thing
|
2020-02-09 20:53:56 -05:00
|
|
|
COPY ./superset-frontend /app/superset-frontend
|
2019-12-05 19:47:22 -05:00
|
|
|
# This is BY FAR the most expensive step (thanks Terser!)
|
2020-02-09 20:53:56 -05:00
|
|
|
RUN cd /app/superset-frontend \
|
2020-03-13 12:25:54 -04:00
|
|
|
&& npm run ${BUILD_CMD} \
|
2019-12-03 13:37:18 -05:00
|
|
|
&& rm -rf node_modules
|
|
|
|
|
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
|
|
|
######################################################################
|
2020-09-11 07:33:15 -04:00
|
|
|
ARG PY_VER=3.7.9
|
2019-12-05 19:47:22 -05:00
|
|
|
FROM python:${PY_VER} AS lean
|
2019-12-03 13:37:18 -05:00
|
|
|
|
|
|
|
ENV LANG=C.UTF-8 \
|
|
|
|
LC_ALL=C.UTF-8 \
|
|
|
|
FLASK_ENV=production \
|
|
|
|
FLASK_APP="superset.app:create_app()" \
|
|
|
|
PYTHONPATH="/app/pythonpath" \
|
|
|
|
SUPERSET_HOME="/app/superset_home" \
|
|
|
|
SUPERSET_PORT=8080
|
|
|
|
|
|
|
|
RUN useradd --user-group --no-create-home --no-log-init --shell /bin/bash superset \
|
|
|
|
&& mkdir -p ${SUPERSET_HOME} ${PYTHONPATH} \
|
|
|
|
&& apt-get update -y \
|
|
|
|
&& apt-get install -y --no-install-recommends \
|
|
|
|
build-essential \
|
|
|
|
default-libmysqlclient-dev \
|
|
|
|
libpq-dev \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
2020-09-11 07:33:15 -04:00
|
|
|
COPY --from=superset-py /usr/local/lib/python3.7/site-packages/ /usr/local/lib/python3.7/site-packages/
|
2019-12-03 13:37:18 -05:00
|
|
|
# Copying site-packages doesn't move the CLIs, so let's copy them one by one
|
2019-12-05 19:47:22 -05:00
|
|
|
COPY --from=superset-py /usr/local/bin/gunicorn /usr/local/bin/celery /usr/local/bin/flask /usr/bin/
|
2020-02-12 10:48:24 -05:00
|
|
|
COPY --from=superset-node /app/superset/static/assets /app/superset/static/assets
|
2020-02-09 20:53:56 -05:00
|
|
|
COPY --from=superset-node /app/superset-frontend /app/superset-frontend
|
2019-12-03 13:37:18 -05:00
|
|
|
|
2019-12-05 19:47:22 -05:00
|
|
|
## Lastly, let's install superset itself
|
|
|
|
COPY superset /app/superset
|
|
|
|
COPY setup.py MANIFEST.in README.md /app/
|
|
|
|
RUN cd /app \
|
|
|
|
&& chown -R superset:superset * \
|
|
|
|
&& pip install -e .
|
|
|
|
|
2019-12-03 13:37:18 -05:00
|
|
|
COPY ./docker/docker-entrypoint.sh /usr/bin/
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
USER superset
|
|
|
|
|
2020-11-24 15:39:10 -05:00
|
|
|
HEALTHCHECK CMD curl -f "http://localhost:$SUPERSET_PORT/health"
|
2019-12-03 13:37:18 -05:00
|
|
|
|
|
|
|
EXPOSE ${SUPERSET_PORT}
|
|
|
|
|
|
|
|
ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]
|
2019-12-05 19:47:22 -05:00
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Dev image...
|
|
|
|
######################################################################
|
|
|
|
FROM lean AS dev
|
|
|
|
|
2020-08-08 21:56:20 -04:00
|
|
|
COPY ./requirements/*.txt ./docker/requirements-*.txt/ /app/requirements/
|
2019-12-05 19:47:22 -05:00
|
|
|
|
|
|
|
USER root
|
2020-05-19 11:46:52 -04:00
|
|
|
# Cache everything for dev purposes...
|
2019-12-05 19:47:22 -05:00
|
|
|
RUN cd /app \
|
2020-08-08 21:56:20 -04:00
|
|
|
&& pip install --no-cache -r requirements/docker.txt \
|
|
|
|
&& pip install --no-cache -r requirements/requirements-local.txt || true
|
2020-02-09 20:53:56 -05:00
|
|
|
USER superset
|
2021-02-24 13:50:52 -05:00
|
|
|
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# CI image...
|
|
|
|
######################################################################
|
|
|
|
FROM lean AS ci
|
|
|
|
|
|
|
|
COPY --chown=superset ./docker/docker-bootstrap.sh /app/docker/
|
|
|
|
COPY --chown=superset ./docker/docker-init.sh /app/docker/
|
|
|
|
COPY --chown=superset ./docker/docker-ci.sh /app/docker/
|
|
|
|
|
|
|
|
RUN chmod a+x /app/docker/*.sh
|
|
|
|
|
|
|
|
CMD /app/docker/docker-ci.sh
|