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

Inhouse docker image builds #323

Merged
merged 5 commits into from
Jan 13, 2022
Merged

Inhouse docker image builds #323

merged 5 commits into from
Jan 13, 2022

Conversation

jinnatar
Copy link
Contributor

@jinnatar jinnatar commented Jan 9, 2022

This hugely builds on the work by @ajacobson (https://github.com/ajacobson/chiadog-docker) and no disrespect is intended.

Proposing merge to main instead of dev since this does not in any way modify how Chiadog works and will then enable images to be built for any and all branches regardless of when dev is merged to main.

Major benefits of inhousing:

  • Can easily build any state of the repo regardless of branch or
    mid-development into a functional image without mucking about with an
    external repo. Doing other chiadog development made me frustrated enough to also fix this. :-)
  • Faster builds when the source code is already present without an extra clone
  • Automated Docker image builds into the free GitHub image repository. Official images triggered by official tags & releases, but also dev images any any other branch provide repeatable and traceable pinning of images.

Minor fixes added as well:

  • entrypoint.sh was missing a shebang
  • Simplified entrypoint running now that the script has a proper shebang
  • Simplified logic by switching WORKDIR earlier
  • Add a .dockerignore file to prune dirty state and useless weight from
    the container.

Does not include:

  • Any documentation. Docker is an advanced option in any case but this
    should be added as a followup.

@jinnatar
Copy link
Contributor Author

jinnatar commented Jan 9, 2022

Oops, let me rebase this from dev -> main.

This way it doesn't matter how configs are named.
This brings over only only drop dead simple bits that really should live
with the tool itself.

Major benefits:
- Can easily build any state of the repo regardless of branch or
  mid-development into a functional image without mucking about with an
  external repo.
- Faster builds when the source code is already present without an extra
  clone

Minor fixes added as well:
- entrypoint.sh was missing a shebang
- Simplified entrypoint running now that the script has a proper
  shabang
- Simplified logic by switching WORKDIR earlier
- Add a .dockerignore file to prune dirty state and useless weight from
  the container.

Does not include:
- Any documentation. Docker is an advanced option in any case but this
  should be added as a followup.
- Automated Docker builds. Those come in the next commit.
- Images based on the `main` branch will update the `latest` tag.
- Other branches will be tagged with the branch name and first 6 chars
  of commit hash.
- Any git tags will tag images as-is, say `v0.7.0` would become: `ghcr.io/martomi/chiadog:v0.7.0`
@jinnatar
Copy link
Contributor Author

jinnatar commented Jan 9, 2022

Example image has been automatically built in my fork: https://github.com/Artanicus/chiadog/pkgs/container/chiadog .. this shows the logic for non-special branches with the image name becoming:
ghcr.io/artanicus/chiadog:inhouse_docker-26c7b8

Copy link
Owner

@martomi martomi left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @Artanicus !

I agree with the benefits you listed and particularly like the automated build workflow 👍

Please check some feedback I have below.

.gitignore Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
Dockerfile Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
.github/workflows/publish-image.yml Show resolved Hide resolved
- Breaking change for anyone coming from ajacobson/chiadog-docker: The
  config dir env variable is now called CHIADOG_CONFIG_DIR
- Switch base image to python:3.10-slim, reduced image size
  significantly
- Dropped manual TZ handling at the container system level, just setting
  env TZ is enough
- Dropped manual PyNaCL install, requirements pull in the binary wheel
  just fine
- Simplify entrypoint and use sh for security.
@jinnatar
Copy link
Contributor Author

@martomi PTAL, all feedback incorporated and everything simplified quite a bit.

@jinnatar jinnatar requested a review from martomi January 13, 2022 19:12
Copy link
Owner

@martomi martomi left a comment

Choose a reason for hiding this comment

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

Looks great now, thanks!

@martomi martomi merged commit 99cf0bb into martomi:main Jan 13, 2022
guydavis added a commit to guydavis/chiadog that referenced this pull request Jan 20, 2022
Automated docker image builds (martomi#323)
jinnatar added a commit to jinnatar/chiadog that referenced this pull request Feb 5, 2023
* Inhouse Dockerfile and entrypoint from ajacobson/chiadog-docker

This brings over only only drop dead simple bits that really should live
with the tool itself.

Major benefits:
- Can easily build any state of the repo regardless of branch or
  mid-development into a functional image without mucking about with an
  external repo.
- Faster builds when the source code is already present without an extra
  clone

Minor fixes added as well:
- entrypoint.sh was missing a shebang
- Simplified entrypoint running now that the script has a proper
  shabang
- Simplified logic by switching WORKDIR earlier
- Add a .dockerignore file to prune dirty state and useless weight from
  the container.

Does not include:
- Any documentation. Docker is an advanced option in any case but this
  should be added as a followup.
- Automated Docker builds. Those come in the next commit.

* Automate building of Docker images.

- Images based on the `main` branch will update the `latest` tag.
- Other branches will be tagged with the branch name and first 6 chars
  of commit hash.
- Any git tags will tag images as-is, say `v0.7.0` would become: `ghcr.io/martomi/chiadog:v0.7.0`

* Simplify & improve Docker image, change config env to CHIADOG_CONFIG_DIR

- Breaking change for anyone coming from ajacobson/chiadog-docker: The
  config dir env variable is now called CHIADOG_CONFIG_DIR
- Switch base image to python:3.10-slim, reduced image size
  significantly
- Dropped manual TZ handling at the container system level, just setting
  env TZ is enough
- Dropped manual PyNaCL install, requirements pull in the binary wheel
  just fine
- Simplify entrypoint and use sh for security.
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.

2 participants