Skip to content

Commit 65cd365

Browse files
committed
ci: docker build
1 parent 1722917 commit 65cd365

File tree

6 files changed

+208
-2
lines changed

6 files changed

+208
-2
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 Cisco and/or its affiliates.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
---
5+
name: ci-docker-build
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
pull_request:
12+
branches:
13+
- "main"
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
18+
19+
jobs:
20+
docker-build:
21+
name: Build wfsrv docker image
22+
uses: ./.github/workflows/reusable-docker-build-push.yaml
23+
with:
24+
bake-target: workflowserver
25+
image-name: wfsrv
26+
image-tag: ${{ github.sha }}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 Cisco and/or its affiliates.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
---
5+
name: ci-release-image
6+
7+
on:
8+
push:
9+
tags:
10+
- "v?[0-9]+.[0-9]+.[0-9]+"
11+
- "v?[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+"
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
16+
17+
jobs:
18+
build-push:
19+
name: Build docker image - wfsrv
20+
uses: ./.github/workflows/reusable-docker-build-push.yaml
21+
permissions:
22+
contents: "read"
23+
packages: "write"
24+
attestations: "write"
25+
with:
26+
bake-target: workflowserver
27+
image-name: wfsrv
28+
image-tag: ${{ github.ref_name }}
29+
secrets:
30+
github-token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 Cisco and/or its affiliates.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
---
5+
name: Build and Push
6+
7+
on:
8+
workflow_call:
9+
inputs:
10+
bake-target:
11+
required: true
12+
type: string
13+
description: "Bake target"
14+
bake-file:
15+
required: false
16+
type: string
17+
description: "Bake file"
18+
default: "docker-bake.hcl"
19+
image-name:
20+
required: true
21+
type: string
22+
description: "Image repo to use."
23+
image-tag:
24+
required: true
25+
type: string
26+
description: "Image tag to use."
27+
secrets:
28+
github-token:
29+
description: "github token"
30+
required: false
31+
32+
jobs:
33+
build-and-push:
34+
name: Build and Push
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
40+
with:
41+
fetch-depth: 0
42+
43+
- name: Login to GitHub Container Registry
44+
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
45+
uses: docker/login-action@v3
46+
with:
47+
registry: ghcr.io
48+
username: ${{github.actor}}
49+
password: ${{secrets.github-token}}
50+
51+
- name: Setup QEMU
52+
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
53+
54+
- name: Setup Docker Buildx
55+
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
56+
57+
- name: Docker metadata
58+
id: metadata
59+
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
60+
with:
61+
images: |
62+
ghcr.io/agntcy/acp/${{ inputs.image-name }}
63+
tags: |
64+
type=raw,value=${{ inputs.image-tag }}
65+
type=raw,value=latest,enable=${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
66+
67+
- name: Build and push
68+
uses: docker/bake-action@a4d7f0b5b91c14a296d792d4ec53a9db17f02e67 # v5.5.0
69+
with:
70+
files: |
71+
${{ inputs.bake-file }}
72+
${{ steps.metadata.outputs.bake-file }}
73+
targets: ${{ inputs.bake-target }}
74+
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
75+
provenance: false

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PACKAGE_NAME := agent_workflow_server.generated
77
GENERATOR_IMAGE := openapitools/openapi-generator-cli:latest
88
ADDITIONAL_PROPERTIES := packageName=$(PACKAGE_NAME),python_typed=true
99

10-
.PHONY: clean validate-spec update-spec generate-api
10+
.PHONY: clean validate-spec update-spec generate-api run docker-build-dev
1111

1212
# Ensure output directory exists
1313
$(OUTPUT_DIR):
@@ -44,4 +44,7 @@ generate-api: clean update-spec
4444
# Install dependecies and run server
4545
run:
4646
poetry install
47-
poetry run server
47+
poetry run server
48+
49+
docker-build-dev: ## Build the docker image.
50+
docker buildx bake workflowserver-dev

assets/workflowserver.Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM python:3.12
2+
3+
ENV POETRY_VERSION=2.1.1
4+
5+
RUN set -ex; pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org poetry==$POETRY_VERSION;
6+
7+
WORKDIR /opt/agent-workflow-server
8+
9+
COPY . .
10+
11+
RUN poetry config virtualenvs.create true
12+
RUN poetry config virtualenvs.in-project true
13+
RUN poetry install --no-interaction
14+
15+
EXPOSE 8000
16+
17+
CMD ["poetry" ,"run", "server"]

docker-bake.hcl

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// SPDX-FileCopyrightText: Copyright (c) 2025 Cisco and/or its affiliates.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
5+
# Documentation available at: https://docs.docker.com/build/bake/
6+
7+
# Docker build args
8+
variable "IMAGE_REPO" {default = ""}
9+
variable "IMAGE_TAG" {default = "v0.0.0-dev"}
10+
11+
function "get_tag" {
12+
params = [tags, name]
13+
result = coalescelist(tags, ["${IMAGE_REPO}/${name}:${IMAGE_TAG}"])
14+
}
15+
16+
group "default" {
17+
targets = ["workflowserver"]
18+
}
19+
20+
group "workflowserver" {
21+
targets = [
22+
"workflowserver",
23+
]
24+
}
25+
26+
target "_common" {
27+
output = [
28+
"type=image",
29+
]
30+
platforms = [
31+
"linux/arm64",
32+
"linux/amd64",
33+
]
34+
}
35+
36+
target "docker-metadata-action" {
37+
tags = []
38+
}
39+
40+
target "workflowserver-dev" {
41+
context = "."
42+
dockerfile = "assets/workflowserver.Dockerfile"
43+
tags = [
44+
"workflowserver:latest",
45+
]
46+
}
47+
48+
target "workflowserver" {
49+
tags = get_tag(target.docker-metadata-action.tags, "${target.workflowserver.name}")
50+
inherits = [
51+
"workflowserver-dev",
52+
"_common",
53+
"docker-metadata-action",
54+
]
55+
}

0 commit comments

Comments
 (0)