1+ # ================================
2+ # Bootstrap image
3+ # ================================
4+ # This image builds the local Fantom installation using the Fantom Bootstrap process.
5+ #
6+ # It mirrors the Bootstrap.fan script, but does not use it (since we want to use the
7+ # local fantom, not one pulled via git).
8+
9+ FROM openjdk:8-jdk as bootstrap
10+
11+ ARG FAN_DL_URL=https://github.com/fantom-lang/fantom/releases/download
12+ # SWT 4.16 was the last one with JDK 8 support
13+ ARG SWT_DL_URL=https://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops4/R-4.16-202006040540/swt-4.16-gtk-linux-x86_64.zip
14+
15+ # These define the `rel` Fantom version.
16+ ARG REL_VERSION=fantom-1.0.77
17+ ARG REL_TAG=v1.0.77
18+
19+ WORKDIR /work
20+
21+ RUN set -e; \
22+ FAN_BIN_URL="$FAN_DL_URL/$REL_TAG/$REL_VERSION.zip" \
23+ # Install curl
24+ && export DEBIAN_FRONTEND=noninteractive \
25+ && apt-get -q update && apt-get -q install -y curl && rm -rf /var/lib/apt/lists/* \
26+ # Download Fantom
27+ && curl -fsSL "$FAN_BIN_URL" -o fantom.zip \
28+ && unzip fantom.zip -d fantom \
29+ && mv fantom/$REL_VERSION rel \
30+ && chmod +x rel/bin/* \
31+ && rm -rf fantom && rm -f fantom.zip \
32+ # Download linux-x86_64 SWT
33+ && curl -fsSL "$SWT_DL_URL" -o swt.zip \
34+ && unzip swt.zip -d swt \
35+ && mv swt/swt.jar ./ \
36+ && rm -rf swt && rm -f swt.zip
37+
38+ COPY . ./fan/
39+
40+ # Copy SWT into installations
41+ RUN mkdir rel/lib/java/ext/linux-x86_64 \
42+ && cp swt.jar rel/lib/java/ext/linux-x86_64/ \
43+ && mkdir fan/lib/java/ext/linux-x86_64 \
44+ && cp swt.jar fan/lib/java/ext/linux-x86_64/ \
45+ && rm swt.jar
46+
47+ # Populate config.props with jdkHome (to use jdk, not jre) and devHome
48+ RUN echo -e "\n\njdkHome=/usr/local/openjdk-8/\ndevHome=/work/fan/\n" >> rel/etc/build/config.props \
49+ && echo -e "\n\njdkHome=/usr/local/openjdk-8/" >> fan/etc/build/config.props
50+
51+ RUN rel/bin/fan fan/src/buildall.fan superclean \
52+ && rel/bin/fan fan/src/buildboot.fan compile \
53+ && fan/bin/fan fan/src/buildpods.fan compile
54+
55+ # The /work/fan directory now contains a compiled version of the local Fantom
56+
57+ # ================================
58+ # Run image
59+ # ================================
60+ # This simply copies the new Fantom into a fresh container and sets up the path.
61+
62+ FROM openjdk:8-jdk
63+
64+ COPY --from=bootstrap /work/fan/ /opt/fan/
65+
66+ ENV PATH $PATH:/opt/fan/bin
67+
68+ # Return Fantom's version
69+ CMD ["fan","-version"]
0 commit comments