-
Notifications
You must be signed in to change notification settings - Fork 14
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
Optimize Dockerfile to reduce image size #136
Conversation
Dockerfile
Outdated
@@ -1,26 +1,24 @@ | |||
# Copyright (c) 2021 LG Electronics Inc. | |||
# SPDX-License-Identifier: Apache-2.0 | |||
FROM ubuntu:20.04 | |||
FROM --platform=linux/amd64 python:3.8-slim-buster |
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.
To provide for multiple platforms instead of just one, the setting must be excluded from the FROM
statement. For more information, see https://docs.docker.com/build/building/multi-platform/
FROM --platform=linux/amd64 python:3.8-slim-buster | |
FROM python:3.8-slim-buster |
Dockerfile
Outdated
RUN apt-get clean | ||
RUN apt-get update && apt-get install sudo -y | ||
RUN ln -sf /bin/bash /bin/sh | ||
ENV DEBIAN_FRONTEND=noninteractive |
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.
noninteractive
mode is useful when we need zero interaction while installing or upgrading the system via apt. However, setting this environment variable to noninteractive has an adverse effect. Because it is inherited by all images and containers built from the image, effectively changing their behavior.
ENV DEBIAN_FRONTEND=noninteractive |
Let's look for an alternative.
Dockerfile
Outdated
apt-get update && \ | ||
apt-get install -y sudo build-essential \ |
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.
apt-get update && \ | |
apt-get install -y sudo build-essential \ | |
apt-get update && \ | |
apt-get install --no-install-recommends -y \ | |
build-essential \ |
Consider changing the pull request title and commit message to |
Signed-off-by: jaehee329 <[email protected]>
@jongwooo I have a question about using multi-stage build now.
|
Description
ref #135
Changed docker base image from
ubuntu:20.04
topython:3.8-slim-buster
Reduced the number of layers
Reduced 0.31GB of the image size
build time also decreased from 5.5 min to 2 min in my environment (Win10, i5-10400F, 16GB RAM)
Type of change