Skip to content

Commit

Permalink
fix(docker): optimize docker build by better utilizing build cache (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianliebscher authored Apr 13, 2023
1 parent 04bd528 commit 536b1c4
Showing 1 changed file with 32 additions and 36 deletions.
68 changes: 32 additions & 36 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,52 +58,48 @@ ENV LANG=C.UTF-8 \
SUPERSET_PORT=8088

RUN mkdir -p ${PYTHONPATH} \
&& useradd --user-group -d ${SUPERSET_HOME} -m --no-log-init --shell /bin/bash superset \
&& apt-get update -y \
&& apt-get install -y --no-install-recommends \
build-essential \
curl \
default-libmysqlclient-dev \
libsasl2-dev \
libsasl2-modules-gssapi-mit \
libpq-dev \
libecpg-dev \
&& rm -rf /var/lib/apt/lists/*

COPY ./requirements/*.txt /app/requirements/
COPY setup.py MANIFEST.in README.md /app/
&& useradd --user-group -d ${SUPERSET_HOME} -m --no-log-init --shell /bin/bash superset \
&& apt-get update -y \
&& apt-get install -y --no-install-recommends \
build-essential \
curl \
default-libmysqlclient-dev \
libsasl2-dev \
libsasl2-modules-gssapi-mit \
libpq-dev \
libecpg-dev \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY --chown=superset:superset ./requirements/*.txt requirements/
COPY --chown=superset:superset setup.py MANIFEST.in README.md ./

# setup.py uses the version information in package.json
COPY superset-frontend/package.json /app/superset-frontend/
COPY --chown=superset:superset superset-frontend/package.json superset-frontend/

RUN cd /app \
&& mkdir -p superset/static \
RUN mkdir -p superset/static \
&& touch superset/static/version_info.json \
&& pip install --no-cache -r requirements/local.txt
&& pip install --no-cache-dir -r requirements/local.txt

COPY --from=superset-node /app/superset/static/assets /app/superset/static/assets
COPY --chown=superset:superset --from=superset-node /app/superset/static/assets superset/static/assets

## 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 . \
&& flask fab babel-compile --target superset/translations
COPY --chown=superset:superset superset superset
RUN chown -R superset:superset ./* \
&& pip install --no-cache-dir -e . \
&& flask fab babel-compile --target superset/translations

COPY ./docker/run-server.sh /usr/bin/

RUN chmod a+x /usr/bin/run-server.sh

WORKDIR /app

USER superset

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

EXPOSE ${SUPERSET_PORT}

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

######################################################################
# Dev image...
Expand All @@ -118,13 +114,13 @@ USER root

RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
libnss3 \
libdbus-glib-1-2 \
libgtk-3-0 \
libx11-xcb1 \
libasound2 \
libxtst6 \
wget
libnss3 \
libdbus-glib-1-2 \
libgtk-3-0 \
libx11-xcb1 \
libasound2 \
libxtst6 \
wget

# Install GeckoDriver WebDriver
RUN wget https://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz -O /tmp/geckodriver.tar.gz && \
Expand Down

0 comments on commit 536b1c4

Please sign in to comment.