fix(docker): optimize docker build by better utilizing build cache (#23624)

This commit is contained in:
Sebastian Liebscher 2023-04-13 18:31:36 +02:00 committed by GitHub
parent 04bd528bed
commit 536b1c4816
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 40 additions and 44 deletions

View File

@ -70,40 +70,36 @@ RUN mkdir -p ${PYTHONPATH} \
libecpg-dev \
&& rm -rf /var/lib/apt/lists/*
COPY ./requirements/*.txt /app/requirements/
COPY setup.py MANIFEST.in README.md /app/
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 . \
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...