Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions compiled_starters/zig/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ const std = @import("std");
pub fn build(b: *std.Build) void {
const exe = b.addExecutable(.{
.name = "main",
.root_source_file = b.path("src/main.zig"),
.target = b.standardTargetOptions(.{}),
.optimize = b.standardOptimizeOption(.{}),
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = b.standardTargetOptions(.{}),
.optimize = b.standardOptimizeOption(.{}),
}),
});

// This declares intent for the executable to be installed into the
Expand Down
2 changes: 1 addition & 1 deletion compiled_starters/zig/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// This field is optional.
// This is currently advisory only; Zig does not yet do anything
// with this value.
.minimum_zig_version = "0.14.0",
.minimum_zig_version = "0.15.1",

// This field is optional.
// Each dependency must either provide a `url` and `hash`, or a `path`.
Expand Down
2 changes: 1 addition & 1 deletion compiled_starters/zig/codecrafters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ debug: false
# on Codecrafters.
#
# Available versions: zig-0.14
buildpack: zig-0.14
buildpack: zig-0.15
27 changes: 27 additions & 0 deletions dockerfiles/zig-0.15.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# syntax=docker/dockerfile:1.7-labs
FROM alpine:3.20

RUN apk add --no-cache 'xz>=5.6' 'curl>=8.9'

# Download and install Zig
RUN curl -O https://ziglang.org/download/0.15.1/zig-linux-x86_64-0.15.1.tar.xz \
&& tar -xf zig-linux-x86_64-0.15.1.tar.xz \
&& mv zig-linux-x86_64-0.15.1 /usr/local/zig \
&& rm zig-linux-x86_64-0.15.1.tar.xz

# Add Zig to PATH
ENV PATH="/usr/local/zig:${PATH}"

ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="build.zig,build.zig.zon"

WORKDIR /app

# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
COPY --exclude=.git --exclude=README.md . /app

# This runs zig build
RUN .codecrafters/compile.sh

# Cache build directory
RUN mkdir -p /app-cached
RUN mv /app/.zig-cache /app-cached/.zig-cache || true