Skip to content

Commit 217a306

Browse files
committed
Add Dockerfile for portable builds and deployments
* Add a `Dockerfile` for building the Ion Fusion SDK and CLI, across a variety of base environments, with multi-stage image builds to support in-development vs runtime container deployment contexts. * Add a new GitHub Actions workflow for building the container images across all base environments and build targets, and pushing them to the GitHub Container Registry. * Update onboarding documentation in the README to leverage the accessibility of now having Fusion container images. * Rewrite most of `howto_build.md` documentation to provide a guide to building Fusion via the Dockerfile, in various contexts.
1 parent 734aaaa commit 217a306

File tree

6 files changed

+387
-23
lines changed

6 files changed

+387
-23
lines changed

.dockerignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/Dockerfile
2+
3+
/.editorconfig
4+
/.git
5+
/.github
6+
7+
# Via .gitignore:
8+
9+
/build
10+
/compiled
11+
/demo/compiled
12+
/eclipse-bin
13+
/jdiff-baseline
14+
cobertura.ser
15+
junit*.properties
16+
tmp*
17+
FusionJava.iml
18+
19+
# Ignore Gradle project-specific cache directory
20+
.gradle
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: push-container-images
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
jobs:
13+
14+
# Build job for the Ion Fusion SDK images:
15+
build-sdk:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
strategy:
21+
matrix:
22+
include:
23+
- base: corretto-8
24+
tag: sdk
25+
- base: temurin-8
26+
tag: sdk-temurin-8
27+
- base: zulu-8
28+
tag: sdk-zulu-8
29+
- base: alpine-openjdk-8
30+
tag: sdk-alpine-openjdk-8
31+
- base: ubuntu-openjdk-8
32+
tag: sdk-ubuntu-openjdk-8
33+
- base: rhel-openjdk-8
34+
tag: sdk-rhel-openjdk-8
35+
steps:
36+
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
39+
40+
- name: Set up Docker
41+
uses: docker/setup-buildx-action@v3
42+
43+
- name: Log in to Container Registry
44+
uses: docker/login-action@v3
45+
with:
46+
registry: ${{ env.REGISTRY }}
47+
username: ${{ github.actor }}
48+
password: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Extract metadata
51+
id: meta
52+
uses: docker/metadata-action@v5
53+
with:
54+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
55+
tags: |
56+
type=raw,value=${{ matrix.tag }}
57+
labels: |
58+
org.opencontainers.image.title=Ion Fusion SDK (${{ matrix.tag }})
59+
org.opencontainers.image.description=Ion Fusion SDK container image (${{ matrix.tag }}) built on ${{ matrix.base }}
60+
61+
- name: Build and push SDK image
62+
uses: docker/build-push-action@v6
63+
with:
64+
context: .
65+
platforms: linux/amd64,linux/arm64
66+
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
67+
target: sdk
68+
build-args: |
69+
BASE=${{ matrix.base }}
70+
tags: ${{ steps.meta.outputs.tags }}
71+
labels: ${{ steps.meta.outputs.labels }}
72+
cache-from: type=gha
73+
cache-to: type=gha,mode=max
74+
75+
# Build job for the Ion Fusion runtime images:
76+
build-runtime:
77+
runs-on: ubuntu-latest
78+
# to rely on layer caching:
79+
needs: build-sdk
80+
permissions:
81+
contents: read
82+
packages: write
83+
strategy:
84+
matrix:
85+
include:
86+
- base: corretto-8
87+
tag: runtime
88+
- base: temurin-8
89+
tag: runtime-temurin-8
90+
- base: zulu-8
91+
tag: runtime-zulu-8
92+
- base: alpine-openjdk-8
93+
tag: runtime-alpine-openjdk-8
94+
- base: ubuntu-openjdk-8
95+
tag: runtime-ubuntu-openjdk-8
96+
- base: rhel-openjdk-8
97+
tag: runtime-rhel-openjdk-8
98+
steps:
99+
100+
- name: Checkout repository
101+
uses: actions/checkout@v4
102+
103+
- name: Set up Docker Buildx
104+
uses: docker/setup-buildx-action@v3
105+
106+
- name: Log in to Container Registry
107+
uses: docker/login-action@v3
108+
with:
109+
registry: ${{ env.REGISTRY }}
110+
username: ${{ github.actor }}
111+
password: ${{ secrets.GITHUB_TOKEN }}
112+
113+
- name: Extract metadata
114+
id: meta
115+
uses: docker/metadata-action@v5
116+
with:
117+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
118+
tags: |
119+
type=raw,value=${{ matrix.tag }}
120+
labels: |
121+
org.opencontainers.image.title=Ion Fusion Runtime (${{ matrix.tag }})
122+
org.opencontainers.image.description=Ion Fusion runtime container image (${{ matrix.tag }}) built on ${{ matrix.base }}
123+
124+
- name: Build and push runtime image
125+
uses: docker/build-push-action@v6
126+
with:
127+
context: .
128+
platforms: linux/amd64,linux/arm64
129+
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
130+
build-args: |
131+
BASE=${{ matrix.base }}
132+
tags: ${{ steps.meta.outputs.tags }}
133+
labels: ${{ steps.meta.outputs.labels }}
134+
cache-from: type=gha
135+
cache-to: type=gha,mode=max
136+

Dockerfile

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# syntax=docker/dockerfile:1.16-labs
2+
3+
# This is the official Ion Fusion container file (aka Dockerfile).
4+
#
5+
# You can build an Ion Fusion runtime image with:
6+
#
7+
# docker build -t fusion .
8+
#
9+
# Then you can run that with:
10+
#
11+
# docker run --rm -it fusion repl
12+
#
13+
# You can also build an Ion Fusion SDK image with:
14+
#
15+
# docker build -t fusion-sdk --target sdk .
16+
#
17+
# For more details, see: ./fusion/src/howto_build.md
18+
19+
# Available bases:
20+
# corretto-8 temurin-8 zulu-8 alpine-openjdk-8 ubuntu-openjdk-8 rhel-openjdk-8
21+
ARG BASE="corretto-8"
22+
23+
ARG BASE_JDK="base-jdk-${BASE}"
24+
ARG BASE_JRE="base-jre-${BASE}"
25+
26+
# Base images
27+
# -----------
28+
29+
# Amazon Corretto OpenJDK: https://hub.docker.com/_/amazoncorretto
30+
FROM amazoncorretto:8-al2-native-jdk@sha256:f18bef23fd4113fce0e2570516bf80fa38cc083935385995d8e67df15c6de958 AS base-jdk-corretto-8
31+
32+
FROM amazoncorretto:8-al2-native-jre@sha256:ed068bc774f2fdbacf40327072c3a80b76475d16b36d9c9c4b9baaaa2ca744b1 AS base-jre-corretto-8
33+
34+
# Eclipse Temurin OpenJDK: https://hub.docker.com/_/eclipse-temurin
35+
FROM eclipse-temurin:8-jdk@sha256:26eef5df6131e5da7d556f1bd62fa118571ff00c0eac6d76ae30f5c7e7ce8b49 AS base-jdk-temurin-8
36+
37+
FROM eclipse-temurin:8-jre@sha256:eb4cc550df86a3534356839ca37c5894e8dae83b29f84d7ca0684898d4057b2d AS base-jre-temurin-8
38+
39+
# Azul Zulu OpenJDK: https://hub.docker.com/r/azul/zulu-openjdk
40+
FROM azul/zulu-openjdk:8@sha256:bd2bd5ce9f81297d25755cf5083264d9253bc137bbe3e8e2176446456ad56b06 AS base-jdk-zulu-8
41+
42+
FROM azul/zulu-openjdk:8-jre@sha256:a498c63c3ecfe1f4cf642bb79aeda4c710271fbc9439a9d835db8192fe7eeb23 AS base-jre-zulu-8
43+
44+
# Alpine Linux: https://hub.docker.com/_/alpine
45+
FROM alpine:latest@sha256:8a1f59ffb675680d47db6337b49d22281a139e9d709335b492be023728e11715 AS base-jdk-alpine-openjdk-8
46+
RUN apk add --no-cache openjdk8-jdk
47+
48+
FROM alpine:latest@sha256:8a1f59ffb675680d47db6337b49d22281a139e9d709335b492be023728e11715 AS base-jre-alpine-openjdk-8
49+
RUN apk add --no-cache openjdk8-jre
50+
51+
# Ubuntu Linux: https://hub.docker.com/_/ubuntu
52+
FROM ubuntu:latest@sha256:b59d21599a2b151e23eea5f6602f4af4d7d31c4e236d22bf0b62b86d2e386b8f AS base-jdk-ubuntu-openjdk-8
53+
RUN apt-get update && \
54+
apt-get --assume-yes --no-install-recommends install openjdk-8-jdk-headless
55+
56+
FROM ubuntu:latest@sha256:b59d21599a2b151e23eea5f6602f4af4d7d31c4e236d22bf0b62b86d2e386b8f AS base-jre-ubuntu-openjdk-8
57+
RUN apt-get update && \
58+
apt-get --assume-yes --no-install-recommends install openjdk-8-jre-headless
59+
60+
# Red Hat Enterprise Linux 8: https://hub.docker.com/r/redhat/ubi8
61+
FROM redhat/ubi8:latest@sha256:0c1757c4526cfd7fdfedc54fadf4940e7f453201de65c0fefd454f3dde117273 AS base-jdk-rhel-openjdk-8
62+
RUN dnf --assumeyes install java-1.8.0-openjdk-devel
63+
64+
FROM redhat/ubi8:latest@sha256:0c1757c4526cfd7fdfedc54fadf4940e7f453201de65c0fefd454f3dde117273 AS base-jre-rhel-openjdk-8
65+
RUN dnf --assumeyes install java-1.8.0-openjdk-headless
66+
67+
68+
# Ion Fusion SDK image
69+
# --------------------
70+
71+
FROM ${BASE_JDK} AS sdk
72+
WORKDIR /opt/fusion
73+
ENV LC_ALL="C.UTF-8" LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8"
74+
# install gradle via the wrapper:
75+
COPY --parents ./*gradle* .
76+
RUN ./gradlew --version
77+
# run the gradle build:
78+
COPY . .
79+
RUN ./gradlew --no-daemon release && \
80+
cp -r build/install/fusion/* /usr/local/ && \
81+
./gradlew --no-daemon clean
82+
ENTRYPOINT ["fusion"]
83+
84+
# Ion Fusion runtime image
85+
# ------------------------
86+
87+
FROM ${BASE_JRE}
88+
COPY --from=sdk \
89+
/usr/local/bin \
90+
/usr/local/lib \
91+
/usr/local/
92+
ENTRYPOINT ["fusion"]
93+

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,21 @@ It is now an independent Apache-licensed project led by current and former Amazo
3535

3636
# Getting Started
3737

38-
To learn more about this project, browse our documentation at <https://docs.ion-fusion.dev>.
38+
To learn more about Ion Fusion, see the website: <https://ion-fusion.dev/>
3939

40-
To try out the Fusion CLI, you'll need to build from source (sorry!).
41-
See [Building Ion Fusion](https://docs.ion-fusion.dev/howto_build.html) for instructions and
42-
some introductory tutorials.
40+
With a container CLI installed (such as [docker][], [podman][], [nerdctl][], [finch][] or
41+
[container][]), you can quickly try Ion Fusion with:
42+
43+
docker run --rm -it ghcr.io/ion-fusion/fusion-java:sdk repl
44+
45+
For more details on building the Ion Fusion SDK, the `fusion` utility, and the Ion Fusion container
46+
images, see the documentation on [building Ion Fusion](fusion/src/howto_build.md).
47+
48+
[docker]: https://www.docker.com/products/cli/
49+
[podman]: https://podman.io/
50+
[nerdctl]: https://github.com/containerd/nerdctl
51+
[finch]: https://github.com/runfinch/finch
52+
[container]: https://github.com/apple/container
4353

4454

4555
# Support

0 commit comments

Comments
 (0)