Skip to content

Commit

Permalink
ci: use shared named-data/actions workflow to publish Docker image
Browse files Browse the repository at this point in the history
Change-Id: I732952ba6640e1e8d34d5de006c712a5565b1c08
  • Loading branch information
Pesa committed Apr 7, 2024
1 parent c0993b0 commit 4b3aa4f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 66 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ trim_trailing_whitespace = true
[*.{yaml,yml}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
79 changes: 14 additions & 65 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Docker images
name: Docker
on:
push:
branches:
Expand All @@ -14,69 +14,18 @@ on:

permissions:
packages: write

env:
REGISTRY: ghcr.io
id-token: write

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate metadata for ndn-cxx-build image
id: build-meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/ndn-cxx-build
tags: |
type=ref,event=branch
type=raw,value=latest,enable={{is_default_branch}}
type=sha
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: index,manifest

- name: Build and push ndn-cxx-build image
uses: docker/build-push-action@v5
with:
build-args: BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
pull: true
push: true
target: build
tags: ${{ steps.build-meta.outputs.tags }}
labels: ${{ steps.build-meta.outputs.labels }}
annotations: ${{ steps.build-meta.outputs.annotations }}
cache-from: type=gha
cache-to: type=gha

- name: Generate metadata for ndn-cxx-runtime image
id: runtime-meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/ndn-cxx-runtime
tags: |
type=ref,event=branch
type=raw,value=latest,enable={{is_default_branch}}
type=sha
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: index,manifest

- name: Build and push ndn-cxx-runtime image
uses: docker/build-push-action@v5
with:
build-args: BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
pull: true
push: true
tags: ${{ steps.runtime-meta.outputs.tags }}
labels: ${{ steps.runtime-meta.outputs.labels }}
annotations: ${{ steps.runtime-meta.outputs.annotations }}
cache-from: type=gha
cache-to: type=gha
ndn-cxx-build:
uses: named-data/actions/.github/workflows/docker-image.yml@v1
with:
name: ndn-cxx-build
target: build
ndn-cxx-runtime:
needs: ndn-cxx-build
uses: named-data/actions/.github/workflows/docker-image.yml@v1
with:
name: ndn-cxx-runtime
target: runtime
contexts: build=docker-image://${{ needs.ndn-cxx-build.outputs.image }}
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# syntax=docker/dockerfile:1

FROM ubuntu:23.10 AS build
ARG SOURCE_DATE_EPOCH

RUN apt-get install -Uy --no-install-recommends \
dpkg-dev \
Expand Down Expand Up @@ -41,7 +42,8 @@ dpkg-shlibdeps --ignore-missing-info /usr/lib/libndn-cxx.so.* /usr/bin/ndnsec -O
| sed -n 's|^shlibs:Depends=||p' | sed 's| ([^)]*),\?||g' > ndn-cxx
EOF

FROM ubuntu:23.10 AS run
FROM ubuntu:23.10 AS runtime
ARG SOURCE_DATE_EPOCH

RUN --mount=type=bind,from=build,source=/deps,target=/deps \
apt-get install -Uy --no-install-recommends $(cat /deps/ndn-cxx) \
Expand Down

0 comments on commit 4b3aa4f

Please sign in to comment.