From cfe0d7568ccb7c135379367e1ccaa952f728d493 Mon Sep 17 00:00:00 2001 From: Victoria Nadasdi Date: Tue, 16 Apr 2024 17:59:57 +0200 Subject: [PATCH] image builder --- .github/workflows/build-and-publish.yaml | 46 ++++++++++++++++++++++++ Dockerfile | 17 +++++++++ Makefile | 4 +++ 3 files changed, 67 insertions(+) create mode 100644 .github/workflows/build-and-publish.yaml create mode 100644 Dockerfile create mode 100644 Makefile diff --git a/.github/workflows/build-and-publish.yaml b/.github/workflows/build-and-publish.yaml new file mode 100644 index 0000000..d2594ad --- /dev/null +++ b/.github/workflows/build-and-publish.yaml @@ -0,0 +1,46 @@ +name: Publish Docker image + +on: + workflow_dispatch: + inputs: + phanpy_version: + description: Target Phanpy version + required: true + type: string + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build_and_push_to_registry: + name: "Build and Push to Registry: phanpy ${{ inputs.phanpy_version }}" + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: + type=semver,pattern={{version}},value=${{ inputs.phanpy_version }} + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + build-args: | + VERSION=${{ inputs.phanpy_version }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..452535d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +from alpine:3.19 as builder + +ARG VERSION + +run apk add --update curl +run curl -sLO "https://github.com/cheeaun/phanpy/releases/download/${VERSION}/phanpy-dist.tar.gz" \ + && mkdir /phanpy \ + && tar zxf phanpy-dist.tar.gz -C /phanpy + +from nginx:1.25.4-alpine + +label maintainer="Victoria Nadasdi " +label org.opencontainers.image.source=https://github.com/yitsushi/phanpy-docker +label org.opencontainers.image.description="Unofficial Docker Image for Phanpy" +label org.opencontainers.image.licenses=MIT + +copy --from=builder /phanpy /usr/share/nginx/html diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..177512e --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +VERSION := unknown + +build: + docker build --build-arg VERSION=$(VERSION) -t phanpy-docker:$(VERSION) .