Skip to content

musl compability + alpine dockerfile #1115

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

Merged
merged 3 commits into from
May 22, 2025
Merged
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
21 changes: 21 additions & 0 deletions packaging/alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM 84codes/crystal:latest-alpine AS builder
RUN apk add lz4-dev
WORKDIR /tmp
COPY shard.yml shard.lock .
RUN shards install --production
COPY ./static ./static
COPY ./views ./views
COPY ./src ./src
COPY Makefile .
ARG MAKEFLAGS=-j2
RUN make all

FROM alpine:latest
RUN apk add openssl lz4-libs pcre2 libgcc
COPY --from=builder /tmp/bin/* /usr/bin/
EXPOSE 5672 15672
VOLUME /var/lib/lavinmq
WORKDIR /var/lib/lavinmq
ENV GC_UNMAP_THRESHOLD=1
HEALTHCHECK CMD ["/usr/bin/lavinmqctl", "status"]
ENTRYPOINT ["/usr/bin/lavinmq", "-b", "0.0.0.0", "--guest-only-loopback=false"]
10 changes: 7 additions & 3 deletions src/stdlib/filesystem.cr
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ lib LibC
spare : StaticArray(Long, 4)
end

fun statfs64(file : Char*, buf : Statfs*) : Int
{% if flag?(:musl) %}
fun statfs(file : Char*, buf : Statfs*) : Int
{% else %}
fun statfs64(file : Char*, buf : Statfs*) : Int
{% end %}
{% elsif flag?(:darwin) %}
struct Statfs
bsize : UInt32
Expand Down Expand Up @@ -85,7 +89,7 @@ struct FilesystemInfo
getter total : UInt64
end

{% if flag?(:linux) || flag?(:darwin) %}
{% if (flag?(:linux) && !flag?(:musl)) || flag?(:darwin) %}
module Filesystem
def self.info(path)
statfs = uninitialized LibC::Statfs
Expand All @@ -95,7 +99,7 @@ end
FilesystemInfo.new(statfs)
end
end
{% elsif flag?(:freebsd) %}
{% elsif flag?(:freebsd) || flag?(:musl) %}
module Filesystem
def self.info(path)
statfs = uninitialized LibC::Statfs
Expand Down
Loading