Skip to content

Commit 400b6e6

Browse files
Build libgc in alpine image to enable MT builds (#63)
Co-authored-by: Caspian Baska <[email protected]>
1 parent 85028bd commit 400b6e6

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

docker/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ CRYSTAL_TARGZ ?= ## Which crystal.tar.gz file to install in docker images (a
1313
DOCKER_TAG ?= ## How to tag the docker image (examples: `0.27.2`, `nightly20190307`). `-build` will be appended for build images.
1414
DOCKER_REPOSITORY ?= ## Docker hub repository to commit image
1515

16+
GC_VERSION = v8.0.4
17+
LIBATOMIC_OPS_VERSION = v7.6.10
18+
1619
OUTPUT_DIR := build
1720
BUILD_CONTEXT := $(CURDIR)/build-context
1821
BUILD_ARGS_UBUNTU64 := --build-arg crystal_deb=crystal.deb $(BUILD_CONTEXT)/ubuntu64 --build-arg base_docker_image=ubuntu:focal
1922
BUILD_ARGS_UBUNTU32 := --build-arg crystal_deb=crystal.deb $(BUILD_CONTEXT)/ubuntu32 --build-arg base_docker_image=i386/ubuntu:bionic
20-
BUILD_ARGS_ALPINE := --build-arg crystal_targz=crystal.tar.gz $(BUILD_CONTEXT)/alpine
23+
BUILD_ARGS_ALPINE := --build-arg crystal_targz=crystal.tar.gz $(BUILD_CONTEXT)/alpine --build-arg gc_version=$(GC_VERSION) --build-arg libatomic_ops_version=$(LIBATOMIC_OPS_VERSION)
2124
DOCKER_TAG_UBUNTU := $(DOCKER_REPOSITORY):$(DOCKER_TAG)
2225
DOCKER_TAG_ALPINE := $(DOCKER_REPOSITORY):$(DOCKER_TAG)-alpine
2326

@@ -53,6 +56,8 @@ $(BUILD_CONTEXT)/ubuntu64: ubuntu.Dockerfile $(BUILD_CONTEXT)/ubuntu64/crystal.d
5356

5457
$(BUILD_CONTEXT)/alpine: alpine.Dockerfile $(BUILD_CONTEXT)/alpine/crystal.tar.gz
5558
cp alpine.Dockerfile $@/Dockerfile
59+
mkdir $@/files/
60+
cp ../linux/files/feature-thread-stackbottom-upstream.patch $@/files/feature-thread-stackbottom-upstream.patch
5661

5762
%/crystal.deb:
5863
mkdir -p $(shell dirname $@)

docker/alpine.Dockerfile

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,33 @@ FROM alpine:3.13 as runtime
33
RUN \
44
apk add --update --no-cache --force-overwrite \
55
# core dependencies
6-
gc-dev gcc gmp-dev libatomic_ops libevent-static musl-dev pcre-dev \
6+
gcc gmp-dev libevent-static musl-dev pcre-dev \
77
# stdlib dependencies
88
libxml2-dev openssl-dev openssl-libs-static tzdata yaml-static zlib-static \
99
# dev tools
10-
make git
10+
make git \
11+
# build libgc dependencies
12+
autoconf automake libtool patch
13+
14+
# Build libgc
15+
ARG gc_version
16+
ARG libatomic_ops_version
17+
COPY files/feature-thread-stackbottom-upstream.patch /tmp/
18+
RUN git clone https://github.com/ivmai/bdwgc \
19+
&& cd bdwgc \
20+
&& git checkout ${gc_version} \
21+
&& git clone https://github.com/ivmai/libatomic_ops \
22+
&& (cd libatomic_ops && git checkout ${libatomic_ops_version}) \
23+
\
24+
&& patch -p1 < /tmp/feature-thread-stackbottom-upstream.patch \
25+
\
26+
&& ./autogen.sh \
27+
&& ./configure --disable-debug --disable-shared --enable-large-config \
28+
&& make -j$(nproc) CFLAGS=-DNO_GETCONTEXT \
29+
&& make install
30+
31+
# Remove build tools from image now that libgc is built
32+
RUN apk del -r --purge autoconf automake libtool patch
1133

1234
ARG crystal_targz
1335
COPY ${crystal_targz} /tmp/crystal.tar.gz

0 commit comments

Comments
 (0)