From 47d9a3bb847c729baaed9fd3a81564e1c0851fe8 Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Thu, 28 Nov 2024 16:59:51 +1100 Subject: [PATCH] chore: simplify Dockerfiles --- .github/workflows/ci.yml | 90 +++++------ .github/workflows/release.yml | 199 +++++------------------- Dockerfile | 46 ++++++ Dockerfile.controller | 49 ------ Dockerfile.cron | 44 ------ Dockerfile.http-ingress | 44 ------ Dockerfile.initdb | 50 ------ Dockerfile.provisioner | 50 ------ Dockerfile.runner | 40 ----- Justfile | 80 +++++++++- backend/controller/controller.go | 4 +- backend/ingress/service.go | 2 +- backend/provisioner/service.go | 2 +- backend/runner/runner.go | 2 +- charts/ftl/values.yaml | 12 +- deployment/Dockerfile.controller.test | 18 --- deployment/Dockerfile.cron.test | 7 - deployment/Dockerfile.http-ingress.test | 8 - deployment/Dockerfile.provisioner.test | 13 -- deployment/Dockerfile.runner-jvm.test | 21 --- deployment/Dockerfile.runner.test | 15 -- deployment/Justfile | 118 +++++++------- lefthook.yml | 3 + 23 files changed, 276 insertions(+), 641 deletions(-) create mode 100644 Dockerfile delete mode 100644 Dockerfile.controller delete mode 100644 Dockerfile.cron delete mode 100644 Dockerfile.http-ingress delete mode 100644 Dockerfile.initdb delete mode 100644 Dockerfile.provisioner delete mode 100644 Dockerfile.runner delete mode 100644 deployment/Dockerfile.controller.test delete mode 100644 deployment/Dockerfile.cron.test delete mode 100644 deployment/Dockerfile.http-ingress.test delete mode 100644 deployment/Dockerfile.provisioner.test delete mode 100644 deployment/Dockerfile.runner-jvm.test delete mode 100644 deployment/Dockerfile.runner.test mode change 100755 => 100644 deployment/Justfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41d76f29f7..24a2896c2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -218,62 +218,30 @@ jobs: - uses: actions/checkout@v4 - uses: cashapp/activate-hermit@v1.1.3 - run: go-arch-lint check || true - docker-build-controller: - name: Build Controller Docker Image - # if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all') - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: cashapp/activate-hermit@v1.1.3 - - uses: ./.github/actions/build-cache - - run: just build-docker controller - docker-build-provisioner: - name: Build Provisioner Docker Image - # if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all') - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: cashapp/activate-hermit@v1.1.3 - - uses: ./.github/actions/build-cache - - run: just build-docker provisioner - docker-build-cron: - name: Build Cron Docker Image - # if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all') - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: cashapp/activate-hermit@v1.1.3 - - uses: ./.github/actions/build-cache - - run: just build-docker cron - docker-build-http-ingress: - name: Build HTTP Ingress Docker Image - # if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all') - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: cashapp/activate-hermit@v1.1.3 - - uses: ./.github/actions/build-cache - - run: just build-docker http-ingress - docker-build-runner: - name: Build Runner Docker Images - # if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all') + docker-shard: + name: Shard Docker Builds runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - uses: actions/checkout@v4 - uses: cashapp/activate-hermit@v1.1.3 - - uses: ./.github/actions/build-cache - - name: Build Runner Docker Image - run: just build-docker runner - docker-build-jvm-runners: - name: Build JVM Runner Docker Images - # if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all') + - id: set-matrix + run: echo "matrix=$(just list-docker-images | tr -d '\n' | jq -R -s -c 'split(" ")')" >> "$GITHUB_OUTPUT" + docker-build: + name: Build ${{ matrix.service }} Docker Image + needs: docker-shard runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + service: ${{ fromJson(needs.docker-shard.outputs.matrix) }} steps: - uses: actions/checkout@v4 - uses: cashapp/activate-hermit@v1.1.3 - uses: ./.github/actions/build-cache - - name: Build JVM Docker Imag - run: just build-docker runner-jvm + - name: Build Docker Image + run: just build-docker ${{ matrix.service }} console-e2e: name: Console e2e # if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all') @@ -422,3 +390,31 @@ jobs: else echo "Integration tests passed" fi + docker-success: + name: Docker Success + needs: [docker-build] + runs-on: ubuntu-latest + if: ${{ always() }} + steps: + - name: Check docker builds result + run: | + if [[ "${{ needs.docker-build.result }}" == "failure" ]]; then + echo "Docker builds failed" + exit 1 + else + echo "Docker builds passed" + fi + infrastructure-success: + name: Infrastructure Success + needs: [infrastructure-run] + runs-on: ubuntu-latest + if: ${{ always() }} + steps: + - name: Check infrastructure tests result + run: | + if [[ "${{ needs.infrastructure-run.result }}" == "failure" ]]; then + echo "Infrastructure tests failed" + exit 1 + else + echo "Infrastructure tests passed" + fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f97bd941b..9234d7c05f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,119 +4,46 @@ on: - "v[0-9]+.[0-9]+.[0-9]+" name: Automatically Build Release jobs: - build-runners: - name: Build Runner Docker Images + docker-shard: + name: Shard Docker Builds runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Init Hermit - uses: cashapp/activate-hermit@v1.1.3 - - name: Build Runner - run: | - just build-docker runner - mkdir -p artifacts/ftl-runner - docker save -o artifacts/ftl-runner/ftl-runner.tar ftl0/ftl-runner:latest - - name: Temporarily save Docker image - uses: actions/upload-artifact@v4 - with: - name: docker-runner-artifact - path: artifacts/ftl-runner/ftl-runner.tar - retention-days: 1 - - name: Build JVM Runner - run: | - just build-docker runner-jvm - mkdir -p artifacts/ftl-runner-jvm - docker save -o artifacts/ftl-runner-jvm/ftl-runner-jvm.tar ftl0/ftl-runner-jvm:latest - - name: Temporarily save JVM Docker image - uses: actions/upload-artifact@v4 - with: - name: docker-runner-jvm-artifact - path: artifacts/ftl-runner-jvm/ftl-runner-jvm.tar - retention-days: 1 - build-controller: - name: Build Controller Docker Image - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Init Hermit - uses: cashapp/activate-hermit@v1.1.3 - - name: Build - run: | - just build-docker controller - mkdir -p artifacts/ftl-controller - docker save -o artifacts/ftl-controller/ftl-controller.tar ftl0/ftl-controller:latest - - name: Temporarily save Docker image - uses: actions/upload-artifact@v4 - with: - name: docker-controller-artifact - path: artifacts/ftl-controller - retention-days: 1 - build-provisioner: - name: Build Provisioner Docker Image - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Init Hermit - uses: cashapp/activate-hermit@v1.1.3 - - name: Build - run: | - just build-docker provisioner - mkdir -p artifacts/ftl-provisioner - docker save -o artifacts/ftl-provisioner/ftl-provisioner.tar ftl0/ftl-provisioner:latest - - name: Temporarily save Docker image - uses: actions/upload-artifact@v4 - with: - name: docker-provisioner-artifact - path: artifacts/ftl-provisioner - retention-days: 1 - build-cron: - name: Build Cron Docker Image - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Init Hermit - uses: cashapp/activate-hermit@v1.1.3 - - name: Build - run: | - just build-docker cron - mkdir -p artifacts/ftl-cron - docker save -o artifacts/ftl-cron/ftl-cron.tar ftl0/ftl-cron:latest - - name: Temporarily save Docker image - uses: actions/upload-artifact@v4 - with: - name: docker-cron-artifact - path: artifacts/ftl-cron - retention-days: 1 - build-http-ingress: - name: Build HTTP Ingress Docker Image + - uses: actions/checkout@v4 + - uses: cashapp/activate-hermit@v1.1.3 + - id: set-matrix + run: echo "matrix=$(just list-docker-images | tr -d '\n' | jq -R -s -c 'split(" ")')" >> "$GITHUB_OUTPUT" + build-docker-images: + name: Build ${{ matrix.service }} Docker Image + needs: docker-shard runs-on: ubuntu-latest + strategy: + matrix: + service: ${{ fromJson(needs.docker-shard.outputs.matrix) }} steps: - name: Checkout code uses: actions/checkout@v4 - name: Init Hermit uses: cashapp/activate-hermit@v1.1.3 - - name: Build + - name: Build Docker Image run: | - just build-docker http-ingress - mkdir -p artifacts/ftl-http-ingress - docker save -o artifacts/ftl-http-ingress/ftl-http-ingress.tar ftl0/ftl-http-ingress:latest + just build-docker ${{ matrix.service }} + mkdir -p artifacts/ftl-${{ matrix.service }} + docker save -o artifacts/ftl-${{ matrix.service }}/ftl-${{ matrix.service }}.tar ftl0/ftl-${{ matrix.service }}:latest - name: Temporarily save Docker image uses: actions/upload-artifact@v4 with: - name: docker-http-ingress-artifact - path: artifacts/ftl-http-ingress + name: docker-${{ matrix.service }}-artifact + path: artifacts/ftl-${{ matrix.service }} retention-days: 1 release-docker: - name: Release Assets + name: Release Docker Images runs-on: ubuntu-latest permissions: contents: read packages: write - needs: [build-runners, build-controller, build-provisioner, build-cron, build-http-ingress] + needs: build-docker-images steps: - name: Checkout code uses: actions/checkout@v4 @@ -124,49 +51,17 @@ jobs: fetch-depth: 0 - name: Init Hermit uses: cashapp/activate-hermit@v1.1.3 - - name: Retrieve Runner Docker image - uses: actions/download-artifact@v4 - with: - name: docker-runner-artifact - path: artifacts/ftl-runner - - name: Retrieve JVM Runner Docker image - uses: actions/download-artifact@v4 - with: - name: docker-runner-jvm-artifact - path: artifacts/ftl-runner-jvm - - name: Retrieve Controller Docker image - uses: actions/download-artifact@v4 - with: - name: docker-controller-artifact - path: artifacts/ftl-controller - - name: Retrieve Provisioner Docker image - uses: actions/download-artifact@v4 - with: - name: docker-provisioner-artifact - path: artifacts/ftl-provisioner - - name: Retrieve Cron Docker image + - name: Download all artifacts uses: actions/download-artifact@v4 with: - name: docker-cron-artifact - path: artifacts/ftl-cron - - name: Retrieve HTTP Ingress Docker image - uses: actions/download-artifact@v4 - with: - name: docker-http-ingress-artifact - path: artifacts/ftl-http-ingress - - name: Load Runner Docker image - run: docker load -i artifacts/ftl-runner/ftl-runner.tar - - name: Load JVM Runner Docker image - run: docker load -i artifacts/ftl-runner-jvm/ftl-runner-jvm.tar - - name: Load Controller Docker image - run: docker load -i artifacts/ftl-controller/ftl-controller.tar - - name: Load Provisioner Docker image - run: docker load -i artifacts/ftl-provisioner/ftl-provisioner.tar - - name: Load Cron Docker image - run: docker load -i artifacts/ftl-cron/ftl-cron.tar - - name: Load HTTP Ingress Docker image - run: docker load -i artifacts/ftl-http-ingress/ftl-http-ingress.tar - - name: Log in to the Container registry + path: artifacts + pattern: docker-*-artifact + - name: Load Docker images + run: | + for tar in artifacts/ftl-*/ftl-*.tar; do + docker load -i "$tar" + done + - name: Log in to Container registry uses: docker/login-action@v3 with: username: ftl0 @@ -174,25 +69,11 @@ jobs: - name: Push Docker Images run: | version="$(git describe --tags --abbrev=0)" - docker tag ftl0/ftl-runner:latest ftl0/ftl-runner:"$GITHUB_SHA" - docker tag ftl0/ftl-runner:latest ftl0/ftl-runner:"$version" - docker push -a ftl0/ftl-runner - docker tag ftl0/ftl-runner-jvm:latest ftl0/ftl-runner-jvm:"$GITHUB_SHA" - docker tag ftl0/ftl-runner-jvm:latest ftl0/ftl-runner-jvm:"$version" - docker push -a ftl0/ftl-runner-jvm - 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-provisioner:latest ftl0/ftl-provisioner:"$GITHUB_SHA" - docker tag ftl0/ftl-provisioner:latest ftl0/ftl-provisioner:"$version" - docker push -a ftl0/ftl-provisioner - docker tag ftl0/ftl-cron:latest ftl0/ftl-cron:"$GITHUB_SHA" - docker tag ftl0/ftl-cron:latest ftl0/ftl-cron:"$version" - docker push -a ftl0/ftl-cron - docker tag ftl0/ftl-http-ingress:latest ftl0/ftl-http-ingress:"$GITHUB_SHA" - docker tag ftl0/ftl-http-ingress:latest ftl0/ftl-http-ingress:"$version" - docker push -a ftl0/ftl-http-ingress - + for image in $(just list-docker-images); do + docker tag "ftl0/ftl-${image}:latest" "ftl0/ftl-${image}:${GITHUB_SHA}" + docker tag "ftl0/ftl-${image}:latest" "ftl0/ftl-${image}:${version}" + docker push -a "ftl0/ftl-${image}" + done create-go-release: name: Release Go Binaries runs-on: ubuntu-latest @@ -305,8 +186,8 @@ jobs: - uses: actions/checkout@v4 name: "Checkout Charts Repository" with: - repository: '${{ github.repository_owner }}/ftl-charts' - token: '${{ secrets.FTL_CHARTS_TOKEN }}' + repository: "${{ github.repository_owner }}/ftl-charts" + token: "${{ secrets.FTL_CHARTS_TOKEN }}" fetch-depth: 0 - name: Checkout FTL uses: actions/checkout@v4 @@ -316,7 +197,7 @@ jobs: - name: Init Hermit uses: cashapp/activate-hermit@v1.1.3 with: - working-directory: '.ftl' + working-directory: ".ftl" - name: Configure Git run: | git config user.name "$GITHUB_ACTOR" @@ -332,4 +213,4 @@ jobs: cp -r .ftl/charts/ charts/ git add charts git commit -a -m "Update charts" - git push \ No newline at end of file + git push diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..937e237401 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +# Declare build arguments at the very top +ARG RUNTIME=scratch-runtime + +# Get certificates from Alpine (smaller than Ubuntu) +FROM alpine:latest AS certs +RUN apk --update add ca-certificates + +# Used for everything except ftl-runner +FROM scratch AS scratch-runtime +COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ + +# Used for ftl-runner +FROM ubuntu:24.04 AS ubuntu-runtime +RUN apt-get update && apt-get install -y ca-certificates +RUN mkdir -p /root/deployments + +# Final stage selection +FROM ${RUNTIME} +ARG EXTRA_FILES +ARG SERVICE + +WORKDIR /root/ +COPY . . + + +# Common environment variables +ENV PATH="$PATH:/root" + +# Service-specific configurations +EXPOSE 8891 +EXPOSE 8892 + +# Environment variables for all (most) services +ENV FTL_ENDPOINT="http://host.docker.internal:8892" +ENV FTL_BIND=http://0.0.0.0:8892 +ENV FTL_ADVERTISE=http://127.0.0.1:8892 + +# Controller-specific configurations +ENV FTL_CONTROLLER_CONSOLE_URL="*" +ENV FTL_CONTROLLER_DSN="postgres://host.docker.internal/ftl?sslmode=disable&user=postgres&password=secret" + +# Provisioner-specific configurations +ENV FTL_PROVISIONER_PLUGIN_CONFIG_FILE="/root/ftl-provisioner-config.toml" + +# Default command +CMD ["/root/svc"] diff --git a/Dockerfile.controller b/Dockerfile.controller deleted file mode 100644 index e98cc1194a..0000000000 --- a/Dockerfile.controller +++ /dev/null @@ -1,49 +0,0 @@ -FROM ubuntu:24.04 AS builder -RUN apt-get update -RUN apt-get install -y curl git zip - -# Copy Hermit bin stubs and install all packages. This is done -# separately so that Docker will cache the tools correctly. -COPY ./bin /src/bin -ENV PATH="/src/bin:$PATH" -WORKDIR /src - -# Seed some of the most common tools - this will be cached -RUN go version -RUN node --version - -# Download Go dependencies separately so Docker will cache them -COPY go.mod go.sum ./ -RUN go mod download -x - -# Download PNPM dependencies separately so Docker will cache them -COPY frontend/console/package.json ./frontend/console/ -COPY frontend/vscode/package.json ./frontend/vscode/ -COPY pnpm-workspace.yaml pnpm-lock.yaml ./ -RUN pnpm install --frozen-lockfile - -# Build -COPY . /src/ -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-controller ftl-initdb - -# Finally create the runtime image. -FROM scratch - -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ - -WORKDIR /service/ - -COPY --from=builder /src/build/release/ftl-controller . - -EXPOSE 8891 -EXPOSE 8892 - -ENV FTL_CONTROLLER_BIND="http://0.0.0.0:8892" -ENV FTL_CONTROLLER_ADVERTISE="http://127.0.0.1:8892" -ENV FTL_CONTROLLER_CONSOLE_URL="*" -ENV FTL_CONTROLLER_DSN="postgres://host.docker.internal/ftl?sslmode=disable&user=postgres&password=secret" - -CMD ["/service/ftl-controller"] diff --git a/Dockerfile.cron b/Dockerfile.cron deleted file mode 100644 index a85d938368..0000000000 --- a/Dockerfile.cron +++ /dev/null @@ -1,44 +0,0 @@ -FROM ubuntu:24.04 AS builder -RUN apt-get update -RUN apt-get install -y curl git zip - -# Copy Hermit bin stubs and install all packages. This is done -# separately so that Docker will cache the tools correctly. -COPY ./bin /src/bin -ENV PATH="/src/bin:$PATH" -WORKDIR /src - -# Seed some of the most common tools - this will be cached -RUN go version -RUN node --version - -# Download Go dependencies separately so Docker will cache them -COPY go.mod go.sum ./ -RUN go mod download -x - -# Download PNPM dependencies separately so Docker will cache them -COPY frontend/console/package.json ./frontend/console/ -COPY frontend/vscode/package.json ./frontend/vscode/ -COPY pnpm-workspace.yaml pnpm-lock.yaml ./ -RUN pnpm install --frozen-lockfile - -# Build -COPY . /src/ -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-without-frontend ftl-cron - -# Finally create the runtime image. -FROM scratch - -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ - -WORKDIR /plugins/ - -WORKDIR /service/ -COPY --from=builder /src/build/release/ftl-cron . - -EXPOSE 8893 - -CMD ["/service/ftl-cron"] diff --git a/Dockerfile.http-ingress b/Dockerfile.http-ingress deleted file mode 100644 index c769ade8f3..0000000000 --- a/Dockerfile.http-ingress +++ /dev/null @@ -1,44 +0,0 @@ -FROM ubuntu:24.04 AS builder -RUN apt-get update -RUN apt-get install -y curl git zip - -# Copy Hermit bin stubs and install all packages. This is done -# separately so that Docker will cache the tools correctly. -COPY ./bin /src/bin -ENV PATH="/src/bin:$PATH" -WORKDIR /src - -# Seed some of the most common tools - this will be cached -RUN go version -RUN node --version - -# Download Go dependencies separately so Docker will cache them -COPY go.mod go.sum ./ -RUN go mod download -x - -# Download PNPM dependencies separately so Docker will cache them -COPY frontend/console/package.json ./frontend/console/ -COPY frontend/vscode/package.json ./frontend/vscode/ -COPY pnpm-workspace.yaml pnpm-lock.yaml ./ -RUN pnpm install --frozen-lockfile - -# Build -COPY . /src/ -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-without-frontend ftl-http-ingress - -# Finally create the runtime image. -FROM scratch - -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ - -WORKDIR /plugins/ - -WORKDIR /service/ -COPY --from=builder /src/build/release/ftl-http-ingress . - -EXPOSE 8893 - -CMD ["/service/ftl-http-ingress"] diff --git a/Dockerfile.initdb b/Dockerfile.initdb deleted file mode 100644 index 0c8c3157be..0000000000 --- a/Dockerfile.initdb +++ /dev/null @@ -1,50 +0,0 @@ -FROM ubuntu:24.04 AS builder -RUN apt-get update -RUN apt-get install -y curl git zip - -# Copy Hermit bin stubs and install all packages. This is done -# separately so that Docker will cache the tools correctly. -COPY ./bin /src/bin -ENV PATH="/src/bin:$PATH" -WORKDIR /src - -# Seed some of the most common tools - this will be cached -RUN go version -RUN node --version - -# Download Go dependencies separately so Docker will cache them -COPY go.mod go.sum ./ -RUN go mod download -x - -# Download PNPM dependencies separately so Docker will cache them -COPY frontend/console/package.json ./frontend/console/ -COPY frontend/vscode/package.json ./frontend/vscode/ -COPY pnpm-workspace.yaml pnpm-lock.yaml ./ -RUN pnpm install --frozen-lockfile - -# Build -COPY . /src/ -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-without-frontend ftl-controller - -# Finally create the runtime image. -FROM scratch - -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ - -WORKDIR /service/ - -COPY --from=builder /src/build/release/ftl-controller . -COPY --from=builder /src/build/release/ftl-initdb . #TODO: Remove this line, we need a different migration image, this will get us moving for now though - -EXPOSE 8891 -EXPOSE 8892 - -ENV FTL_CONTROLLER_BIND="http://0.0.0.0:8892" -ENV FTL_CONTROLLER_ADVERTISE="http://127.0.0.1:8892" -ENV FTL_CONTROLLER_CONSOLE_URL="*" -ENV FTL_CONTROLLER_DSN="postgres://host.docker.internal/ftl?sslmode=disable&user=postgres&password=secret" - -CMD ["/service/ftl-controller"] diff --git a/Dockerfile.provisioner b/Dockerfile.provisioner deleted file mode 100644 index d3ec707ebd..0000000000 --- a/Dockerfile.provisioner +++ /dev/null @@ -1,50 +0,0 @@ -FROM ubuntu:24.04 AS builder -RUN apt-get update -RUN apt-get install -y curl git zip - -# Copy Hermit bin stubs and install all packages. This is done -# separately so that Docker will cache the tools correctly. -COPY ./bin /src/bin -ENV PATH="/src/bin:$PATH" -WORKDIR /src - -# Seed some of the most common tools - this will be cached -RUN go version -RUN node --version - -# Download Go dependencies separately so Docker will cache them -COPY go.mod go.sum ./ -RUN go mod download -x - -# Download PNPM dependencies separately so Docker will cache them -COPY frontend/console/package.json ./frontend/console/ -COPY frontend/vscode/package.json ./frontend/vscode/ -COPY pnpm-workspace.yaml pnpm-lock.yaml ./ -RUN pnpm install --frozen-lockfile - -# Build -COPY . /src/ -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-without-frontend ftl-provisioner ftl-provisioner-cloudformation - -# Finally create the runtime image. -FROM scratch - -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ - -WORKDIR /plugins/ -COPY ftl-provisioner-config.toml /config/config.toml -COPY --from=builder /src/build/release/ftl-provisioner-cloudformation . - -WORKDIR /service/ -COPY --from=builder /src/build/release/ftl-provisioner . - -EXPOSE 8893 - -ENV PATH="$PATH:/plugins/" -ENV FTL_PROVISIONER_BIND="http://0.0.0.0:8893" -ENV FTL_PROVISIONER_PLUGIN_CONFIG_FILE="/config/config.toml" - -CMD ["/service/ftl-provisioner"] diff --git a/Dockerfile.runner b/Dockerfile.runner deleted file mode 100644 index 04eabf69b4..0000000000 --- a/Dockerfile.runner +++ /dev/null @@ -1,40 +0,0 @@ -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 go 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 -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-without-frontend ftl-runner - -# Finally create the runtime image. -FROM ubuntu:24.04 -RUN apt-get update -RUN apt-get install -y ca-certificates - -WORKDIR /root/ - -COPY --from=builder /src/build/release/ftl-runner . -RUN mkdir deployments - -EXPOSE 8894 - -ENV FTL_ENDPOINT="http://host.docker.internal:8892" -ENV FTL_RUNNER_BIND="http://0.0.0.0:8893" - -CMD ["/root/ftl-runner", "--deployment-dir=deployments"] diff --git a/Justfile b/Justfile index 5342c02a49..23ff3641d6 100644 --- a/Justfile +++ b/Justfile @@ -27,6 +27,23 @@ PROTOS_OUT := "backend/protos/xyz/block/ftl/v1/console/console.pb.go " + \ CONSOLE_ROOT + "/src/protos/xyz/block/ftl/v1/ftl_pb.ts " + \ CONSOLE_ROOT + "/src/protos/xyz/block/ftl/v1/schema/runtime_pb.ts " + \ CONSOLE_ROOT + "/src/protos/xyz/block/ftl/v1/schema/schema_pb.ts" +# Configuration for building Docker images +DOCKER_IMAGES := ''' +{ + "controller": { + "extra_binaries": ["ftl"], + "extra_files": ["ftl-provisioner-config.toml"] + }, + "provisioner": { + "extra_binaries": ["ftl-provisioner-cloudformation"], + "extra_files": ["ftl-provisioner-config.toml"] + }, + "cron": {}, + "http-ingress": {}, + "runner": {}, + "runner-jvm": {} +} +''' _help: @just -l @@ -288,14 +305,63 @@ localstack-stop: storybook: @cd {{CONSOLE_ROOT}} && pnpm run storybook -# Build an FTL Docker image. +# Build an FTL Docker image build-docker name: - docker build \ - --platform linux/amd64 \ - -t ftl0/ftl-{{name}}:"${GITHUB_SHA:-$(git rev-parse HEAD)}" \ - -t ftl0/ftl-{{name}}:latest \ - -f Dockerfile.{{name}} . + #!/bin/bash + set -euo pipefail + + rm -rf build/release + + config="$(echo '{{DOCKER_IMAGES}}' | jq -r ".{{name}}")" + if [ "$config" = "null" ]; then + echo "FATAL: No configuration found for {{name}}" + exit 1 + fi + + # Determine if this is a runner variant + if [[ "{{name}}" =~ ^runner-(.+)$ ]]; then + runtime="${BASH_REMATCH[1]}" + # Build base runner first + just build-docker runner + # Build the language-specific runner + docker build \ + --platform linux/amd64 \ + -t ftl0/ftl-{{name}}:latest \ + -t ftl0/ftl-{{name}}:"${GITHUB_SHA:-$(git rev-parse HEAD)}" \ + -f Dockerfile.runner-${runtime} . + else + # First build the binary on host + extra_binaries="$(echo "$config" | jq -r '.extra_binaries // [] | join(" ")')" + GOARCH=amd64 GOOS=linux CGO_ENABLED=0 just build ftl-{{name}} ${extra_binaries} + # The main binary in the container must be named "svc" + (cd build/release && mv ftl-{{name}} svc) + + extra_files="$(echo "$config" | jq -r '.extra_files // [] | join(" ")')" + for file in $extra_files; do + echo "Copying $file to build/release" + cp "$file" build/release + done + + # Build regular service + docker build \ + --platform linux/amd64 \ + -t ftl0/ftl-{{name}}:latest \ + -t ftl0/ftl-{{name}}:"${GITHUB_SHA:-$(git rev-parse HEAD)}" \ + --build-arg SERVICE={{name}} \ + --build-arg PORT=8891 \ + --build-arg RUNTIME=$([ "{{name}}" = "runner" ] && echo "ubuntu-runtime" || echo "scratch-runtime") \ + --build-arg EXTRA_FILES="$(echo "$config" | jq -r '((.extra_files // []) + (.extra_binaries // [])) | join(" ")')" \ + -f Dockerfile build/release + fi + +# Build all Docker images +build-all-docker: + @for image in $(just list-docker-images); do just build-docker $image; done + +# List available Docker images +list-docker-images: + @echo '{{DOCKER_IMAGES}}' | jq -r 'keys | join(" ")' # Run a Just command in the Helm charts directory chart *args: - @cd charts && just {{args}} + @cd charts && just {{args}} diff --git a/backend/controller/controller.go b/backend/controller/controller.go index 7428f1cdf6..c513da4bec 100644 --- a/backend/controller/controller.go +++ b/backend/controller/controller.go @@ -78,10 +78,10 @@ type CommonConfig struct { } type Config struct { - Bind *url.URL `help:"Socket to bind to." default:"http://127.0.0.1:8892" env:"FTL_CONTROLLER_BIND"` + Bind *url.URL `help:"Socket to bind to." default:"http://127.0.0.1:8892" env:"FTL_BIND"` Key model.ControllerKey `help:"Controller key (auto)." placeholder:"KEY"` DSN string `help:"DAL DSN." default:"${dsn}" env:"FTL_CONTROLLER_DSN"` - Advertise *url.URL `help:"Endpoint the Controller should advertise (must be unique across the cluster, defaults to --bind if omitted)." env:"FTL_CONTROLLER_ADVERTISE"` + Advertise *url.URL `help:"Endpoint the Controller should advertise (must be unique across the cluster, defaults to --bind if omitted)." env:"FTL_ADVERTISE"` ConsoleURL *url.URL `help:"The public URL of the console (for CORS)." env:"FTL_CONTROLLER_CONSOLE_URL"` ContentTime time.Time `help:"Time to use for console resource timestamps." default:"${timestamp=1970-01-01T00:00:00Z}"` RunnerTimeout time.Duration `help:"Runner heartbeat timeout." default:"10s"` diff --git a/backend/ingress/service.go b/backend/ingress/service.go index 810117aee2..4743231f1c 100644 --- a/backend/ingress/service.go +++ b/backend/ingress/service.go @@ -29,7 +29,7 @@ type CallClient interface { } type Config struct { - Bind *url.URL `help:"Socket to bind to for ingress." default:"http://127.0.0.1:8891" env:"FTL_INGRESS_BIND"` + Bind *url.URL `help:"Socket to bind to for ingress." default:"http://127.0.0.1:8891" env:"FTL_BIND"` AllowOrigins []*url.URL `help:"Allow CORS requests to ingress endpoints from these origins." env:"FTL_INGRESS_ALLOW_ORIGIN"` AllowHeaders []string `help:"Allow these headers in CORS requests. (Requires AllowOrigins)" env:"FTL_INGRESS_ALLOW_HEADERS"` } diff --git a/backend/provisioner/service.go b/backend/provisioner/service.go index f8789a94a8..22815233b6 100644 --- a/backend/provisioner/service.go +++ b/backend/provisioner/service.go @@ -28,7 +28,7 @@ type CommonProvisionerConfig struct { } type Config struct { - Bind *url.URL `help:"Socket to bind to." default:"http://127.0.0.1:8893" env:"FTL_PROVISIONER_BIND"` + Bind *url.URL `help:"Socket to bind to." default:"http://127.0.0.1:8893" env:"FTL_BIND"` ControllerEndpoint *url.URL `name:"ftl-endpoint" help:"Controller endpoint." env:"FTL_ENDPOINT" default:"http://127.0.0.1:8892"` CommonProvisionerConfig } diff --git a/backend/runner/runner.go b/backend/runner/runner.go index 290ff814b9..39e5f5c527 100644 --- a/backend/runner/runner.go +++ b/backend/runner/runner.go @@ -51,7 +51,7 @@ import ( type Config struct { Config []string `name:"config" short:"C" help:"Paths to FTL project configuration files." env:"FTL_CONFIG" placeholder:"FILE[,FILE,...]" type:"existingfile"` - Bind *url.URL `help:"Endpoint the Runner should bind to and advertise." default:"http://127.0.0.1:8893" env:"FTL_RUNNER_BIND"` + Bind *url.URL `help:"Endpoint the Runner should bind to and advertise." default:"http://127.0.0.1:8893" env:"FTL_BIND"` Key model.RunnerKey `help:"Runner key (auto)."` ControllerEndpoint *url.URL `name:"ftl-endpoint" help:"Controller endpoint." env:"FTL_ENDPOINT" default:"http://127.0.0.1:8892"` ControllerPublicKey *identity.PublicKey `name:"ftl-public-key" help:"Controller public key in Base64. Temporarily optional." env:"FTL_CONTROLLER_PUBLIC_KEY"` diff --git a/charts/ftl/values.yaml b/charts/ftl/values.yaml index 16b997048c..8837ca5f09 100644 --- a/charts/ftl/values.yaml +++ b/charts/ftl/values.yaml @@ -40,9 +40,9 @@ controller: valueFrom: fieldRef: fieldPath: status.podIP - - name: FTL_CONTROLLER_BIND + - name: FTL_BIND value: "http://$(MY_POD_IP):8892" - - name: FTL_CONTROLLER_ADVERTISE + - name: FTL_ADVERTISE value: "http://$(MY_POD_IP):8892" - name: LOG_LEVEL value: "debug" @@ -107,7 +107,7 @@ provisioner: valueFrom: fieldRef: fieldPath: status.podIP - - name: FTL_PROVISIONER_BIND + - name: FTL_BIND value: "http://$(MY_POD_IP):8893" - name: FTL_ENDPOINT value: "http://ftl-controller:8892" @@ -163,9 +163,9 @@ runner: fieldPath: status.podIP - name: FTL_ENDPOINT value: "http://ftl-controller" - - name: FTL_RUNNER_BIND + - name: FTL_BIND value: "http://$(MY_POD_IP):8893" - - name: FTL_RUNNER_ADVERTISE + - name: FTL_ADVERTISE value: "" - name: FTL_RUNNER_START_DELAY value: "3s" @@ -254,7 +254,7 @@ ingress: fieldPath: status.podIP - name: FTL_ENDPOINT value: "http://ftl-controller:8892" - - name: FTL_INGRESS_BIND + - name: FTL_BIND value: "http://$(MY_POD_IP):8891" - name: FTL_INGRESS_ALLOW_ORIGIN value: "*" diff --git a/deployment/Dockerfile.controller.test b/deployment/Dockerfile.controller.test deleted file mode 100644 index e08cb422ca..0000000000 --- a/deployment/Dockerfile.controller.test +++ /dev/null @@ -1,18 +0,0 @@ -FROM ubuntu:24.04 - -WORKDIR /root/ - -COPY docker-build/ftl-controller . -COPY docker-build/ftl-initdb . -COPY docker-build/ftl . -RUN mkdir deployments - -EXPOSE 8891 -EXPOSE 8892 - -ENV FTL_CONTROLLER_BIND="http://0.0.0.0:8892" -ENV FTL_CONTROLLER_ADVERTISE="http://127.0.0.1:8892" -ENV FTL_CONTROLLER_CONSOLE_URL="*" -ENV FTL_CONTROLLER_DSN="postgres://host.docker.internal/ftl?sslmode=disable&user=postgres&password=secret" - -CMD ["/root/ftl-controller"] diff --git a/deployment/Dockerfile.cron.test b/deployment/Dockerfile.cron.test deleted file mode 100644 index 3aae385e46..0000000000 --- a/deployment/Dockerfile.cron.test +++ /dev/null @@ -1,7 +0,0 @@ -FROM ubuntu:24.04 - -WORKDIR /root/ - -COPY docker-build/ftl-cron . - -CMD ["/root/ftl-cron"] diff --git a/deployment/Dockerfile.http-ingress.test b/deployment/Dockerfile.http-ingress.test deleted file mode 100644 index 2f4d690b53..0000000000 --- a/deployment/Dockerfile.http-ingress.test +++ /dev/null @@ -1,8 +0,0 @@ -FROM ubuntu:24.04 - -WORKDIR /root/ - -COPY docker-build/ftl-http-ingress . -EXPOSE 8891 - -CMD ["/root/ftl-http-ingress"] diff --git a/deployment/Dockerfile.provisioner.test b/deployment/Dockerfile.provisioner.test deleted file mode 100644 index ca828e3054..0000000000 --- a/deployment/Dockerfile.provisioner.test +++ /dev/null @@ -1,13 +0,0 @@ -FROM ubuntu:24.04 - -WORKDIR /root/ - -COPY docker-build/ftl-provisioner . -COPY docker-build/ftl-provisioner-cloudformation /plugins/ -COPY docker-build/ftl . -EXPOSE 8893 -# Temp hack, this should be a configmap -ENV FTL_PROVISIONER_PLUGIN_CONFIG_FILE="/config/config.toml" -ENV PATH="$PATH:/plugins/" - -CMD ["/root/ftl-provisioner"] diff --git a/deployment/Dockerfile.runner-jvm.test b/deployment/Dockerfile.runner-jvm.test deleted file mode 100644 index cc7256cc0f..0000000000 --- a/deployment/Dockerfile.runner-jvm.test +++ /dev/null @@ -1,21 +0,0 @@ -# Huge hack, we want the JVM and same runtime environment as the runner -# So we just take the latest published runner image and copy the JDK from it -FROM ftl0/ftl-runner-jvm:latest AS jdk -# Create the runtime image. -FROM ubuntu:24.04 - -WORKDIR /root/ -ENV PATH="/root/jdk/bin:$PATH" -ENV JAVA_HOME="/root/jdk" -COPY --from=jdk /root/jdk/ /root/jdk/ - -COPY docker-build/ftl-runner . -COPY docker-build/ftl . -RUN mkdir deployments - -EXPOSE 8894 - -ENV FTL_ENDPOINT="http://host.docker.internal:8892" -ENV FTL_RUNNER_BIND="http://0.0.0.0:8893" - -CMD ["/root/ftl-runner", "--deployment-dir=deployments"] diff --git a/deployment/Dockerfile.runner.test b/deployment/Dockerfile.runner.test deleted file mode 100644 index 8d8a511126..0000000000 --- a/deployment/Dockerfile.runner.test +++ /dev/null @@ -1,15 +0,0 @@ -# Create the runtime image. -FROM ubuntu:24.04 - -WORKDIR /root/ - -COPY docker-build/ftl-runner . -COPY docker-build/ftl . -RUN mkdir deployments - -EXPOSE 8894 - -ENV FTL_ENDPOINT="http://host.docker.internal:8892" -ENV FTL_RUNNER_BIND="http://0.0.0.0:8893" - -CMD ["/root/ftl-runner", "--deployment-dir=deployments"] diff --git a/deployment/Justfile b/deployment/Justfile old mode 100755 new mode 100644 index af389ba45e..f937423b3d --- a/deployment/Justfile +++ b/deployment/Justfile @@ -1,3 +1,4 @@ +# Display all available just commands with descriptions _help: @just -l @@ -13,16 +14,20 @@ mirrors := ''' - "http://''' + registry_full + '''" ''' +# Start the FTL environment by setting up and deploying everything start: setup full-deploy +# Remove/teardown the FTL environment rm: teardown -full-deploy: build-controller build-runners build-provisioner setup-istio-cluster build-cron build-http-ingress +# Deploy all components after building images and setting up Istio +full-deploy: build-all-images setup-istio-cluster #!/bin/bash kubectl rollout restart deployment ftl-controller || true # if this exists already restart it to get the latest image just apply || sleep 5 # wait for CRDs to be created, the initial apply will usually fail just apply +# Wait for core Kubernetes components to be ready wait-for-kube: #!/bin/bash while [ -z "$(kubectl get pod ftl-postgresql-0)" ]; do sleep 1; done @@ -33,17 +38,20 @@ wait-for-kube: sleep 1 ftl status || sleep 5 && ftl status +# Wait for FTL version upgrade to complete wait-for-version-upgrade oldversion: #!/bin/bash while [ "$(ftl status | yq '.controllers[0].version')" == {{oldversion}} ]; do sleep 1; done ftl status +# Set up local container registry setup-registry: #!/bin/bash if [ -z "$(k3d registry list | grep {{registry_short}})" ]; then k3d registry create {{registry_short}} --port 5000 fi +# Set up Kubernetes cluster with registry configuration setup-cluster: setup-registry #!/bin/bash bash -c "cd ../ && just chart dep-update" @@ -54,6 +62,7 @@ setup-cluster: setup-registry fi kubectl config set-context --current --namespace=default +# Set up cluster with Istio service mesh setup-istio-cluster: setup-cluster #!/bin/bash if [ -z "$(kubectl get namespace | grep istio-system)" ]; then @@ -66,109 +75,102 @@ setup-istio-cluster: setup-cluster kubectl label namespace default istio-injection=enabled --overwrite kubectl apply -f istio-access-logs.yaml +# Complete setup of registry and Istio-enabled cluster setup: setup-registry setup-istio-cluster +# Remove local container registry teardown-registry: k3d registry delete {{registry_short}} +# Remove Kubernetes cluster teardown-cluster: k3d cluster delete ftl +# Complete teardown of environment teardown: teardown-cluster teardown-registry +# Apply Helm chart for FTL deployment apply: kubectl delete job --ignore-not-found=true ftl-dbmig-latest helm upgrade --install ftl ../charts/ftl -f values.yaml +# Deploy specific version of FTL from Helm repository deploy-version version: setup-istio-cluster helm repo add ftl https://tbd54566975.github.io/ftl-charts --force-update helm upgrade --install ftl ftl/ftl --version={{version}} -f values-release.yaml || sleep 5 # wait for CRDs to be created, the initial apply will usually fail helm upgrade --install ftl ftl/ftl --version={{version}} -f values-release.yaml +# Remove FTL Helm release delete: helm uninstall ftl +# Delete PostgreSQL persistent volume claim delete-db: kubectl delete pvc data-ftl-postgresql-0 +# Watch Kubernetes events events: kubectl get events -w +# Show status of all Kubernetes resources ps: kubectl get deployment,pod,statefulset,svc,configmap,pv,pvc,ingress -o wide +# Stream logs from specified Kubernetes resources logs *args: kubectl logs -f {{args}} +# Execute command in specified pod exec pod *args: kubectl exec -t {{pod}} -- {{args}} +# Open interactive shell in specified pod enter pod *args="bash": kubectl exec -it {{pod}} -- {{args}} +# Connect to PostgreSQL database psql: just enter statefulset.apps/ftl-postgresql env PGPASSWORD=ftl psql -U ftl ftl +# Check FTL controller status ftl-status: just exec deployment/ftl-controller ./ftl status -build-executables: - # we build locally then copy into the docker files - # it is way faster than building in the docker files - java -version #make sure hermit has downloaded Java - mkdir -p "docker-build" - cd ../ && GOARCH=amd64 GOOS=linux CGO_ENABLED=0 just build ftl-controller ftl-runner ftl-initdb ftl ftl-provisioner ftl-provisioner-cloudformation ftl-cron ftl-http-ingress - cp ../build/release/* ./docker-build/ - -build-controller: build-executables setup-registry setup-istio-cluster - docker build --platform linux/amd64 -t ftl-controller:latest -f Dockerfile.controller.test . - docker tag ftl-controller:latest {{registry_local}}/ftl-controller:latest - docker push {{registry_local}}/ftl-controller:latest - -build-runners: build-executables setup-registry setup-istio-cluster - just build-runner runner - just build-runner runner-jvm - -@build-runner name: - docker build --platform linux/amd64 -t ftl-{{name}}:latest -f Dockerfile.{{name}}.test . - docker tag ftl-{{name}}:latest {{registry_local}}/ftl-{{name}}:latest - docker push {{registry_local}}/ftl-{{name}}:latest - -build-provisioner: build-executables setup-registry setup-istio-cluster - docker build --platform linux/amd64 -t ftl-provisioner:latest -f Dockerfile.provisioner.test . - docker tag ftl-provisioner:latest {{registry_local}}/ftl-provisioner:latest - docker push {{registry_local}}/ftl-provisioner:latest - -build-cron: build-executables setup-registry setup-istio-cluster - docker build --platform linux/amd64 -t ftl-cron:latest -f Dockerfile.cron.test . - docker tag ftl-cron:latest {{registry_local}}/ftl-cron:latest - docker push {{registry_local}}/ftl-cron:latest - -build-http-ingress: build-executables setup-registry setup-istio-cluster - docker build --platform linux/amd64 -t ftl-http-ingress:latest -f Dockerfile.http-ingress.test . - docker tag ftl-http-ingress:latest {{registry_local}}/ftl-http-ingress:latest - docker push {{registry_local}}/ftl-http-ingress:latest - -build: build-controller build-runners build-provisioner build-cron build-http-ingress - +# Build and push all FTL images to local registry +build-all-images: setup-registry setup-istio-cluster + #!/bin/bash + for image in $(just -f ../Justfile list-docker-images); do + just -f ../Justfile build-docker $image + docker tag ftl0/ftl-$image:latest {{registry_local}}/ftl-$image:latest + docker push {{registry_local}}/ftl-$image:latest + done + +# Build and push single FTL image to local registry +build-image image: setup-registry setup-istio-cluster + just -f ../Justfile build-docker $image + docker tag ftl0/ftl-$image:latest {{registry_local}}/ftl-$image:latest + docker push {{registry_local}}/ftl-$image:latest + +# Deploy FTL module from specified path deploy path: - #!/usr/bin/env bash - set -euxo pipefail - rm -f ftl.tar.gz - COPYFILE_DISABLE=1 tar -cf ftl.tar -C .. . - export POD=$(kubectl get pods -l app=ftl-controller --no-headers | tail -1 | awk '{print $1}') - kubectl exec -it ${POD} -- apt install -y golang - kubectl exec -it ${POD} -- rm -rf /tmp/ftl/ - kubectl exec -it ${POD} -- mkdir -p /tmp/ftl/ - kubectl cp ftl.tar ${POD}:/tmp/ftl/ftl.tar - kubectl exec -it ${POD} -- tar --warning=no-unknown-keyword -tf /tmp/ftl/ftl.tar - kubectl exec -it ${POD} -- tar -xf /tmp/ftl/ftl.tar -C /tmp/ftl/ - kubectl exec -it ${POD} -- bash -c "cd /tmp/ftl && FTL_ENDPOINT=http://ftl-controller:8892 /root/ftl deploy {{path}}" - rm -f ftl.tar.gz - + #!/usr/bin/env bash + set -euxo pipefail + rm -f ftl.tar.gz + COPYFILE_DISABLE=1 tar -cf ftl.tar -C .. . + export POD=$(kubectl get pods -l app=ftl-controller --no-headers | tail -1 | awk '{print $1}') + kubectl exec -it ${POD} -- apt install -y golang + kubectl exec -it ${POD} -- rm -rf /tmp/ftl/ + kubectl exec -it ${POD} -- mkdir -p /tmp/ftl/ + kubectl cp ftl.tar ${POD}:/tmp/ftl/ftl.tar + kubectl exec -it ${POD} -- tar --warning=no-unknown-keyword -tf /tmp/ftl/ftl.tar + kubectl exec -it ${POD} -- tar -xf /tmp/ftl/ftl.tar -C /tmp/ftl/ + kubectl exec -it ${POD} -- bash -c "cd /tmp/ftl && FTL_ENDPOINT=http://ftl-controller:8892 /root/ftl deploy {{path}}" + rm -f ftl.tar.gz + +# Execute FTL CLI commands in the controller pod ftl *args: - #!/usr/bin/env bash - set -euxo pipefail - export POD=$(kubectl get pods -l app=ftl-controller --no-headers | tail -1 | awk '{print $1}') - kubectl exec -it ${POD} -- bash -c "FTL_ENDPOINT=http://ftl-controller:8892 /root/ftl {{args}}" + #!/usr/bin/env bash + set -euxo pipefail + export POD=$(kubectl get pods -l app=ftl-controller --no-headers | tail -1 | awk '{print $1}') + kubectl exec -it ${POD} -- bash -c "FTL_ENDPOINT=http://ftl-controller:8892 /root/ftl {{args}}" diff --git a/lefthook.yml b/lefthook.yml index 2457af9efb..cbccf86b97 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -16,3 +16,6 @@ pre-push: run: just lint-frontend ensure-frozen-migrations: run: just ensure-frozen-migrations + actionlint: + root: .github/workflows/ + run: actionlint