Skip to content

Instantly share code, notes, and snippets.

@resolritter
Last active June 17, 2023 05:56
Show Gist options
  • Select an option

  • Save resolritter/fd8aa2920699b87894e35c450b10fbd7 to your computer and use it in GitHub Desktop.

Select an option

Save resolritter/fd8aa2920699b87894e35c450b10fbd7 to your computer and use it in GitHub Desktop.
Build zigup on Docker

Since the Zigup binary is statically-linked, you'll be able to copy it to your machine afterwards.

# Build for the default target (x86_64-linux)
docker build -t zigup .
# Or specify a custom target through ZIGUP_TARGET
# docker build -t zigup --build-arg ZIGUP_TARGET=macos-x86_64 .

# Copy zigup from the Docker image to your host
container="$(docker container create zigup)"
docker container cp "$container":/zigup/zig-out/bin/zigup .
docker container rm "$container"

# Use zigup  
./zigup --help
FROM docker.io/library/alpine:latest
# Update the system
RUN apk update && apk upgrade
# Initialize build tools directory
RUN mkdir -p /tools
WORKDIR /tools
# Install Zig
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"
# Build zigup
RUN apk add --no-cache git
ARG ZIGUP_TARGET=x86_64-linux
ARG ZIGUP_BUILD_FLAGS=-Drelease-safe
COPY . /zigup
WORKDIR /zigup
RUN zig build -Dfetch -Dtarget="$ZIGUP_TARGET" $ZIGUP_BUILD_FLAGS
ENV PATH="/zigup/zig-out/bin:$PATH"
ENTRYPOINT ["/zigup/zig-out/bin/zigup"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment