From 47d391b478e1cbb8e5c185747e3aae5dacba7db5 Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Tue, 25 Jun 2024 19:00:58 +1000 Subject: [PATCH] feat: add ftl-in-a-box Docker image (#1869) --- .github/workflows/release.yml | 29 +++++++++++++++++++++ Dockerfile.box | 49 +++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 Dockerfile.box diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1e14bb0e90..e6a0d95c63 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,6 +43,25 @@ jobs: name: docker-controller-artifact path: artifacts/ftl-controller retention-days: 1 + build-box: + name: Build FTL-in-a-box Docker Image + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Init Hermit + uses: cashapp/activate-hermit@v1 + - name: Build + run: | + docker build -t ftl0/ftl-box:"$GITHUB_SHA" -t ftl0/ftl-box:latest -f Dockerfile.box . + mkdir -p artifacts/ftl-box + docker save -o artifacts/ftl-box/ftl-box.tar ftl0/ftl-box:latest + - name: Temporarily save Docker image + uses: actions/upload-artifact@v4 + with: + name: docker-box-artifact + path: artifacts/ftl-box + retention-days: 1 release-docker: name: Release Assets runs-on: ubuntu-latest @@ -67,10 +86,17 @@ jobs: with: name: docker-controller-artifact path: artifacts/ftl-controller + - name: Retrieve FTL-in-a-box Docker image + uses: actions/download-artifact@v4 + with: + name: docker-box-artifact + path: artifacts/ftl-box - name: Load Runner Docker image run: docker load -i artifacts/ftl-runner/ftl-runner.tar - name: Load Controller Docker image run: docker load -i artifacts/ftl-controller/ftl-controller.tar + - name: Load FTL-in-a-box Docker image + run: docker load -i artifacts/ftl-box/ftl-box.tar - name: Log in to the Container registry uses: docker/login-action@v3 with: @@ -85,6 +111,9 @@ jobs: docker tag ftl0/ftl-controller:latest ftl0/ftl-controller:"$GITHUB_SHA" docker tag ftl0/ftl-controller:latest ftl0/ftl-controller:"$version" docker push -a ftl0/ftl-controller + docker tag ftl0/ftl-box:latest ftl0/ftl-box:"$GITHUB_SHA" + docker tag ftl0/ftl-box:latest ftl0/ftl-box:"$version" + docker push -a ftl0/ftl-box create-release: name: Release Go Binaries runs-on: ubuntu-latest diff --git a/Dockerfile.box b/Dockerfile.box new file mode 100644 index 0000000000..b6a1af72b8 --- /dev/null +++ b/Dockerfile.box @@ -0,0 +1,49 @@ +FROM ubuntu:24.04 AS builder +RUN apt-get update +RUN apt-get install -y curl git zip + +# Seed some of the most common tools - this will be cached +COPY ./bin /src/bin +ENV PATH="/src/bin:$PATH" +ENV HERMIT_STATE_DIR=/hermit +RUN hermit uninstall jbr +RUN hermit install openjre-18.0.2.1_1 +# openjre and jbr conflict, but we want the JRE in the cache +RUN hermit uninstall openjre +RUN hermit install jbr +RUN go version +RUN mvn -f kotlin-runtime/ftl-runtime -B --version + +WORKDIR /src + +# Download Go dependencies separately so Docker will cache them +COPY go.mod go.sum /src/ +RUN go mod download -x + +COPY . /src/ + +# Build runner template +RUN just build-kt-runtime + +# Build runner +RUN just errtrace +# Reset timestamps so that the build state is reset +RUN git ls-files -z | xargs -0 touch -r go.mod +RUN just build ftl + +# Finally create the runtime image. +FROM ubuntu:24.04 + +WORKDIR /root/ + +ENV PATH="/root/jre/bin:$PATH" +COPY --from=builder /hermit/pkg/openjre-18.0.2.1_1/ ./jre/ +COPY --from=builder /src/build/template template +COPY --from=builder /src/build/release/ftl-runner . +COPY --from=builder /src/build/release/ftl . +RUN mkdir deployments + +EXPOSE 8891 +EXPOSE 8892 + +CMD ["/root/ftl", "dev"]