diff --git a/.github/workflows/build-and-push-container-image.yml b/.github/workflows/build-and-push-container-image.yml new file mode 100644 index 0000000..8b4683e --- /dev/null +++ b/.github/workflows/build-and-push-container-image.yml @@ -0,0 +1,58 @@ +name: build and push container image + +on: + pull_request: + push: + branches: [main] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + filter: tree:0 + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Install packages + run: sudo apt-get install -y make libarchive-tools unzip wget + + - name: build + run: make + + - name: set version + run: echo "VERSION=$(lein pprint --no-pretty -- :version)" >> $GITHUB_ENV + + - name: docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.IMAGE_NAME }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{version}},value=${{ env.VERSION }} + type=sha + + - name: build and push + uses: docker/build-push-action@v5 + with: + context: . + file: docker/Dockerfile + build-args: | + VERSION=${{ env.VERSION }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/clojure.yml b/.github/workflows/clojure.yml index 62f98e3..9f32579 100644 --- a/.github/workflows/clojure.yml +++ b/.github/workflows/clojure.yml @@ -9,7 +9,11 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + filter: tree:0 - name: Install dependencies run: lein deps - name: Run tests diff --git a/Makefile b/Makefile index 252af85..ee46e0b 100644 --- a/Makefile +++ b/Makefile @@ -96,4 +96,4 @@ target/llar-$(LLAR_VERSION)-standalone.jar: $(CLOJURE_FILES) uberjar: target/llar-$(LLAR_VERSION)-standalone.jar docker-image: uberjar docker/Dockerfile - docker build --network host -t ghcr.io/irq0/llar:latest -f docker/Dockerfile . + docker build --build-arg VERSION=$(LLAR_VERSION) --network host -t ghcr.io/irq0/llar:snapshot -f docker/Dockerfile . diff --git a/docker/Dockerfile b/docker/Dockerfile index 9cd7474..9dfde23 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,8 +1,14 @@ FROM ubuntu:jammy +ARG VERSION + LABEL org.opencontainers.image.source=https://github.com/irq0/llar -LABEL org.opencontainers.image.description="LLAR - Live Long and Read: Container Image" -LABEL org.opencontainers.image.licenses=GPL +LABEL org.opencontainers.image.url=https://llar.dev +LABEL org.opencontainers.image.title="llar" +LABEL org.opencontainers.image.description="Live Long and Read: Container Image" +LABEL org.opencontainers.image.authors="ml+llar@irq0.org" +LABEL org.opencontainers.image.licenses=AGPLv3 +LABEL org.opencontainers.image.version=$VERSION RUN ln -fs /usr/share/zoneinfo/Europe/Berlin /etc/localtime @@ -36,7 +42,7 @@ ENV LANG en_US.UTF-8 ENV LANGUAGE en_US.UTF-8 RUN mkdir -p /opt/llar -COPY target/llar-0.1.0-SNAPSHOT-standalone.jar /opt/llar/standalone.jar +COPY target/llar-$VERSION-standalone.jar /opt/llar/standalone.jar ENV LLAR_CONFIG /var/lib/llar/config.edn ENV JDK_JAVA_OPTIONS "-XshowSettings:system -XX:+UseContainerSupport -XX:MaxRAMPercentage=60 -Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2-factory -Dtika.config=tika-config.xml"