Skip to content

Commit b0f047d

Browse files
authored
Automatic Docker builds (#73)
* 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
1 parent e63def6 commit b0f047d

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed

.github/workflows/publish-docker.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: build-and-publish-docker
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
on:
9+
push:
10+
branches: ["master"]
11+
12+
pull_request:
13+
branches: ["master"]
14+
15+
env:
16+
# Use docker.io for Docker Hub if empty
17+
REGISTRY: ghcr.io
18+
# github.repository as <account>/<repo>
19+
IMAGE_NAME: ${{ github.repository }}
20+
21+
jobs:
22+
23+
build:
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
packages: write
28+
# This is used to complete the identity challenge
29+
# with sigstore/fulcio when running outside of PRs.
30+
id-token: write
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v3
35+
36+
# Workaround: https://github.com/docker/build-push-action/issues/461
37+
- name: Setup Docker buildx
38+
uses: docker/setup-buildx-action@v3
39+
40+
# Login against a Docker registry except on PR
41+
# https://github.com/docker/login-action
42+
- name: Log into registry ${{ env.REGISTRY }}
43+
if: github.event_name != 'pull_request'
44+
uses: docker/login-action@v3
45+
with:
46+
registry: ${{ env.REGISTRY }}
47+
username: ${{ github.actor }}
48+
password: ${{ secrets.GITHUB_TOKEN }}
49+
50+
# Extract metadata (tags, labels) for Docker
51+
# https://github.com/docker/metadata-action
52+
- name: Extract Docker metadata
53+
id: meta
54+
uses: docker/metadata-action@v5
55+
with:
56+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
57+
58+
# Build and push Docker image with Buildx (don't push on PR)
59+
# https://github.com/docker/build-push-action
60+
- name: Build and push Docker image
61+
id: build-and-push
62+
uses: docker/build-push-action@v3
63+
with:
64+
push: ${{ github.event_name != 'pull_request' }}
65+
tags: ${{ steps.meta.outputs.tags }}
66+
labels: ${{ steps.meta.outputs.labels }}
67+
cache-from: type=gha
68+
cache-to: type=gha,mode=max
69+
70+
- name: Clean container registry
71+
uses: actions/delete-package-versions@v4
72+
with:
73+
package-name: "elk-live"
74+
package-type: "container"
75+
min-versions-to-keep: 3
76+
token: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM alpine:latest
2+
3+
LABEL authors="Arnd Plumhoff <[email protected]>, Sascha Hoppe <[email protected]>"
4+
5+
ARG ELKLIVE_UID=1002
6+
7+
RUN apk add --update --no-cache yarn git gradle curl
8+
9+
RUN adduser elklive -h /elklive -D -u ${ELKLIVE_UID}
10+
11+
USER elklive
12+
13+
RUN git clone https://github.com/kieler/elk-live --depth=1 /elklive
14+
15+
WORKDIR "/elklive/client"
16+
RUN yarn install && yarn run build
17+
18+
WORKDIR "/elklive/server"
19+
RUN ./gradlew build
20+
21+
EXPOSE 8080
22+
23+
CMD ["./gradlew", "jettyRun", "--args='-m=SIGTERM'"]

docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: "2"
2+
3+
services:
4+
elkweb:
5+
container_name: elkweb
6+
image: ghcr.io/kieler/elk-live:master
7+
ports:
8+
- 8082:8080
9+
restart: unless-stopped
10+
cpus: 0.5
11+
mem_limit: 536870912
12+
healthcheck:
13+
test: curl --fail http://localhost:8080 || exit 1
14+
interval: 60s
15+
start_period: 2m

0 commit comments

Comments
 (0)