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

Provide way of building zigup through Docker #88

Closed
wants to merge 2 commits into from

Conversation

resolritter
Copy link

@resolritter resolritter commented Apr 30, 2023

I suppose that this might be sufficient for closing #87

See https://github.com/resolritter/zigup/actions/runs/4841936672/jobs/8628552320 for a demo

@resolritter resolritter changed the title Provide way of building zigup on Docker Provide way of building zigup through Docker Apr 30, 2023
@marler8997
Copy link
Owner

This looks well written and I appreciate the effort, but, I'm not sure supporting docker as a bootstrap method adds enough value for me to maintain it going forward right now.

One thought I do have is if we we're to use a docker image, I think it could be cool/interesting to base it off a docker image that only contains the zig toolchain? Such an image would be interesting paired with another one of my projects: https://github.com/bettertools/zigenesis

@resolritter
Copy link
Author

One thought I do have is if we we're to use a docker image, I think it could be cool/interesting to base it off a docker image that only contains the zig toolchain?

By using an image which already contains the right Zig version required by this project (i.e. the version would no longer be configurable through --build-arg ZIG_VERSION=foo), we'd be able to skip the steps for downloading and installing the toolchain, thus curl + tar + xz (which tar internally uses) would not be necessary. However, git would still be necessary for fetching the dependencies, so it would have to be included in said image or we'd have to create our own image.

Something to consider is complexity. The Zig install procedure is just 7 LOC, so I wonder if it's worthwhile to pull another image just for that. This PR uses docker.io/library/alpine:latest which is an actively-maintained official Docker image, leveraged by hundreds of other open-source projects; we could use some third-party/zig image instead, but in my opinion the Zig install is not complicated enough to warrant something like that. For comparison's sake, the Rust image has to:

1 - Sets up the environment variables
2 - Downloads and runs rustup-init
3 - Sets up permissions for the toolchain's directories

Here we just have to download Zig and put it in $PATH.

Such an image would be interesting paired with another one of my projects: https://github.com/bettertools/zigenesi

I would advise you to just copy-and-paste this:

FROM docker.io/library/alpine:latest

RUN apk update && apk upgrade

RUN mkdir -p /tools
WORKDIR /tools

RUN apk add --no-cache curl tar xz
ARG ZIG_VERSION=0.11.0-dev.1507+6f13a725a
RUN curl -sSfL \
      https://ziglang.org/builds/zig-linux-x86_64-"$ZIG_VERSION".tar.xz \
      -o zig.tar.xz && \
    tar -xf zig.tar.xz && \
    mv zig-linux-x86_64-"$ZIG_VERSION" zig
ENV PATH="/tools/zig:$PATH"

And add what you want after that. Like I mentioned above, this looks simple enough for a toolchain setup step.

@resolritter
Copy link
Author

This looks well written and I appreciate the effort, but, I'm not sure supporting docker as a bootstrap method adds enough value for me to maintain it going forward right now.

Understandable, I'll close the PR then. Feel free to reopen if there's interest.

@resolritter resolritter closed this May 1, 2023
@marler8997
Copy link
Owner

However, git would still be necessary for fetching the dependencies, so it would have to be included in said image or we'd have to create our own image.

That's true right now, but, GitRepoStep.zig will be removed soon and replaced with zig's new build.zig.zon file which will allow the zig toolchain to automatically download dependencies. I would have moved to that already but there's some intermittent issues with build.zig.zon that need to be fixed first (see ziglang/zig#14573).

As far as using the alpine image for zigup, if we did support docker then this seems like a pretty good solution. I was more talking about using an image with just the Zig toolchain as an interesting way to verify/explore how minimal we could get dependencies for Zig projects in general.

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