Skip to content

Commit

Permalink
Add callable workflow for only building the server image
Browse files Browse the repository at this point in the history
  • Loading branch information
Sushisource committed Nov 23, 2022
1 parent 012bfdd commit 2652c1d
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 5 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/docker-build-only.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions admin-tools.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
10 changes: 7 additions & 3 deletions server.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
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
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
Expand Down

0 comments on commit 2652c1d

Please sign in to comment.