Skip to content

Commit 18ac55b

Browse files
ian-floresCopilot
andauthored
Add Dockerfile and CI for container image builds (#15)
* Add Dockerfile and CI for container image builds * Fix SHA tag format in Docker workflow The prefix={{branch}} template resolves empty on PRs, producing an invalid tag like ":-949cd9f". Use the default sha prefix instead. * Include README.md in Docker build context Hatchling validates readme = "README.md" from pyproject.toml during build. The *.md exclusion in .dockerignore was removing it. * Update .dockerignore Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Dockerfile Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Dockerfile Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 92d259d commit 18ac55b

File tree

3 files changed

+103
-0
lines changed

3 files changed

+103
-0
lines changed

.dockerignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.git
2+
.github
3+
.vscode
4+
*.md
5+
!README.md
6+
plans/
7+
selftests/
8+
examples/
9+
.gitignore
10+
.gitattributes
11+
vip.toml

.github/workflows/docker.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build and Push Container Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- main
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: posit-dev/vip
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Log in to GitHub Container Registry
32+
if: github.event_name != 'pull_request'
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ${{ env.REGISTRY }}
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Extract metadata
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44+
tags: |
45+
type=raw,value=latest,enable={{is_default_branch}}
46+
type=semver,pattern={{version}}
47+
type=semver,pattern={{major}}.{{minor}}
48+
type=semver,pattern={{major}}
49+
type=sha
50+
51+
- name: Build and push
52+
uses: docker/build-push-action@v6
53+
with:
54+
context: .
55+
push: ${{ github.event_name != 'pull_request' }}
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# VIP - Verified Installation of Posit
2+
# Container image for running VIP tests as Kubernetes Jobs
3+
FROM mcr.microsoft.com/playwright/python:v1.52.0-noble
4+
5+
# Install uv for fast Python package management
6+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/
7+
8+
WORKDIR /app
9+
10+
# Copy dependency files first for layer caching
11+
COPY pyproject.toml uv.lock ./
12+
13+
# Install dependencies (without the project itself yet)
14+
RUN uv sync --frozen --no-install-project
15+
16+
# Copy the full project
17+
COPY . .
18+
19+
# Install the project itself
20+
RUN uv sync --frozen
21+
22+
# Install playwright browsers (chromium is already in the base image, but ensure deps)
23+
RUN uv run playwright install --with-deps chromium
24+
25+
# Run as the existing non-root user from the base image (ubuntu, UID 1000)
26+
RUN chown -R ubuntu:ubuntu /app
27+
USER ubuntu
28+
# Default entrypoint runs pytest
29+
# Config file should be mounted at /app/vip.toml
30+
ENTRYPOINT ["uv", "run", "pytest"]
31+
32+
# Default args: run all tests with short tracebacks and verbose output
33+
CMD ["--tb=short", "-v"]

0 commit comments

Comments
 (0)