- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 92
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
Add Dockerfile #104
Add Dockerfile #104
Conversation
@@ -0,0 +1,19 @@ | |||
FROM rust:1.69-bullseye as rust-build-stage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason not to use latest
here, so we don't have to bump the version in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair question. Using :latest
is seen as an anti-pattern for a few reasons. Here are some of them:
- You're dependent on the build process of the base image distributor keeping that latest tag up to date. You don't really know what version you're getting now or later, or even that it's the latest version actually.
- Your builds aren't deterministic. The image you build might be different from what I get when I build the next day.
- If the docker build starts to fail, but you didn't change your Dockerfile, it's hard to troubleshoot that. How do you find out what the base image version was previously, when the build worked? What is it now, when it's failing?
- You aren't in control of what you ship to your users. You blindly ship whatever updates happened up stream, whether you need them or not, whether they make sense for you or not.
I definitely sympathize with resistance to adding manual toil updating versions. In my experience, that can be addressed with dependency management (like dependabot, or Renovatebot) in conjunction with build tests in CI/CD. If you are anxious about those ongoing maintenance costs, I could possibly help put together a quick-and-dirty docker build workflow in GitHub Actions for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that definitely makes sense. I was just thinking that maybe, those Rust images are relatively well maintained and in principle, updates to the Rust version shouldn't break backwards compatibility, i.e. vivid
should continue building. But I'm okay with leaving the hardcoded version in. Having a CI check that the image still builds would be great. I don't think there is a need for an automated update mechanism at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a basic docker build workflow here: 4d1cfb7
For security reasons, github won't run it here until you merge it. But you can see it running on my fork: https://github.com/rpdelaney/vivid/actions
USER 1001:1001 | ||
|
||
WORKDIR /app | ||
COPY --from=rust-build-stage --chown=1001:1001 /build/target/release/vivid . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So... I think this will always use the builtin/embedded filetypes database and themes. So there is no way for the user to customize this using ~/.config/vivid/filetypes.yml
or /usr/share/vivid/filetypes.yml
, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal would be for the vivid
process to have access to these files at runtime, I think. That is, we wouldn't want to have the user rebuild the container locally every time they update their local configuration, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. So, the user would have to --mount
their host ~/.config/vivid folder (and others)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For context, my use case is that I co-maintain LS_COLORS
. The vast number of extensions we support is getting unwieldy, so I'm interested in migrating our build to leverage vivid
. Having vivid in docker would help a lot since that obviates managing a hermetic rust build process inside GHA. For a use case like that, I think it's perfectly fine to leave configuration and filesystem access to the user. Anybody who is used to working with docker is already used to dealing with that, and frankly, I for one prefer it that way.
Using docker to run applications on a consumer desktop system is not something I generally recommend, since the daemon runs as the root user and therefore it is unsafe in multi-user environments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For context, my use case is that I co-maintain
LS_COLORS
.
Oh, cool! That project was a huge inspiration for vivid
. Glad to see that it is still actively maintained.
The vast number of extensions we support is getting unwieldy, so I'm interested in migrating our build to leverage vivid.
That would be fantastic. We would certainly see some synergy effects in both projects.
Having vivid in docker would help a lot since that obviates managing a hermetic rust build process inside GHA. For a use case like that, I think it's perfectly fine to leave configuration and filesystem access to the user.
I understand.
Using docker to run applications on a consumer desktop system is not something I generally recommend, since the daemon runs as the root user and therefore it is unsafe in multi-user environments.
Ok, then let's leave the setup minimal and add the Dockerfile just for purposes like yours.
Thank you. I have a few minor questions. |
Since this is a multi-stage build, we don't need to bother with this.
This will test whether the docker image builds successfully.
Works great, thank you: https://github.com/sharkdp/vivid/actions/runs/5271134914 |
This gives me an image about 18Mb.