Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add callable workflow for only building the server image #87

Merged
merged 3 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/docker-build-only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# 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.
mindaugasrukas marked this conversation as resolved.
Show resolved Hide resolved
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
mindaugasrukas marked this conversation as resolved.
Show resolved Hide resolved
repository: temporalio/docker-builds
ref: ${{ inputs.docker-builds-repo-ref }}
submodules: "true"

- name: Checkout temporal server repository
Sushisource marked this conversation as resolved.
Show resolved Hide resolved
# I have no idea why all this hullabaloo with explicitly fetching the other repo's branch
# is necessary, you should be able to just `git submodule update --init` and have it work,
# but possibly something about the barebones nature of the checkout action makes that not
# work.
run: |
git submodule set-url temporal ${{ format('https://github.com/{0}', inputs.temporal-server-repo-path) }}
git submodule set-branch --branch ${{ inputs.temporal-server-repo-ref }} -- temporal
git submodule sync
cat .gitmodules
echo "Updating temporal submodule"
cd temporal
git remote show origin
git fetch --depth 1 origin ${{ inputs.temporal-server-repo-ref }}:refs/remotes/origin/${{ inputs.temporal-server-repo-ref }}
git checkout origin/${{ inputs.temporal-server-repo-ref }}
cd ..
git submodule status temporal

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: network=host

- name: Build Server Image
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any way to share more of this with docker.yml?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They will be combined later by @mindaugasrukas

uses: docker/build-push-action@v3
with:
context: .
file: server.Dockerfile
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: |
SERVER_IMAGE=localhost:5000/temporal-server:latest
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

# Upload-artifact has no good way to flatten paths, so we need to move the compose file
# to avoid some disgustingly long inner path inside the artifact zip.
mindaugasrukas marked this conversation as resolved.
Show resolved Hide resolved
- name: Copy compose file
run: cp ./temporal/develop/docker-compose/docker-compose.yml /tmp/docker-compose.yml

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: temporal-server-docker
path: |
/tmp/temporal-autosetup.tar
/tmp/docker-compose.yml
5 changes: 4 additions & 1 deletion admin-tools.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ COPY ./temporal/go.mod ./temporal/go.sum ./temporal/
RUN (cd ./temporal && go mod download all)

# build
COPY . .
COPY ./temporal ./temporal
# Git info is needed for Go build to attach VCS information properly
COPY ./.git ./.git
COPY ./.gitmodules ./.gitmodules
mindaugasrukas marked this conversation as resolved.
Show resolved Hide resolved
RUN (cd ./temporal && make temporal-cassandra-tool temporal-sql-tool tdbg)


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


WORKDIR /home/builder

# cache Temporal packages as a docker layer
Expand All @@ -17,12 +15,17 @@ COPY ./tctl/go.mod ./tctl/go.sum ./tctl/
RUN (cd ./tctl && go mod download all)

# build
COPY . .
COPY ./tctl ./tctl
COPY ./temporal ./temporal
# Git info is needed for Go build to attach VCS information properly
COPY ./.git ./.git
COPY ./.gitmodules ./.gitmodules
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