Skip to content

Commit

Permalink
Automatic Docker builds (#73)
Browse files Browse the repository at this point in the history
* add docker files

* add action to build docker file and publish it as a package

* point to published docker image in example docker-compose.yml
  • Loading branch information
Eddykasp authored May 2, 2024
1 parent e63def6 commit b0f047d
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: build-and-publish-docker

# 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: ["master"]

pull_request:
branches: ["master"]

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

jobs:

build:
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

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
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@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# 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:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Clean container registry
uses: actions/delete-package-versions@v4
with:
package-name: "elk-live"
package-type: "container"
min-versions-to-keep: 3
token: ${{ secrets.GITHUB_TOKEN }}
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM alpine:latest

LABEL authors="Arnd Plumhoff <[email protected]>, Sascha Hoppe <[email protected]>"

ARG ELKLIVE_UID=1002

RUN apk add --update --no-cache yarn git gradle curl

RUN adduser elklive -h /elklive -D -u ${ELKLIVE_UID}

USER elklive

RUN git clone https://github.com/kieler/elk-live --depth=1 /elklive

WORKDIR "/elklive/client"
RUN yarn install && yarn run build

WORKDIR "/elklive/server"
RUN ./gradlew build

EXPOSE 8080

CMD ["./gradlew", "jettyRun", "--args='-m=SIGTERM'"]
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "2"

services:
elkweb:
container_name: elkweb
image: ghcr.io/kieler/elk-live:master
ports:
- 8082:8080
restart: unless-stopped
cpus: 0.5
mem_limit: 536870912
healthcheck:
test: curl --fail http://localhost:8080 || exit 1
interval: 60s
start_period: 2m

0 comments on commit b0f047d

Please sign in to comment.