diff --git a/.github/workflows/docker-build-only.yml b/.github/workflows/docker-build-only.yml new file mode 100644 index 00000000..29e6993e --- /dev/null +++ b/.github/workflows/docker-build-only.yml @@ -0,0 +1,84 @@ +# This workflow builds the server docker image and exposes it as an artifact which may be used by +# other GitHub workflow jobs. This is useful for creating docker images that you want to use to +# test a certain commit of server without publishing them. + +name: Build Docker Image as Artifact + +on: + workflow_call: + inputs: + # TODO: Shouldn't be required. If not set, use existing submodule. + temporal-server-repo-ref: + type: string + required: true + temporal-server-repo-path: + type: string + default: "temporalio/temporal" + docker-builds-repo-ref: + type: string + default: "main" + +jobs: + build-image: + # TODO: use bigger runner when available. Seems like they're stuck or not enough? + runs-on: ubuntu-latest + steps: + - name: Checkout docker builds repository + uses: actions/checkout@v3 + with: + # Must specify repo path, or it will use path of calling workflow + repository: temporalio/docker-builds + ref: ${{ inputs.docker-builds-repo-ref }} + submodules: "true" + + - name: Checkout temporal server repository + uses: actions/checkout@v3 + with: + repository: ${{ inputs.temporal-server-repo-path }} + path: temporal-server-checkedout + ref: ${{ inputs.temporal-server-repo-ref }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build Server Image + uses: docker/build-push-action@v3 + with: + context: . + platforms: linux/amd64 + file: server.Dockerfile + build-args: TEMPORAL_REPO_PATH=temporal-server-checkedout + tags: temporal-server:latest + load: true + + - name: Build Admin tools Image + uses: docker/build-push-action@v3 + with: + context: . + platforms: linux/amd64 + file: admin-tools.Dockerfile + build-args: | + TEMPORAL_REPO_PATH=temporal-server-checkedout + SERVER_IMAGE=temporal-server:latest + tags: temporal-admin-tools:latest + load: true + + - name: Build Autosetup Image + uses: docker/build-push-action@v3 + with: + context: . + platforms: linux/amd64 + file: admin-tools.Dockerfile + build-args: | + SERVER_IMAGE=temporal-server:latest + ADMIN_TOOLS_IMAGE=temporal-admin-tools:latest + tags: temporal-autosetup:latest + outputs: type=docker,dest=/tmp/temporal-autosetup.tar + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: temporal-server-docker + path: | + /tmp/temporal-autosetup.tar + ./temporal-server-checkout/develop/docker-compose/docker-compose.yml diff --git a/admin-tools.Dockerfile b/admin-tools.Dockerfile index 4ed26eaa..93134556 100644 --- a/admin-tools.Dockerfile +++ b/admin-tools.Dockerfile @@ -5,15 +5,16 @@ ARG GOPROXY ##### Temporal Admin Tools builder ##### FROM ${BASE_BUILDER_IMAGE} AS admin-tools-builder +ARG TEMPORAL_REPO_PATH=temporal WORKDIR /home/builder # cache Temporal packages as a docker layer -COPY ./temporal/go.mod ./temporal/go.sum ./temporal/ +COPY ./${TEMPORAL_REPO_PATH}/go.mod ./${TEMPORAL_REPO_PATH}/go.sum ./temporal/ RUN (cd ./temporal && go mod download all) # build -COPY . . +COPY ./${TEMPORAL_REPO_PATH} ./temporal RUN (cd ./temporal && make temporal-cassandra-tool temporal-sql-tool tdbg) diff --git a/server.Dockerfile b/server.Dockerfile index f51a64f1..a194ef6f 100644 --- a/server.Dockerfile +++ b/server.Dockerfile @@ -1,15 +1,15 @@ ARG BASE_BUILDER_IMAGE=temporalio/base-builder:1.11.0 ARG BASE_SERVER_IMAGE=temporalio/base-server:1.12.0 -ARG GOPROXY ##### Builder ##### FROM ${BASE_BUILDER_IMAGE} AS temporal-builder +ARG TEMPORAL_REPO_PATH=temporal WORKDIR /home/builder # cache Temporal packages as a docker layer -COPY ./temporal/go.mod ./temporal/go.sum ./temporal/ +COPY ./${TEMPORAL_REPO_PATH}/go.mod ./${TEMPORAL_REPO_PATH}/go.sum ./temporal/ RUN (cd ./temporal && go mod download all) # cache tctl packages as a docker layer @@ -17,12 +17,16 @@ COPY ./tctl/go.mod ./tctl/go.sum ./tctl/ RUN (cd ./tctl && go mod download all) # build -COPY . . +COPY ./tctl ./tctl +COPY ./${TEMPORAL_REPO_PATH} ./temporal +# TODO: Not sure why this is suddenly necessary to make the build pass +ENV GOFLAGS -buildvcs=false RUN (cd ./temporal && make temporal-server) RUN (cd ./tctl && make build) ##### Temporal server ##### FROM ${BASE_SERVER_IMAGE} as temporal-server + WORKDIR /etc/temporal ENV TEMPORAL_HOME /etc/temporal