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

docker image size exploded with version 3.8.x #12582

Closed
khassel opened this issue May 16, 2024 · 0 comments · Fixed by #12593
Closed

docker image size exploded with version 3.8.x #12582

khassel opened this issue May 16, 2024 · 0 comments · Fixed by #12593
Assignees
Labels
Milestone

Comments

@khassel
Copy link

khassel commented May 16, 2024

NodeBB version

v3.8.1

NodeBB git hash

f491d43

NodeJS version

v20.13.1

Installed NodeBB plugins

only defaults

Database type

MongoDB

Database version

v7.0.9

Exact steps to cause this issue

The docker image size exploded from v3.7.x to v3.8.x

❯ docker images
REPOSITORY                      TAG        IMAGE ID       CREATED        SIZE
ghcr.io/nodebb/nodebb           3.8.1      791cf33c60df   24 hours ago   1.75GB
ghcr.io/nodebb/nodebb           3.7.5      5b1553eafba7   13 days ago    647MB

What you expected

Image size of v3.7.x similar to v3.8.x

What happened instead

see above

Anything else?

This is caused by the refactored Dockerfile.

COPY --from=build --chown=${USER}:${USER} /usr/src/app/ /usr/src/app/install/docker/setup.json /usr/src/app/
COPY --from=build --chown=${USER}:${USER} /usr/bin/tini /usr/src/app/install/docker/entrypoint.sh /usr/local/bin/

RUN corepack enable \
    && groupadd --gid ${GID} ${USER} \
    && useradd --uid ${UID} --gid ${GID} --home-dir /usr/src/app/ --shell /bin/bash ${USER} \
    && mkdir -p /usr/src/app/logs/ /opt/config/ \
    && chown -R ${USER}:${USER} /usr/src/app/ /opt/config/ \
    && chmod +x /usr/local/bin/entrypoint.sh \
    && chmod +x /usr/local/bin/tini

Most size increase is caused by chown -R ${USER}:${USER} /usr/src/app/ in above RUN section.

It is also bad style to do the above COPY statements with user/group id's which does not exist at that time, they are created later in the RUN statement (I was surprised that this is allowed by e.g. buildkit, kaniko throws an error).

@khassel khassel added the bug label May 16, 2024
oplik0 added a commit to oplik0/NodeBB that referenced this issue May 23, 2024
it really was just order of operations...
resolves NodeBB#12582
julianlam pushed a commit that referenced this issue May 23, 2024
it really was just order of operations...
resolves #12582
@barisusakli barisusakli added this to the 3.8.2 milestone May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants