forked from fantom-lang/fantom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerfile
72 lines (56 loc) · 2.45 KB
/
dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# USAGE
# docker build -t fantom .
#
# The following build args are accepted, with documentation:
# - JDK_VERSION: The version of the JDK to use. Defaults to 17.
# - SWT_DL_URL: The URL to download the SWT jar from. Defaults to 4.27. Be sure that this is compatible with your JDK version.
# - REL_VERSION: The version name of Fantom to use to bootstrap. Defaults to fantom-1.0.77.
# - REL_TAG: The tag of Fantom to use to bootstrap. Be sure that matches REL_VERSION. Defaults to v1.0.77.
# ================================
# Bootstrap image
# ================================
# This image builds the local Fantom installation using the Fantom Bootstrap process.
#
# It mirrors the Bootstrap.fan script, but does not use it (since we want to use the
# local fantom, not one pulled via git).
ARG JDK_VERSION=17
FROM eclipse-temurin:$JDK_VERSION as bootstrap
ARG SWT_DL_URL=https://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops4/R-4.27-202303020300/swt-4.27-gtk-linux-x86_64.zip&mirror_id=1
# These define the `rel` Fantom version.
ARG REL_VERSION=fantom-1.0.80
ARG REL_TAG=v1.0.80
WORKDIR /work
RUN set -e; \
FAN_BIN_URL="https://github.com/fantom-lang/fantom/releases/download/$REL_TAG/$REL_VERSION.zip" \
# Install curl
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get -q update && apt-get -q install -y curl unzip && rm -rf /var/lib/apt/lists/* \
# Download Fantom
&& curl -fsSL "$FAN_BIN_URL" -o fantom.zip \
&& unzip fantom.zip -d fantom \
&& mv fantom/$REL_VERSION rel \
&& chmod +x rel/bin/* \
&& rm -rf fantom && rm -f fantom.zip \
# Download linux-x86_64 SWT
&& curl -fsSL "$SWT_DL_URL" -o swt.zip \
&& unzip swt.zip -d swt \
&& mv swt/swt.jar ./ \
&& rm -rf swt && rm -f swt.zip
COPY . ./fan/
RUN <<EOF
echo "\n\njdkHome=${JAVA_HOME}/\ndevHome=/work/fan/\n" >> rel/etc/build/config.props
echo "\n\njdkHome=${JAVA_HOME}/" >> fan/etc/build/config.props
rel/bin/fan fan/src/buildall.fan superclean
rel/bin/fan fan/src/buildboot.fan compile
fan/bin/fan fan/src/buildpods.fan compile
EOF
# The /work/fan directory now contains a compiled version of the local Fantom
# ================================
# Run image
# ================================
# This simply copies the new Fantom into a fresh container and sets up the path.
FROM eclipse-temurin:$JDK_VERSION as run
COPY --from=bootstrap /work/fan/ /opt/fan/
ENV PATH $PATH:/opt/fan/bin
# Return Fantom's version
CMD ["fan","-version"]