Skip to content

Commit 98dacf8

Browse files
authored
add container build (#352)
* ignore dead localhost links * add container build
1 parent 7c4ec7b commit 98dacf8

File tree

6 files changed

+127
-1
lines changed

6 files changed

+127
-1
lines changed
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+
push:
5+
branches:
6+
- "master"
7+
- "develop"
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 10
17+
container:
18+
image: moby/buildkit:latest
19+
options: --privileged
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v6
23+
- name: Build container
24+
run: |
25+
REPO="$(echo "$GITHUB_REPOSITORY" | tr "[:upper:]" "[:lower:]")"
26+
PARAMS="--output type=image,\"name=ghcr.io/${REPO}:${{ github.ref_name }}\",push=true"
27+
# registry credentials
28+
export DOCKER_CONFIG="$(pwd)/container"
29+
echo "{\"auths\":{\"ghcr.io\":{\"auth\":\"$(echo -n ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} | base64 -w 0)\"}}}" > $DOCKER_CONFIG/config.json
30+
# build
31+
buildctl-daemonless.sh build \
32+
--progress plain \
33+
--frontend=dockerfile.v0 \
34+
--local context=. \
35+
--local dockerfile=container \
36+
$PARAMS

.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default defineConfig({
55
title: "MagicMirror² Docs",
66
description: "The open source modular smart mirror platform.",
77
lang: "en",
8+
ignoreDeadLinks: "localhostLinks",
89
head: [
910
[
1011
"script",

container/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM node:alpine AS builder
2+
3+
WORKDIR /workspace
4+
5+
COPY . .
6+
7+
RUN <<EOF
8+
set -e
9+
apk add git
10+
git log -1
11+
npm install
12+
node --run docs:build
13+
EOF
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/.vitepress/dist /usr/share/nginx/website/
22+
23+
EXPOSE 8080
24+
25+
HEALTHCHECK --timeout=10s --start-period=60s CMD wget -qO /dev/null http://0.0.0.0:8080

container/default.conf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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/website;
9+
index index.html index.htm;
10+
# Do not cache HTML to allow quick refresh of UI changes
11+
add_header Cache-Control "no-cache, no-store, must-revalidate";
12+
add_header Pragma "no-cache";
13+
add_header Expires "0";
14+
}
15+
16+
# Cache-bust static assets aggressively; paths are stable under website/
17+
location ~* \.(?:css|js|svg|woff2?|ttf|eot|ico|png|jpg|jpeg|gif|webp)$ {
18+
root /usr/share/nginx/website;
19+
access_log off;
20+
expires 30d;
21+
add_header Cache-Control "public, max-age=2592000, immutable";
22+
}
23+
24+
error_page 404 /404.html;
25+
26+
}

container/nginx.conf

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
gzip on;
21+
gzip_comp_level 6;
22+
gzip_min_length 1024;
23+
gzip_proxied any;
24+
gzip_vary on;
25+
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
26+
27+
log_format main '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
28+
'$status $body_bytes_sent "$http_referer" '
29+
'"$http_user_agent" $remote_addr';
30+
31+
access_log /var/log/nginx/access.log main;
32+
33+
sendfile on;
34+
35+
keepalive_timeout 65;
36+
37+
include /etc/nginx/conf.d/*.conf;
38+
}

cspell.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@
8080
"yearmatchgroup",
8181
"yourprovider"
8282
],
83-
"ignorePaths": ["node_modules/**"],
83+
"ignorePaths": ["container/**", "node_modules/**"],
8484
"dictionaries": ["node"]
8585
}

0 commit comments

Comments
 (0)