Skip to content

Commit 39c7d36

Browse files
committed
fixed github actions
1 parent baa0686 commit 39c7d36

3 files changed

Lines changed: 32 additions & 68 deletions

File tree

.github/workflows/docker-publish.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

.github/workflows/docker.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,53 @@ on:
44
push:
55
branches: [ master ]
66
release:
7-
types: [published]
7+
types: [ published ]
8+
workflow_dispatch: {}
89

910
jobs:
1011
build-and-push:
1112
runs-on: ubuntu-latest
1213
permissions:
1314
contents: read
1415
packages: write
16+
env:
17+
IMAGE_NAME: unet-lungs-segmentation
18+
1519
steps:
1620
- name: Checkout
1721
uses: actions/checkout@v4
1822

19-
- name: Extract version
23+
- name: Compute owner + version
2024
id: vars
25+
shell: bash
2126
run: |
22-
VERSION=$(grep -Po '^(version\s*=\s*).*' setup.cfg | sed -E 's/version\s*=\s*//')
23-
echo "version=${VERSION}" >> $GITHUB_OUTPUT
27+
OWNER_LC="${GITHUB_REPOSITORY_OWNER,,}"
28+
VERSION="$(grep -Po '^[[:space:]]*version[[:space:]]*=[[:space:]]*\K.*' setup.cfg || true)"
29+
if [ -z "$VERSION" ]; then VERSION="${GITHUB_SHA::7}"; fi
30+
echo "owner=${OWNER_LC}" >> "$GITHUB_OUTPUT"
31+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
2432
2533
- name: Set up QEMU
2634
uses: docker/setup-qemu-action@v3
2735

2836
- name: Set up Docker Buildx
2937
uses: docker/setup-buildx-action@v3
3038

31-
- name: Login to GitHub Container Registry
39+
- name: Log in to GHCR
3240
uses: docker/login-action@v3
3341
with:
3442
registry: ghcr.io
3543
username: ${{ github.actor }}
3644
password: ${{ secrets.GITHUB_TOKEN }}
3745

38-
- name: Build and push image (GHCR)
46+
- name: Build and push
3947
uses: docker/build-push-action@v5
4048
with:
4149
context: .
4250
push: true
4351
tags: |
44-
ghcr.io/${{ github.repository_owner }}/unet-lungs-segmentation:latest
45-
ghcr.io/${{ github.repository_owner }}/unet-lungs-segmentation:${{ steps.vars.outputs.version }}
46-
ghcr.io/${{ github.repository_owner }}/unet-lungs-segmentation:${{ github.sha }}
52+
ghcr.io/${{ steps.vars.outputs.owner }}/${{ env.IMAGE_NAME }}:latest
53+
ghcr.io/${{ steps.vars.outputs.owner }}/${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.version }}
54+
ghcr.io/${{ steps.vars.outputs.owner }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
55+
labels: |
56+
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}

Dockerfile

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1+
# syntax=docker/dockerfile:1
12
FROM python:3.10-slim
23

4+
ENV PYTHONUNBUFFERED=1 \
5+
PIP_NO_CACHE_DIR=1
6+
37
WORKDIR /app
48

5-
# Install minimal system dependencies (git sometimes required by huggingface_hub)
6-
RUN apt-get update && apt-get install -y --no-install-recommends git \
7-
&& rm -rf /var/lib/apt/lists/*
9+
# Minimal OS deps
10+
RUN apt-get update \
11+
&& apt-get install -y --no-install-recommends git \
12+
&& rm -rf /var/lib/apt/lists/*
813

9-
# Copy only project metadata first (better build cache)
14+
# Copy project metadata first (better build cache)
1015
COPY pyproject.toml setup.cfg README.md LICENSE ./
1116

12-
# Install the project (this pulls dependencies declared in setup.cfg)
13-
RUN pip install --no-cache-dir --upgrade pip && \
14-
pip install --no-cache-dir .
15-
16-
# Copy source (in case editable non-packaged assets are needed at runtime)
17+
# Copy source BEFORE installing so packaging sees the code
1718
COPY src ./src
1819

19-
ENV PYTHONUNBUFFERED=1
20+
# Install the project and its deps
21+
RUN pip install --upgrade pip && pip install .
2022

21-
# Default entrypoint: single-image prediction CLI. Pass -i argument at runtime.
23+
# Default entrypoint: single-image prediction CLI
2224
ENTRYPOINT ["uls_predict_image"]
2325
CMD ["--help"]

0 commit comments

Comments
 (0)