Skip to content

Commit eeaeda4

Browse files
authored
Merge pull request #20 from AstraBert/feat/docker-image
feat: docker image
2 parents 0896427 + 191f3be commit eeaeda4

3 files changed

Lines changed: 85 additions & 5 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build and Publish Docker Image
2+
3+
on:
4+
push:
5+
tags: ["llamagram@v*.*.*"]
6+
branches: [main]
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: astrabert/llamagram
11+
12+
jobs:
13+
build-and-publish-docker-image:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
id-token: write
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Install cosign
25+
if: github.event_name != 'pull_request'
26+
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
27+
with:
28+
cosign-release: "v2.2.4"
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
32+
33+
- name: Log into registry ${{ env.REGISTRY }}
34+
if: github.event_name != 'pull_request'
35+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
36+
with:
37+
registry: ${{ env.REGISTRY }}
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Extract Docker metadata
42+
id: meta
43+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
44+
with:
45+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
46+
47+
- name: Build and push Docker image
48+
id: build-and-push
49+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
50+
with:
51+
context: packages/llamagram
52+
push: ${{ github.event_name != 'pull_request' }}
53+
tags: ${{ steps.meta.outputs.tags }}
54+
labels: ${{ steps.meta.outputs.labels }}
55+
cache-from: type=gha
56+
cache-to: type=gha,mode=max
57+
58+
- name: Sign the published Docker image
59+
if: ${{ github.event_name != 'pull_request' }}
60+
env:
61+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
62+
TAGS: ${{ steps.meta.outputs.tags }}
63+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
64+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

packages/llamagram/Dockerfile

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1-
FROM python:3.12-slim-trixie
2-
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
1+
FROM python:3.12-slim
2+
3+
# Install build dependencies
4+
RUN apt-get update && apt-get install -y \
5+
build-essential \
6+
&& rm -rf /var/lib/apt/lists/*
7+
8+
# Create user
9+
RUN useradd -m -u 1000 user
10+
11+
# Copy uv to system location
12+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/
13+
14+
# Switch to user
15+
USER user
16+
ENV PATH=/home/user/.local/bin:$PATH
17+
WORKDIR /home/user/workspace
18+
19+
# Install llamagram
20+
RUN uv tool install llamagram --prerelease=allow
321

4-
# insall and run LlamaGram
5-
RUN uv tool install llamagram
622
CMD [ "llamagram", "run" ]

packages/llamagram/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Install the bot natively:
1717

1818
```bash
1919
# uv (recommended)
20-
uv tool install llamagram
20+
uv tool install llamagram --prerelease=allow
2121
# pip
2222
pip install llamagram
2323
```

0 commit comments

Comments
 (0)