Skip to content

Commit

Permalink
Merge pull request #5 from unoconv/feature/automation_of_image_etc
Browse files Browse the repository at this point in the history
feat: Publish Docker image to GitHub Container Repo (ghcr.io)
  • Loading branch information
jimisola authored Dec 21, 2022
2 parents 3b1db01 + d1106b7 commit e42d52e
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 3 deletions.
100 changes: 100 additions & 0 deletions .github/workflows/docker-publish..yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Publish Docker Image to GHCR

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
branches:
- main
# Publish semver tags as releases.
tags:
- "v*.*.*"
pull_request:
branches:
- main

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
build-n-publish:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Login to image registry ${{ env.REGISTRY }}
if: github.ref_type == 'tag'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=auto
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.ref_type == 'tag' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.ref_type == 'tag'
uses: sigstore/cosign-installer@main
with:
cosign-release: 'v1.13.1'

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: github.ref_type == 'tag'
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,16 @@ RUN rm $(which wget) && \
rm -rf /var/cache/apk/* /tmp/*

# renovate: datasource=repology depName=temurin-17-jdk versioning=loose
ARG VERSION_ADOPTIUM_TEMURIN_JDK="17.0.4.1_p1-r0"
ARG VERSION_ADOPTIUM_TEMURIN="17.0.5_p8-r0"

# install Eclipse Temurin JDK
RUN curl https://packages.adoptium.net/artifactory/api/security/keypair/public/repositories/apk -o /etc/apk/keys/adoptium.rsa.pub && \
echo 'https://packages.adoptium.net/artifactory/apk/alpine/main' >> /etc/apk/repositories && \
apk update && apk add temurin-17-jdk=${VERSION_ADOPTIUM_TEMURIN_JDK}
apk update && apk add temurin-17-jdk=${VERSION_ADOPTIUM_TEMURIN}

# https://github.com/unoconv/unoserver/
RUN pip install -U unoserver


# FIX: pyuno path not set (https://gitlab.alpinelinux.org/alpine/aports/-/issues/13359)
# define path
ARG PATH_LO=/usr/lib/libreoffice/program
Expand Down

0 comments on commit e42d52e

Please sign in to comment.