-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dockerfile optimized #275
Dockerfile optimized #275
Conversation
Signed-off-by: Lou Marvin Caraig <[email protected]>
Signed-off-by: Lou Marvin Caraig <[email protected]>
Signed-off-by: Lou Marvin Caraig <[email protected]>
Signed-off-by: Lou Marvin Caraig <[email protected]>
&& pip install -r requirements.txt -r requirements-dev.txt -r requirements-extra.txt \ | ||
&& rm -rf /root/.cache/pip | ||
&& pip install --no-index --find-links=/wheels \ | ||
-r requirements.txt -r requirements-dev.txt -r requirements-extra.txt \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requirements-dev
are needed only for dev :)
(except db drivers which we should move to another file)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, this doesn't address #272. The reason is that as you said we should also reorg requirements files such as whether to store our requirements in a requirements-build.txt
or whatever where we store db drivers and pyHive. I wanted to separate this PR which is more general.
superset/contrib/docker/Dockerfile
Outdated
|
||
COPY superset/assets superset/assets | ||
|
||
RUN cd superset/assets \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also improves the usage of docker caching for this step that is really heavy.
if you want to improve it further you can do:
# install deps and cache them
COPY superset/assets/package*.json superset/assets
RUN npm ci
# build
COPY superset/assets superset/assets
RUN npm run build
It will use docker cache instead of downloading and installing dependencies most of the time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Done here.
superset/contrib/docker/Dockerfile
Outdated
@@ -14,7 +14,34 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
# | |||
FROM python:3.6-jessie | |||
FROM node:12 AS static |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node version in build stage and in the final image aren't the same. Most probably it's not important but anyway better make them match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Fixed here.
Signed-off-by: Lou Marvin Caraig <[email protected]>
Signed-off-by: Lou Marvin Caraig <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome
Closes #273.
This doesn't address #272.
The
Dockerfile
has been modified in order to reduce the final image size. This is achieved by using multi-stage build. There are two builders:The first builder compiles the static files and permits the final image to avoid installing nodejs for the production version. This also improves the usage of docker caching for this step that is really heavy.
The second builder builds the python wheels to be used in the final image. This permits to use the slim image version.
The final image depends on the build arg
DEV_BUILD
: ifDEV_BUILD
istrue
, then also os dev dependencies are installed, otherwise, they're not. The Makefile provides thebuild-dev
target.The production image size has decreased from
1.76GB
to945MB
(decrease>800MB
, -46%).The development image size has decreased from
1.76GB
to1.1GB
(decrease>650MB
, -37.5%).