Skip to content

Commit 6606b35

Browse files
authored
Merge pull request #705 from atlanhq/APP-7913
[ci] Added workflow for `pyatlan-wolfi-base` image build
2 parents adcaef3 + 6b97606 commit 6606b35

2 files changed

Lines changed: 209 additions & 0 deletions

File tree

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: Build Pyatlan Wolfi Base Image
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
build_type:
7+
description: 'Build type (dev uses amd64 only, release uses amd64+arm64)'
8+
required: true
9+
default: 'dev'
10+
type: choice
11+
options:
12+
- 'dev'
13+
- 'release'
14+
python_version:
15+
description: 'Python version (leave empty for 3.13)'
16+
required: false
17+
type: choice
18+
options:
19+
- ''
20+
- '3.9'
21+
- '3.10'
22+
- '3.11'
23+
- '3.12'
24+
- '3.13'
25+
pyatlan_version:
26+
description: 'Pyatlan version (leave empty to use version.txt ie: latest)'
27+
required: false
28+
type: string
29+
30+
permissions:
31+
contents: read
32+
packages: write
33+
34+
jobs:
35+
build-and-push:
36+
runs-on: ubuntu-latest
37+
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
with:
42+
fetch-depth: 0 # Need full history for commit hash
43+
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v3
46+
47+
- name: Log in to GitHub Container Registry
48+
uses: docker/login-action@v3
49+
with:
50+
registry: ghcr.io
51+
username: ${{ github.actor }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Set build parameters
55+
id: set-params
56+
run: |
57+
# Set Python version (default to 3.13 if empty)
58+
if [ -z "${{ github.event.inputs.python_version }}" ]; then
59+
PYTHON_VERSION="3.13"
60+
else
61+
PYTHON_VERSION="${{ github.event.inputs.python_version }}"
62+
fi
63+
echo "PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV
64+
65+
# Set Pyatlan version (default to version.txt if empty)
66+
if [ -z "${{ github.event.inputs.pyatlan_version }}" ]; then
67+
PYATLAN_VERSION=$(cat pyatlan/version.txt)
68+
echo "Using pyatlan version from version.txt: $PYATLAN_VERSION"
69+
else
70+
PYATLAN_VERSION="${{ github.event.inputs.pyatlan_version }}"
71+
echo "Using specified pyatlan version: $PYATLAN_VERSION"
72+
fi
73+
echo "PYATLAN_VERSION=$PYATLAN_VERSION" >> $GITHUB_ENV
74+
75+
# Set platforms based on build type
76+
if [ "${{ github.event.inputs.build_type }}" = "dev" ]; then
77+
PLATFORMS="linux/amd64"
78+
else
79+
PLATFORMS="linux/amd64,linux/arm64"
80+
fi
81+
echo "PLATFORMS=$PLATFORMS" >> $GITHUB_ENV
82+
83+
# Generate commit hash for dev builds
84+
COMMIT_HASH=$(git rev-parse --short HEAD)
85+
echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_ENV
86+
87+
echo "Build parameters:"
88+
echo " - Build Type: ${{ github.event.inputs.build_type }}"
89+
echo " - Python Version: $PYTHON_VERSION"
90+
echo " - Pyatlan Version: $PYATLAN_VERSION"
91+
echo " - Platforms: $PLATFORMS"
92+
echo " - Commit Hash: $COMMIT_HASH"
93+
94+
- name: Generate image tags
95+
id: generate-tags
96+
run: |
97+
BUILD_TYPE="${{ github.event.inputs.build_type }}"
98+
PYTHON_VERSION="${{ env.PYTHON_VERSION }}"
99+
PYATLAN_VERSION="${{ env.PYATLAN_VERSION }}"
100+
COMMIT_HASH="${{ env.COMMIT_HASH }}"
101+
102+
if [ "$BUILD_TYPE" = "dev" ]; then
103+
# Dev: 8.0.0-3.11-commithash
104+
IMAGE_TAG="${PYATLAN_VERSION}-${PYTHON_VERSION}-${COMMIT_HASH}"
105+
else
106+
# Release: 8.0.0-3.11
107+
IMAGE_TAG="${PYATLAN_VERSION}-${PYTHON_VERSION}"
108+
fi
109+
110+
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
111+
112+
echo "Generated image tag: ghcr.io/atlanhq/pyatlan-wolfi-base:$IMAGE_TAG"
113+
114+
- name: Wait for PyPI availability
115+
if: github.event.inputs.pyatlan_version != ''
116+
uses: nick-fields/retry@v3
117+
with:
118+
max_attempts: 5
119+
timeout_minutes: 3
120+
command: |
121+
echo "Checking if pyatlan==${{ env.PYATLAN_VERSION }} is available on PyPI..."
122+
if pip index versions pyatlan | grep -q "${{ env.PYATLAN_VERSION }}"; then
123+
echo "Package is available on PyPI!"
124+
exit 0
125+
else
126+
echo "Package not available yet. Retrying..."
127+
exit 1
128+
fi
129+
130+
- name: Build and push Docker image
131+
uses: docker/build-push-action@v6
132+
with:
133+
context: .
134+
file: ./Dockerfile.wolfi
135+
platforms: ${{ env.PLATFORMS }}
136+
push: true
137+
tags: |
138+
ghcr.io/atlanhq/pyatlan-wolfi-base:${{ env.IMAGE_TAG }}
139+
build-args: |
140+
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
141+
PYATLAN_VERSION=${{ env.PYATLAN_VERSION }}
142+
cache-from: type=gha
143+
cache-to: type=gha,mode=max
144+
145+
- name: Output image information
146+
run: |
147+
echo "## 🐳 Wolfi Docker Image Built Successfully!" >> $GITHUB_STEP_SUMMARY
148+
echo "" >> $GITHUB_STEP_SUMMARY
149+
echo "### Image Details:" >> $GITHUB_STEP_SUMMARY
150+
echo "- **Base Image:** Wolfi" >> $GITHUB_STEP_SUMMARY
151+
echo "- **Build Type:** ${{ github.event.inputs.build_type }}" >> $GITHUB_STEP_SUMMARY
152+
echo "- **Python Version:** ${{ env.PYTHON_VERSION }}" >> $GITHUB_STEP_SUMMARY
153+
echo "- **Pyatlan Version:** ${{ env.PYATLAN_VERSION }}" >> $GITHUB_STEP_SUMMARY
154+
echo "- **Platforms:** ${{ env.PLATFORMS }}" >> $GITHUB_STEP_SUMMARY
155+
if [ "${{ github.event.inputs.build_type }}" = "dev" ]; then
156+
echo "- **Commit Hash:** ${{ env.COMMIT_HASH }}" >> $GITHUB_STEP_SUMMARY
157+
fi
158+
echo "" >> $GITHUB_STEP_SUMMARY
159+
echo "### Available Tag:" >> $GITHUB_STEP_SUMMARY
160+
echo "- \`ghcr.io/atlanhq/pyatlan-wolfi-base:${{ env.IMAGE_TAG }}\`" >> $GITHUB_STEP_SUMMARY
161+
echo "" >> $GITHUB_STEP_SUMMARY
162+
echo "### Usage in your Dockerfile:" >> $GITHUB_STEP_SUMMARY
163+
echo "\`\`\`dockerfile" >> $GITHUB_STEP_SUMMARY
164+
echo "FROM ghcr.io/atlanhq/pyatlan-wolfi-base:${{ env.IMAGE_TAG }}" >> $GITHUB_STEP_SUMMARY
165+
echo "" >> $GITHUB_STEP_SUMMARY
166+
echo "# Your application code here" >> $GITHUB_STEP_SUMMARY
167+
echo "COPY your-package/ /app/" >> $GITHUB_STEP_SUMMARY
168+
echo "RUN uv pip install --system -r requirements.txt" >> $GITHUB_STEP_SUMMARY
169+
echo "" >> $GITHUB_STEP_SUMMARY
170+
echo "CMD [\"python\", \"your-app.py\"]" >> $GITHUB_STEP_SUMMARY
171+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

Dockerfile.wolfi

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM cgr.dev/chainguard/wolfi-base
2+
3+
# Build arguments for configurable versions
4+
ARG PYTHON_VERSION=3.11
5+
ARG PYATLAN_VERSION=latest
6+
7+
WORKDIR /app
8+
9+
# Install Python
10+
RUN apk add python-${PYTHON_VERSION} && \
11+
chown -R nonroot:nonroot /app/
12+
13+
# Install uv
14+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
15+
16+
USER nonroot
17+
18+
# Create uv cache directory with proper permissions
19+
RUN mkdir -p /home/nonroot/.cache/uv && \
20+
chown -R nonroot:nonroot /home/nonroot/.cache
21+
22+
# Install pyatlan from PyPI using uv pip install
23+
RUN --mount=type=cache,target=/home/nonroot/.cache/uv,uid=65532,gid=65532 \
24+
if [ "$PYATLAN_VERSION" = "latest" ]; then \
25+
uv pip install --system pyatlan; \
26+
else \
27+
uv pip install --system pyatlan==$PYATLAN_VERSION; \
28+
fi
29+
30+
# Set environment variables
31+
ENV PYTHONPATH=/app
32+
ENV PATH="/home/nonroot/.local/bin:${PATH}"
33+
34+
# Default working directory for applications
35+
WORKDIR /app
36+
37+
# Default command (can be overridden by extending images)
38+
CMD ["python"]

0 commit comments

Comments
 (0)