Skip to content

Local development Docker improvements #15943

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

Merged
merged 1 commit into from
Oct 19, 2021
Merged

Local development Docker improvements #15943

merged 1 commit into from
Oct 19, 2021

Conversation

hiddewie
Copy link
Contributor

@hiddewie hiddewie commented Oct 18, 2021

When building the local development Docker image, a huge context is sent to the Docker daemon. Even worse, the whole image is usually rebuilt instead of Docker layer caching reusing the previous builds of the same image.

Example output

~/C/G/symfony-docs (request-locales|✔) $ docker build . -t symfony-docs
Sending build context to Docker daemon  164.4MB
Step 1/8 : FROM  python:2-stretch as builder
2-stretch: Pulling from library/python
7568c21980bd: Pull complete
4a9f2207c812: Pull complete
6fe350d2b140: Pull complete
d95a2fdc8b3d: Pull complete

# ...

The problem is 2 things

  • a locally built _build directory is sent with the Docker context
  • The .git directory is sent with the Docker context
    Both are not needed in the build process.

This has been fixed with a .dockerignore file, see the documentation here: https://docs.docker.com/engine/reference/builder/#dockerignore-file

New output:

~/C/G/symfony-docs (docker-performance|✔) $ docker build . -t symfony-docs
Sending build context to Docker daemon  12.88MB
Step 1/9 : FROM python:2-alpine as builder
2-alpine: Pulling from library/python
aad63a933944: Already exists
259d822268fb: Already exists

# ...

Next, the much smaller alpine variants of the base images can be used, which is smaller to download. The Python 2 and Nginx base image both have an alpine variant.

@carsonbot carsonbot added this to the 5.4 milestone Oct 18, 2021
@hiddewie hiddewie changed the base branch from 5.4 to 4.4 October 18, 2021 20:10
@javiereguiluz javiereguiluz modified the milestones: 5.4, 4.4 Oct 19, 2021
@javiereguiluz
Copy link
Member

Thanks Hidde!

Please note that we're going to change the doc building completely soon (and move from Python to a PHP-based solution). But, let's improve this meanwhile.

@javiereguiluz javiereguiluz merged commit da8f6f5 into symfony:4.4 Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants