Skip to content

Commit

Permalink
feat: add ftl-in-a-box Docker image (#1869)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas authored Jun 25, 2024
1 parent 38de28c commit 47d391b
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down
49 changes: 49 additions & 0 deletions Dockerfile.box
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 47d391b

Please sign in to comment.