Skip to content

Commit 8d098bb

Browse files
khasselKristjanESPERANTO
authored andcommitted
use buildkit for container build
1 parent 13397fe commit 8d098bb

File tree

3 files changed

+33
-25
lines changed

3 files changed

+33
-25
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.husky/*
2+
/.github/*
3+
/docs/data/*
4+
/docs/images/*
5+
/guides/*

.github/workflows/container-build.yaml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,26 @@ permissions:
1212
jobs:
1313
build:
1414
runs-on: ubuntu-latest
15+
timeout-minutes: 60
16+
container:
17+
image: moby/buildkit:latest
18+
options: --privileged
1519
steps:
1620
# checkout code:
1721
- uses: actions/checkout@v4
18-
# create json file with credentials for github container registry:
19-
- uses: docker/login-action@v3
20-
with:
21-
registry: ghcr.io
22-
username: ${{ github.actor }}
23-
password: ${{ secrets.GITHUB_TOKEN }}
24-
# ugly workaround for converting content of $GITHUB_REPOSITORY (= `MagicMirrorOrg/MagicMirror-3rd-Party-Modules`)
25-
# to lowercase which is needed for using as image name
26-
- name: downcase GITHUB_REPOSITORY
22+
name: checkout code
23+
# build image:
24+
- name: build container
2725
run: |
28-
echo "REPO=${GITHUB_REPOSITORY@L}" >> "${GITHUB_ENV}"
29-
# build container image with kaniko:
30-
- uses: int128/kaniko-action@v1
31-
with:
32-
file: container/Dockerfile
33-
push: true
34-
tags: ghcr.io/${{ env.REPO }}:${{ github.ref_name }}
35-
labels: GITREF=${{ github.sha }}
36-
build-args: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
26+
# registry credentials
27+
export DOCKER_CONFIG="$(pwd)/container"
28+
echo "{\"auths\":{\"ghcr.io\":{\"auth\":\"$(echo -n ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} | base64)\"}}}" > $DOCKER_CONFIG/config.json
29+
# ugly workaround for converting content of $GITHUB_REPOSITORY (= `MagicMirrorOrg/MagicMirror-3rd-Party-Modules`)
30+
REPO="$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')"
31+
# build
32+
buildctl-daemonless.sh build \
33+
--progress plain \
34+
--frontend=dockerfile.v0 \
35+
--local context=. \
36+
--local dockerfile=container \
37+
--output type=image,"\"name=ghcr.io/${REPO}:${{ github.ref_name }}\",push=true"

container/Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
FROM nikolaik/python-nodejs:latest as builder
1+
FROM nikolaik/python-nodejs:latest AS builder
22

33
WORKDIR /workspace
44

55
COPY . .
66

77
ARG GITHUB_TOKEN
8-
RUN set -e; \
9-
git config --global --add safe.directory /workspace; \
10-
git log -1; \
11-
export GITHUB_TOKEN="${GITHUB_TOKEN}"; \
12-
npm clean-install; \
13-
node --run all;
8+
RUN <<EOF
9+
set -e
10+
git config --global --add safe.directory /workspace
11+
git log -1
12+
export GITHUB_TOKEN="${GITHUB_TOKEN}"
13+
npm clean-install
14+
node --run all
15+
EOF
1416

1517
FROM nginxinc/nginx-unprivileged:alpine-slim
1618
LABEL maintainer="MagicMirrorOrg"

0 commit comments

Comments
 (0)