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 Dec 2, 2022
1 parent 012bfdd commit cba69fa
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 6 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/docker-build-only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# 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
services:
registry:
image: registry:2
ports:
- 5000:5000
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@v2
with:
driver-opts: network=host

- name: Build Server Image
uses: docker/build-push-action@v3
with:
context: .
file: server.Dockerfile
build-args: |
TEMPORAL_REPO_PATH=temporal-server-checkedout
GOFLAGS=-buildvcs=false
tags: localhost:5000/temporal-server:latest
push: true

- name: Build Admin tools Image
uses: docker/build-push-action@v3
with:
context: .
file: admin-tools.Dockerfile
build-args: |
TEMPORAL_REPO_PATH=temporal-server-checkedout
SERVER_IMAGE=localhost:5000/temporal-server:latest
GOFLAGS=-buildvcs=false
tags: localhost:5000/temporal-admin-tools:latest
push: true

- name: Build Autosetup Image
uses: docker/build-push-action@v3
with:
context: .
file: auto-setup.Dockerfile
build-args: |
SERVER_IMAGE=localhost:5000/temporal-server:latest
ADMIN_TOOLS_IMAGE=localhost:5000/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
7 changes: 5 additions & 2 deletions admin-tools.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ ARG GOPROXY

##### Temporal Admin Tools builder #####
FROM ${BASE_BUILDER_IMAGE} AS admin-tools-builder
ARG TEMPORAL_REPO_PATH=temporal
ARG GOFLAGS
ENV GOFLAGS ${GOFLAGS}

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
11 changes: 7 additions & 4 deletions server.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
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
ARG GOFLAGS
ENV GOFLAGS ${GOFLAGS}

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
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 cba69fa

Please sign in to comment.