Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

feat: reduce image size by 100MB using multi-stage dockerbuild, introduce using a user #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jlongman
Copy link

@jlongman jlongman commented Oct 24, 2021

Introduce a multi-stage build - reduces size from ~160MB by ~100MB down to 60MB.

  • use the --user installation which puts the installation into $HOME/.local.
  • change the entrypoint to reference as so

Use a user in the final container - best practices, security.

  • move from /root/.local to /home/appuser/.local

note, I've only tested docker run --rm -it -ePYHQ_USER -ePYHQ_PASSWORD from the cli as I don't have a mqtt setup atm.

@jlongman jlongman changed the title feat: multi-stage dockerbuild, use a user feat: reduce image size by 100MB using multi-stage dockerbuild, introduce using a user Oct 24, 2021
@@ -41,9 +41,9 @@ then
export CONFIG="/etc/pyhydroquebec/pyhydroquebec.yaml"
fi

if [ "$PYHQ_OUTPUT" == "MQTT" ]

Choose a reason for hiding this comment

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

Why remove an = in the condition?

Copy link
Author

@jlongman jlongman Oct 28, 2021

Choose a reason for hiding this comment

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

definitely didn't know this previously but for the bourne shell, sh:

== operator is not supported in POSIX sh

https://github.com/koalaman/shellcheck/wiki/SC2039#testing-equality

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants