Skip to content

Commit

Permalink
Merge branch 'masterzain3' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mz0in authored Apr 23, 2024
2 parents cfc440c + 5578774 commit 63063d6
Show file tree
Hide file tree
Showing 42 changed files with 316 additions and 54 deletions.
125 changes: 125 additions & 0 deletions Dockerfile.devfinal
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
######################################################################
# Node stage to deal with static asset construction
######################################################################
ARG PY_VER=3.9-slim-bookworm

# if BUILDPLATFORM is null, set it to 'amd64' (or leave as is otherwise).
ARG BUILDPLATFORM=${BUILDPLATFORM:-amd64}
FROM --platform=${BUILDPLATFORM} node:16-bookworm-slim AS superset-node

ARG NPM_BUILD_CMD="build"

RUN apt-get update -qq \
&& apt-get install -yqq --no-install-recommends \
build-essential \
python3

ENV BUILD_CMD=${NPM_BUILD_CMD} \
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
# NPM ci first, as to NOT invalidate previous steps except for when package.json changes
WORKDIR /app/superset-frontend

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

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

COPY ./superset-frontend ./
# This seems to be the most expensive step
RUN npm run ${BUILD_CMD}

######################################################################
# Final lean image...
######################################################################
FROM python:${PY_VER} AS lean

WORKDIR /app
ENV LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
SUPERSET_ENV=production \
FLASK_APP="superset.app:create_app()" \
PYTHONPATH="/app/pythonpath" \
SUPERSET_HOME="/app/superset_home" \
SUPERSET_PORT=8088

RUN mkdir -p ${PYTHONPATH} superset/static requirements superset-frontend apache_superset.egg-info requirements \
&& useradd --user-group -d ${SUPERSET_HOME} -m --no-log-init --shell /bin/bash superset \
&& apt-get update -qq && apt-get install -yqq --no-install-recommends \
build-essential \
curl \
default-libmysqlclient-dev \
libsasl2-dev \
libsasl2-modules-gssapi-mit \
libpq-dev \
libecpg-dev \
libldap2-dev \
&& touch superset/static/version_info.json \
&& chown -R superset:superset ./* \
&& rm -rf /var/lib/apt/lists/*

COPY --chown=superset:superset setup.py MANIFEST.in README.md ./
# setup.py uses the version information in package.json
COPY --chown=superset:superset superset-frontend/package.json superset-frontend/
COPY --chown=superset:superset requirements/base.txt requirements/
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --upgrade setuptools pip && \
pip install -r requirements/base.txt

COPY --chown=superset:superset --from=superset-node /app/superset/static/assets superset/static/assets
## Lastly, let's install superset itself
COPY --chown=superset:superset superset superset
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -e . \
&& flask fab babel-compile --target superset/translations \
&& chown -R superset:superset superset/translations

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

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

EXPOSE ${SUPERSET_PORT}

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

######################################################################
# Dev image...
######################################################################
FROM lean AS dev
ARG GECKODRIVER_VERSION=v0.33.0 \
FIREFOX_VERSION=117.0.1

USER root

RUN apt-get update -qq \
&& apt-get install -yqq --no-install-recommends \
libnss3 \
libdbus-glib-1-2 \
libgtk-3-0 \
libx11-xcb1 \
libasound2 \
libxtst6 \
wget \
# Install GeckoDriver WebDriver
&& wget -q https://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz -O - | tar xfz - -C /usr/local/bin \
# Install Firefox
&& 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 \
&& ln -s /opt/firefox/firefox /usr/local/bin/firefox \
&& apt-get autoremove -yqq --purge wget && rm -rf /var/[log,tmp]/* /tmp/* /var/lib/apt/lists/*
# Cache everything for dev purposes...

COPY --chown=superset:superset requirements/development.txt requirements/
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -r requirements/development.txt

USER superset
######################################################################
# CI image...
######################################################################
FROM dev AS devfinal

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

CMD ["/app/docker/docker-ci.sh"]
137 changes: 137 additions & 0 deletions Dockerfile.zain
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
############ Zain Note ############
# ARG PY_VER=3.9-slim-bookworm ## Old version upgraded to ARG PY_VER=3.11-slim-bookworm
# node:16-bookworm-slim ## Old version upgraded to node:21-bookworm-slim
# ARG GECKODRIVER_VERSION=v0.29.0 ## you should be noted that GECKODRIVER should be compatible with FIREFOX_VERSION or report delivery will not work
# FIREFOX_VERSION=117.0.1
############ Zain Note End ############

######################################################################
# Node stage to deal with static asset construction
######################################################################
ARG PY_VER=3.11-slim-bookworm
# if BUILDPLATFORM is null, set it to 'amd64' (or leave as is otherwise).
ARG BUILDPLATFORM=${BUILDPLATFORM:-amd64}
FROM --platform=${BUILDPLATFORM} node:21-bullseye-slim AS superset-node

ARG NPM_BUILD_CMD="build"

RUN apt-get update -qq \
&& apt-get install -yqq --no-install-recommends \
build-essential \
python3

ENV BUILD_CMD=${NPM_BUILD_CMD} \
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
# NPM ci first, as to NOT invalidate previous steps except for when package.json changes
WORKDIR /app/superset-frontend

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

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

COPY ./superset-frontend ./
# This seems to be the most expensive step
RUN npm run ${BUILD_CMD}

######################################################################
# Final lean image...
######################################################################
FROM python:${PY_VER} AS lean


WORKDIR /app
ENV LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
SUPERSET_ENV=production \
FLASK_APP="superset.app:create_app()" \
PYTHONPATH="/app/pythonpath" \
SUPERSET_HOME="/app/superset_home" \
SUPERSET_PORT=8088

RUN mkdir -p ${PYTHONPATH} superset/static requirements superset-frontend apache_superset.egg-info requirements \
&& useradd --user-group -d ${SUPERSET_HOME} -m --no-log-init --shell /bin/bash superset \
&& apt-get update -qq && apt-get install -yqq --no-install-recommends \
build-essential \
curl \
default-libmysqlclient-dev \
libsasl2-dev \
libsasl2-modules-gssapi-mit \
libpq-dev \
libecpg-dev \
libldap2-dev \
&& touch superset/static/version_info.json \
&& chown -R superset:superset ./* \
&& rm -rf /var/lib/apt/lists/*


COPY --chown=superset:superset setup.py MANIFEST.in README.md ./
# setup.py uses the version information in package.json
COPY --chown=superset:superset superset-frontend/package.json superset-frontend/
COPY --chown=superset:superset requirements/base.txt requirements/
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --upgrade pip && \
pip install uv && \
pip install -r requirements/base.txt \
uv pip install setuptools Pillow psycopg2-binary gevent ## this is by zain to fix issue not working


COPY --chown=superset:superset --from=superset-node /app/superset/static/assets superset/static/assets
## Lastly, let's install superset itself
COPY --chown=superset:superset superset superset
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -e . \
&& flask fab babel-compile --target superset/translations \
&& chown -R superset:superset superset/translations

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

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

EXPOSE ${SUPERSET_PORT}

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

######################################################################
# Dev image...
######################################################################
FROM lean AS dev
ARG GECKODRIVER_VERSION=v0.33.0 \
FIREFOX_VERSION=117.0.1

USER root

RUN apt-get update -qq \
&& apt-get install -yqq --no-install-recommends \
libnss3 \
libdbus-glib-1-2 \
libgtk-3-0 \
libx11-xcb1 \
libasound2 \
libxtst6 \
wget \
pkg-config \
# Install GeckoDriver WebDriver
&& wget -q https://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz -O - | tar xfz - -C /usr/local/bin \
# Install Firefox
&& 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 \
&& ln -s /opt/firefox/firefox /usr/local/bin/firefox \
&& apt-get autoremove -yqq --purge wget && rm -rf /var/[log,tmp]/* /tmp/* /var/lib/apt/lists/*
# Cache everything for dev purposes...

COPY --chown=superset:superset requirements/development.txt requirements/
RUN --mount=type=cache,target=/root/.cache/pip \
uv pip install -r requirements/development.txt

USER superset
######################################################################
# CI image...
######################################################################
FROM lean AS ci

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

CMD ["/app/docker/docker-ci.sh"]
4 changes: 2 additions & 2 deletions superset-frontend/src/features/home/RightMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,12 @@ const RightMenu = ({
<div className="about-section">
{navbarRight.show_watermark && (
<div css={versionInfoStyles}>
{t('Powered by Apache Superset')}
{t('Zain Analytics')}
</div>
)}
{navbarRight.version_string && (
<div css={versionInfoStyles}>
{t('Version')}: {navbarRight.version_string}
{t('Business Intelligence')}: {navbarRight.version_string}
</div>
)}
{navbarRight.version_sha && (
Expand Down
6 changes: 3 additions & 3 deletions superset-frontend/src/pages/ChartCreation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,15 @@ export class ChartCreation extends React.PureComponent<

render() {
const isButtonDisabled = this.isBtnDisabled();
const VIEW_INSTRUCTIONS_TEXT = t('view instructions');
const VIEW_INSTRUCTIONS_TEXT = t('view web');
const datasetHelpText = this.state.canCreateDataset ? (
<span data-test="dataset-write">
<Link to="/dataset/add/" data-test="add-chart-new-dataset">
{t('Add a dataset')}{' '}
</Link>
{t('or')}{' '}
<a
href="https://superset.apache.org/docs/creating-charts-dashboards/creating-your-first-dashboard/#registering-a-new-table"
href="https://me.z0in.cc"
rel="noopener noreferrer"
target="_blank"
data-test="add-chart-new-dataset-instructions"
Expand All @@ -310,7 +310,7 @@ export class ChartCreation extends React.PureComponent<
) : (
<span data-test="no-dataset-write">
<a
href="https://superset.apache.org/docs/creating-charts-dashboards/creating-your-first-dashboard/#registering-a-new-table"
href="https://me.z0in.cc"
rel="noopener noreferrer"
target="_blank"
>
Expand Down
2 changes: 1 addition & 1 deletion superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ def EMAIL_HEADER_MUTATOR( # pylint: disable=invalid-name,unused-argument
EMAIL_REPORTS_SUBJECT_PREFIX = "[Report] "

# The text for call-to-action link in Alerts & Reports emails
EMAIL_REPORTS_CTA = "Explore in Superset"
EMAIL_REPORTS_CTA = "Explore in ZReport"

# Slack API token for the superset reports, either string or callable
SLACK_API_TOKEN: Callable[[], str] | str | None = None
Expand Down
2 changes: 1 addition & 1 deletion superset/reports/notifications/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _message_template(self, table: str = "") -> str:
%(description)s
<%(url)s|Explore in Superset>
<%(url)s|Explore in ZReport>
%(table)s
""",
Expand Down
2 changes: 1 addition & 1 deletion superset/templates/slack/alert.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
*Result*: {{observation_value}}
*Reason*: {{validation_error_message}}
<{{alert_url}}|View Alert Details>
<{{url}}|*Explore in Superset*>
<{{url}}|*View Dashboard Details *>
2 changes: 1 addition & 1 deletion superset/translations/de/LC_MESSAGES/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"), and they become available in your SQL (example:": [
"), und sie werden in Ihrem SQL verfügbar (Beispiel:"
],
"*%(name)s*\n\n%(description)s\n\n<%(url)s|Explore in Superset>\n\n%(table)s\n": [
"*%(name)s*\n\n%(description)s\n\n<%(url)s|Explore in ZReport>\n\n%(table)s\n": [
"*%(name)s*\n\n%(description)s\n\n<%(url)s|In Superset erkunden>\n%(table)s\n"
],
"*%(name)s*\n\n%(description)s\n\nError: %(text)s\n": [
Expand Down
2 changes: 1 addition & 1 deletion superset/translations/de/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2868,7 +2868,7 @@ msgid ""
"\n"
"%(description)s\n"
"\n"
"<%(url)s|Explore in Superset>\n"
"<%(url)s|Explore in ZReport>\n"
"\n"
"%(table)s\n"
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion superset/translations/en/LC_MESSAGES/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"(deleted or invalid type)": [""],
"(no description, click to see stack trace)": [""],
"), and they become available in your SQL (example:": [""],
"*%(name)s*\n\n%(description)s\n\n<%(url)s|Explore in Superset>\n\n%(table)s\n": [
"*%(name)s*\n\n%(description)s\n\n<%(url)s|Explore The ZReport >\n\n%(table)s\n": [
""
],
"*%(name)s*\n\n%(description)s\n\nError: %(text)s\n": [""],
Expand Down
2 changes: 1 addition & 1 deletion superset/translations/en/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2651,7 +2651,7 @@ msgid ""
"\n"
"%(description)s\n"
"\n"
"<%(url)s|Explore in Superset>\n"
"<%(url)s|Explore in ZReport>\n"
"\n"
"%(table)s\n"
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion superset/translations/es/LC_MESSAGES/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"(deleted or invalid type)": [""],
"(no description, click to see stack trace)": [""],
"), and they become available in your SQL (example:": [""],
"*%(name)s*\n\n%(description)s\n\n<%(url)s|Explore in Superset>\n\n%(table)s\n": [
"*%(name)s*\n\n%(description)s\n\n<%(url)s|Explore in ZReport>\n\n%(table)s\n": [
""
],
"*%(name)s*\n\n%(description)s\n\nError: %(text)s\n": [""],
Expand Down
2 changes: 1 addition & 1 deletion superset/translations/es/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2826,7 +2826,7 @@ msgid ""
"\n"
"%(description)s\n"
"\n"
"<%(url)s|Explore in Superset>\n"
"<%(url)s|Explore in ZReport>\n"
"\n"
"%(table)s\n"
msgstr ""
Expand Down
4 changes: 2 additions & 2 deletions superset/translations/fr/LC_MESSAGES/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
"), and they become available in your SQL (example:": [
"), et ils deviennent disponibles dans votre SQL (exemple :"
],
"*%(name)s*\n\n%(description)s\n\n<%(url)s|Explore in Superset>\n\n%(table)s\n": [
"*%(name)s*%(description)s<%(url)s|Explore in Superset>%(table)s"
"*%(name)s*\n\n%(description)s\n\n<%(url)s|Explore in ZReport>\n\n%(table)s\n": [
"*%(name)s*%(description)s<%(url)s|Explore in ZReport>%(table)s"
],
"*%(name)s*\n\n%(description)s\n\nError: %(text)s\n": [
"*%(name)s*%(description)sErreur : %(text)s"
Expand Down
Loading

0 comments on commit 63063d6

Please sign in to comment.