Skip to content
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

Refactor Dockerfile to reduce the amount of layers #701

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AchimGrolimund
Copy link

@AchimGrolimund AchimGrolimund commented Apr 28, 2024

PR Description

Reduce the layers in the Docker image by 8 Layers. This also reduces the size of the Docker image

Which issue(s) this PR fixes

Notes to the Reviewer

PR Checklist

  • CHANGELOG.md updated
  • Documentation added
  • Tests updated
  • Config converters updated

@rfratto rfratto added the backport-to-agent PR should be backported to the agent repo. label May 3, 2024
Copy link

@henworth henworth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopeful this change can get looked at, just started testing migrating my agents to alloy and CI flagged the amount of wasted space in the image build.

Comment on lines -54 to 63
RUN groupadd --gid $UID $USERNAME
RUN useradd -m -u $UID -g $UID $USERNAME
RUN chown -R $USERNAME:$USERNAME /etc/alloy
RUN chown -R $USERNAME:$USERNAME /bin/alloy
RUN groupadd --gid $UID $USERNAME \
&& useradd -m -u $UID -g $UID $USERNAME \
&& chown -R $USERNAME:$USERNAME /etc/alloy \
&& chown -R $USERNAME:$USERNAME /bin/alloy \

&& mkdir -p /var/lib/alloy/data \
&& chown -R $USERNAME:$USERNAME /var/lib/alloy \
&& chmod -R 770 /var/lib/alloy

RUN mkdir -p /var/lib/alloy/data
RUN chown -R $USERNAME:$USERNAME /var/lib/alloy
RUN chmod -R 770 /var/lib/alloy

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove the line break and indent 2 more spaces, looks a bit cleaner IMO.

Suggested change
RUN groupadd --gid $UID $USERNAME
RUN useradd -m -u $UID -g $UID $USERNAME
RUN chown -R $USERNAME:$USERNAME /etc/alloy
RUN chown -R $USERNAME:$USERNAME /bin/alloy
RUN groupadd --gid $UID $USERNAME \
&& useradd -m -u $UID -g $UID $USERNAME \
&& chown -R $USERNAME:$USERNAME /etc/alloy \
&& chown -R $USERNAME:$USERNAME /bin/alloy \
&& mkdir -p /var/lib/alloy/data \
&& chown -R $USERNAME:$USERNAME /var/lib/alloy \
&& chmod -R 770 /var/lib/alloy
RUN mkdir -p /var/lib/alloy/data
RUN chown -R $USERNAME:$USERNAME /var/lib/alloy
RUN chmod -R 770 /var/lib/alloy
RUN groupadd --gid $UID $USERNAME \
&& useradd -m -u $UID -g $UID $USERNAME \
&& chown -R $USERNAME:$USERNAME /etc/alloy \
&& chown -R $USERNAME:$USERNAME /bin/alloy \
&& mkdir -p /var/lib/alloy/data \
&& chown -R $USERNAME:$USERNAME /var/lib/alloy \
&& chmod -R 770 /var/lib/alloy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-to-agent PR should be backported to the agent repo.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants