Skip to content

Commit 4a81e08

Browse files
committed
docker: static musl build
1 parent 9e3000c commit 4a81e08

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ Thumbs.db
163163

164164
# Logs
165165
*.log
166+
167+
# Docker
168+
.docker/
169+
*.tar.gz
166170
Makefile
167171
test
168172
test.dSYM/

Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM alpine:3.23
2+
3+
# Install build dependencies
4+
RUN apk add --no-cache \
5+
gcc \
6+
musl-dev \
7+
make \
8+
autoconf \
9+
file
10+
11+
# Set working directory
12+
WORKDIR /build
13+
14+
# Copy source files
15+
COPY termcap.c termcap.h tparam.c version.c ./
16+
COPY configure configure.in Makefile.in ./
17+
COPY mkinstalldirs install-sh ./
18+
19+
# Run configure
20+
RUN ./configure
21+
22+
# Build static library with C23 support
23+
RUN make CFLAGS="-std=gnu23 -static -O2" libtermcap.a
24+
25+
# Create output directory
26+
RUN mkdir -p /output && cp libtermcap.a /output/
27+
28+
# Verify that libtermcap.a is a static library and contains no dynamic dependencies
29+
RUN file /output/libtermcap.a
30+
RUN nm -a /usr/local/lib/libtermcap.a | grep " U " && echo "ERROR: Found undefined symbols!" && exit 1 || echo "✓ No undefined symbols found"
31+
32+
# Final stage - minimal image with just the static library
33+
FROM alpine:3.23
34+
RUN mkdir -p /usr/local/lib
35+
COPY --from=0 /build/libtermcap.a /usr/local/lib/
36+
COPY --from=0 /build/termcap.h /usr/local/include/
37+
38+
# Verify the library was built
39+
RUN ls -lh /usr/local/lib/libtermcap.a
40+
41+
WORKDIR /workspace

0 commit comments

Comments
 (0)