Skip to content

Commit ef263fe

Browse files
committed
Enhancements for building/image size
* Updated to use ponyc master since cross compiling changes have been merged. * Updated to add a "runtime" dockerfile that is smaller than full compile docker image. * Makefile/dockerfile changes to support both debug and release builds. * build.sh/ponyc changes to support running in "runtime" container and to support debug/release builds. Only tested on Ubuntu linux via vagrant but should work elsewhere also.
1 parent c6c0838 commit ef263fe

File tree

6 files changed

+69
-20
lines changed

6 files changed

+69
-20
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build
2+

Dockerfile

+30-15
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ RUN dpkg --add-architecture armhf && \
2525
llvm-3.6 \
2626
llvm \
2727
zlib1g-dev \
28+
curl \
2829
software-properties-common \
2930
libicu-dev:armhf \
3031
libncurses5-dev:armhf \
@@ -36,33 +37,47 @@ RUN dpkg --add-architecture armhf && \
3637
gcc-arm-linux-gnueabihf \
3738
g++-arm-linux-gnueabihf && \
3839
rm -rf /var/lib/apt/lists/* && \
39-
apt-get clean
40+
apt-get -y autoremove --purge && \
41+
apt-get -y clean
42+
43+
RUN mkdir -p /tmp/pcre-src && \
44+
curl -SL -o /tmp/pcre-src/repo.tbz2 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.20.tar.bz2 && \
45+
tar xf /tmp/pcre-src/repo.tbz2 -C /tmp/pcre-src && \
46+
ln -s /tmp/pcre-src/*pcre* /tmp/pcre-src/pcre && \
47+
cd /tmp/pcre-src/pcre && \
48+
./configure --prefix=/usr && \
49+
make && \
50+
make install && \
51+
rm -r /tmp/pcre-src/*pcre*
52+
53+
ARG PONYC_CONFIG=debug
54+
ENV PONYC_CONFIG ${PONYC_CONFIG}
4055

4156
RUN rm -rf /build/*
4257
RUN mkdir -p /build/pony
4358
RUN mkdir -p /build/arm
4459
WORKDIR /build/arm
45-
RUN git clone https://github.com/dipinhora/ponyc.git ponyc
60+
RUN git clone https://github.com/ponylang/ponyc.git ponyc
4661

4762
WORKDIR /build/arm/ponyc
48-
RUN git checkout cross_compiling
4963

5064
RUN CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ \
51-
make arch=armv7-a bits=32 verbose=true libponyrt
65+
make arch=armv7-a bits=32 config=${PONYC_CONFIG} libponyrt
5266

5367
WORKDIR /build
54-
RUN git clone https://github.com/dipinhora/ponyc.git ponyc && \
68+
RUN git clone https://github.com/ponylang/ponyc.git ponyc && \
5569
cd /build/ponyc && \
56-
git checkout cross_compiling && \
57-
make verbose=true ponyc && \
58-
make install && \
59-
rm -rf /build/ponyc && rm -rf /build/pony
70+
make config=${PONYC_CONFIG} ponyc && \
71+
make config=${PONYC_CONFIG} test && \
72+
rm -f /build/ponyc/build/${PONYC_CONFIG}/libgtest.a && \
73+
rm -f /build/ponyc/build/${PONYC_CONFIG}/libponyc.tests && \
74+
rm -f /build/ponyc/build/${PONYC_CONFIG}/libponyrt-pic.a && \
75+
rm -rf /build/ponyc/build/${PONYC_CONFIG}/obj
6076

61-
RUN mkdir /data
62-
WORKDIR /data
63-
COPY runasuser.sh /root/
64-
COPY build.sh /build/
65-
RUN chmod ugo+x /build/*.sh
66-
ENTRYPOINT ["/root/runasuser.sh"]
77+
RUN mkdir bin && \
78+
cd bin && \
79+
ln -s /build/ponyc/build/${PONYC_CONFIG}/ponyc .
6780

81+
COPY runasuser.sh /root/
82+
ENTRYPOINT ["/root/runasuser.sh"]
6883

Dockerfile.runtime

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM ubuntu:vivid
2+
MAINTAINER Markus Fix <[email protected]>
3+
4+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
5+
software-properties-common && \
6+
add-apt-repository -y ppa:linaro-maintainers/toolchain && \
7+
# hack to make apt-get update not fail due to ppa not having proper Packages files
8+
(apt-get update || true) && DEBIAN_FRONTEND=noninteractive apt-get install -y \
9+
gcc-arm-linux-gnueabihf \
10+
gcc && \
11+
apt-get -y autoremove software-properties-common && \
12+
rm -rf /var/lib/apt/lists/* && \
13+
apt-get -y autoclean && \
14+
apt-get -y autoremove --purge && \
15+
apt-get -y clean
16+
17+
COPY build /build
18+
19+
RUN mkdir /data
20+
WORKDIR /data
21+
COPY runasuser.sh /root/
22+
COPY build.sh /build/
23+
RUN chmod ugo+x /build/*.sh
24+
ENTRYPOINT ["/root/runasuser.sh"]
25+

Makefile

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ DOCKER_IMAGE_VERSION=0.0.1
22
DOCKER_IMAGE_NAME=lispmeister/rpxp
33
DOCKER_IMAGE_TAGNAME=$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)
44

5+
current_dir = $(shell pwd)
6+
config ?= debug
7+
58
default: build
69

710
print-% : ; @echo $* = $($*)
811

912
build:
10-
docker build -t $(DOCKER_IMAGE_TAGNAME) .
13+
docker build --build-arg PONYC_CONFIG=$(config) -t $(DOCKER_IMAGE_TAGNAME) .
14+
docker run --rm -v $(current_dir):/build-export $(DOCKER_IMAGE_TAGNAME) -U `id -u -n` -u 1000 -G `id -g -n` -g 1000 cp -r /build $(pwd)/build-export
15+
docker build -t $(DOCKER_IMAGE_TAGNAME) --file=./Dockerfile.runtime .
16+
rm -rf build
1117
docker tag -f $(DOCKER_IMAGE_TAGNAME) $(DOCKER_IMAGE_NAME):latest
1218

1319
push:

build.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22

33
module_name=$(basename `pwd`)
44

5-
ponyc --triple arm-unknown-linux-gnueabihf -robj
5+
/build/bin/ponyc --triple arm-unknown-linux-gnueabihf -robj
66

7-
arm-linux-gnueabihf-gcc -v \
7+
arm-linux-gnueabihf-gcc \
88
-o ${module_name} \
99
-O3 -march=armv7-a -flto -fuse-linker-plugin \
1010
-fuse-ld=gold \
1111
${module_name}.o \
1212
-L"/usr/local/lib" \
1313
-L"/build/arm/ponyc/build/debug/" \
14-
-L"/build/arm/ponyc/build/debug/../../packages" \
14+
-L"/build/arm/ponyc/build/release/" \
15+
-L"/build/arm/ponyc/packages" \
1516
-Wl,--start-group \
1617
-l"rt" \
1718
-Wl,--end-group \

ponyc

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) lispmeister/rpxp \
66
-u 1000 \
77
-G `id -g -n` \
88
-g 1000 \
9-
ponyc "$@"
9+
/build/bin/ponyc "$@"

0 commit comments

Comments
 (0)