Skip to content

Commit

Permalink
[dev] gh: build and push container image
Browse files Browse the repository at this point in the history
  • Loading branch information
irq0 committed Feb 15, 2024
1 parent f69e62c commit 3b35f8e
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 5 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/build-and-push-container-image.yml
Original file line number Diff line number Diff line change
@@ -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 }}
6 changes: 5 additions & 1 deletion .github/workflows/clojure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
12 changes: 9 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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="[email protected]"
LABEL org.opencontainers.image.licenses=AGPLv3
LABEL org.opencontainers.image.version=$VERSION

RUN ln -fs /usr/share/zoneinfo/Europe/Berlin /etc/localtime

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 3b35f8e

Please sign in to comment.