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

optimize Dockerfile #409

Merged
merged 1 commit into from Dec 11, 2020
Merged

optimize Dockerfile #409

merged 1 commit into from Dec 11, 2020

Conversation

brownchow
Copy link
Contributor

@brownchow brownchow commented Dec 3, 2020

Hi all:

I modified the Dockerfile a bit to make it more consistent

  1. as the docker documentation says: If the WORKDIR doesn’t exist, it will be created, so there is no need to use RUN mkdir /app

  2. apk update is useless since we have already added --no-cache in apk add --no-cache gcc build-base linux-headers , if keep apk update it just make image size bigger, to prove this, I do it on a alpine container

just run apk add --no-cache gcc build-base linux-headers

/ # apk add --no-cache gcc build-base linux-headers
fetch http://mirrors.tools.huawei.com/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://mirrors.tools.huawei.com/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
OK: 269 MiB in 82 packages
/ # ls -al /var/cache/apk/
total 12
drwxr-xr-x    2 root     root          4096 Oct 21 09:23 .
drwxr-xr-x    1 root     root          4096 Dec  3 02:13 ..

run apk update && apk add --no-cache gcc build-base linux-headers

/ # apk update && apk add --no-cache gcc build-base linux-headers
fetch http://mirrors.tools.huawei.com/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://mirrors.tools.huawei.com/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
v3.12.0-429-gb9df8c9616 [http://mirrors.tools.huawei.com/alpine/v3.12/main]
v3.12.0-430-gc0f4e9959c [http://mirrors.tools.huawei.com/alpine/v3.12/community]
OK: 12744 distinct packages available
fetch http://mirrors.tools.huawei.com/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://mirrors.tools.huawei.com/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
OK: 269 MiB in 82 packages
/ # ls -al /var/cache/apk/
total 1752
drwxr-xr-x    1 root     root          4096 Dec  3 02:15 .
drwxr-xr-x    1 root     root          4096 Dec  3 02:13 ..
-rw-r--r--    1 root     root       1145321 Dec  3 02:15 APKINDEX.18b70b67.tar.gz
-rw-r--r--    1 root     root        634615 Dec  3 02:15 APKINDEX.99eadc54.tar.gz

it produce index files , we don't need this in our image

and we can save 2MB disk sapce

docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
owncast/owncast     v0.2                c7e1b722a174        42 minutes ago      973MB
owncast/owncast     v0.1                e917e7dae6b9        About an hour ago   975MB
  1. we can Minimize the number of layers by merge some command with &&

  2. to test it works or not, I packed a config.json into image, docker build -t owncast/owncast:v0.2 .
    and then run docker container run --rm -p 8082:8080 -p 1937:1935 -v d:\\config.yaml:/config.yaml owncast/owncast:v0.2
    the output it produces is

time="2020-12-03T02:36:02Z" level=info msg="Owncast v0.0.0-localdev (unknown)"
time="2020-12-03T02:36:03Z" level=info msg="Web server is listening on port 8080, RTMP is accepting inbound streams on port 1935."
time="2020-12-03T02:36:03Z" level=info msg="The web admin interface is available at /admin."

and go to http://localhost:8082/ , it works!

@brownchow brownchow changed the title optimize Dockefile optimize Dockerfile Dec 3, 2020
@gabek
Copy link
Member

gabek commented Dec 3, 2020

Lots of good finds, very awesome. Thank you!

So confusingly we have two Dockerfiles, and we probably shouldn't. The one you are looking at is just a simple one that admittedly is probably not used much, hence the issues you see that nobody has noticed.

However, we have another Dockerfile that we use for making the release image that goes up to Dockerhub. And there I think it's probably better configured, but still doesn't get looked at much.
https://github.com/owncast/owncast/blob/master/build/release/Dockerfile-build#L25

So that being said, I'm all for fixing up that root Dockerfile with your changes and at some point in the future consolidating the two using your updates.

I added @geekgonecrazy and @muesli to see if they have any feedback, as they spend more time with Docker than I.

Copy link
Contributor

@geekgonecrazy geekgonecrazy left a comment

Choose a reason for hiding this comment

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

To me these changes all look good. This same level of detail looking at main image used for build might also be good

@gabek gabek merged commit 570f529 into owncast:master Dec 11, 2020
gabek pushed a commit that referenced this pull request Apr 26, 2022
Bumps [antd](https://github.com/ant-design/ant-design) from 4.18.1 to 4.18.2.
- [Release notes](https://github.com/ant-design/ant-design/releases)
- [Changelog](https://github.com/ant-design/ant-design/blob/master/CHANGELOG.en-US.md)
- [Commits](ant-design/ant-design@4.18.1...4.18.2)

---
updated-dependencies:
- dependency-name: antd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants