Skip to content

Commit 9b979f4

Browse files
authored
ci: add container build (#66)
1 parent fff1a33 commit 9b979f4

5 files changed

Lines changed: 106 additions & 1 deletion

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: "Container Build"
2+
3+
on:
4+
workflow_dispatch: # needed for manually running this workflow
5+
schedule:
6+
- cron: "30 5 * * *" # sadly there is no TZ support here
7+
8+
permissions:
9+
contents: read
10+
packages: write
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
# checkout code:
17+
- uses: actions/checkout@v3
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
27+
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 }}

container/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM nikolaik/python-nodejs:latest as builder
2+
3+
WORKDIR /workspace
4+
5+
COPY . .
6+
7+
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+
npm run all;
14+
15+
FROM nginxinc/nginx-unprivileged:alpine-slim
16+
LABEL maintainer="MagicMirrorOrg"
17+
18+
COPY container/default.conf /etc/nginx/conf.d/
19+
COPY container/nginx.conf /etc/nginx/
20+
21+
COPY --from=builder /workspace/docs /usr/share/nginx/docs/
22+
23+
EXPOSE 8080

container/default.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
server {
2+
listen 8080;
3+
server_name localhost;
4+
5+
access_log /var/log/nginx/access.log main;
6+
7+
location / {
8+
root /usr/share/nginx/docs;
9+
index index.html index.htm;
10+
}
11+
12+
error_page 404 /404.html;
13+
14+
}

container/nginx.conf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
worker_processes auto;
2+
3+
error_log /var/log/nginx/error.log warn;
4+
pid /tmp/nginx.pid;
5+
6+
events {
7+
worker_connections 1024;
8+
}
9+
10+
http {
11+
client_body_temp_path /tmp/client_temp;
12+
proxy_temp_path /tmp/proxy_temp_path;
13+
fastcgi_temp_path /tmp/fastcgi_temp;
14+
uwsgi_temp_path /tmp/uwsgi_temp;
15+
scgi_temp_path /tmp/scgi_temp;
16+
17+
include /etc/nginx/mime.types;
18+
default_type application/octet-stream;
19+
20+
log_format main '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
21+
'$status $body_bytes_sent "$http_referer" '
22+
'"$http_user_agent" $remote_addr';
23+
24+
access_log /var/log/nginx/access.log main;
25+
26+
sendfile on;
27+
28+
keepalive_timeout 65;
29+
30+
include /etc/nginx/conf.d/*.conf;
31+
}

cspell.config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"modules/",
3131
"modules_temp/",
3232
"docs/**",
33-
"eslint-config-DEBUG.json"
33+
"eslint-config-DEBUG.json",
34+
"container/"
3435
],
3536
"dictionaries": ["node"]
3637
}

0 commit comments

Comments
 (0)