Repository navigation
105 lines (95 loc) · 3.12 KB
/
Copy pathdocker.yml
File metadata and controls
105 lines (95 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Docker image
on:
push:
branches: [master]
tags: ["v*.*.*"]
pull_request:
branches: [master]
workflow_dispatch:
inputs:
tag:
description: "Image tag to build"
required: true
default: "dev"
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
fail-fast: false
steps:
- uses: actions/checkout@v7
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Extract version
id: meta
run: |
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
VERSION="${GITHUB_REF_NAME#v}"
elif [[ -n "${INPUT_TAG:-}" ]]; then
VERSION="${INPUT_TAG}"
else
VERSION="dev"
fi
echo "VERSION=${VERSION}" >> "${GITHUB_OUTPUT}"
echo "GIT_SHA=${GITHUB_SHA::12}" >> "${GITHUB_OUTPUT}"
echo "BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "${GITHUB_OUTPUT}"
- name: Build image
uses: docker/build-push-action@v7
with:
context: .
file: Dockerfile
push: false
platforms: linux/amd64,linux/arm64
tags: |
underwrite:${{ steps.meta.outputs.VERSION }}
underwrite:sha-${{ steps.meta.outputs.GIT_SHA }}
build-args: |
BUILD_VERSION=${{ steps.meta.outputs.VERSION }}
GIT_COMMIT=${{ steps.meta.outputs.GIT_SHA }}
BUILD_DATE=${{ steps.meta.outputs.BUILD_DATE }}
PYTHON_VERSION=${{ matrix.python-version }}
EXTRAS=serve,otlp,vault
provenance: false
sbom: false
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Smoke test image
run: |
docker run --rm -d --name underwrite-smoke \
-p 8080:8080 \
-e UNDERWRITE_REQUIRE_AUTH=false \
-e UNDERWRITE_DATA_DIR=/tmp/uw-data \
underwrite:sha-${{ steps.meta.outputs.GIT_SHA }}
sleep 5
curl -sf http://127.0.0.1:8080/healthz || { docker logs underwrite-smoke; exit 1; }
docker stop underwrite-smoke
- name: Smoke test CLI
run: |
docker run --rm --entrypoint underwrite \
underwrite:sha-${{ steps.meta.outputs.GIT_SHA }} \
--help
- name: Push to registry
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/build-push-action@v7
with:
context: .
file: Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ steps.meta.outputs.VERSION }}
ghcr.io/${{ github.repository }}:latest
build-args: |
BUILD_VERSION=${{ steps.meta.outputs.VERSION }}
GIT_COMMIT=${{ steps.meta.outputs.GIT_SHA }}
BUILD_DATE=${{ steps.meta.outputs.BUILD_DATE }}
PYTHON_VERSION=${{ matrix.python-version }}
EXTRAS=serve,otlp,vault
provenance: false
sbom: false