Skip to content

Commit 8e4a25d

Browse files
authored
add container build (#23)
1 parent 30afc5b commit 8e4a25d

File tree

4 files changed

+134
-0
lines changed

4 files changed

+134
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: "Container Build"
2+
3+
on:
4+
workflow_dispatch: # needed for manually running this workflow
5+
schedule:
6+
- cron: "15 3 1 * *" # monthly
7+
push:
8+
branches:
9+
- "master"
10+
- "develop"
11+
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 10
20+
container:
21+
image: moby/buildkit:latest
22+
options: --privileged
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v6
26+
- name: Build container
27+
run: |
28+
REPO="$(echo "$GITHUB_REPOSITORY" | tr "[:upper:]" "[:lower:]")"
29+
PARAMS="--output type=image,\"name=ghcr.io/${REPO}:${{ github.ref_name }}\",push=true"
30+
# registry credentials
31+
export DOCKER_CONFIG="$(pwd)/container"
32+
echo "{\"auths\":{\"ghcr.io\":{\"auth\":\"$(echo -n ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} | base64 -w 0)\"}}}" > $DOCKER_CONFIG/config.json
33+
# build
34+
buildctl-daemonless.sh build \
35+
--progress plain \
36+
--frontend=dockerfile.v0 \
37+
--local context=. \
38+
--local dockerfile=container \
39+
$PARAMS

container/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM nginxinc/nginx-unprivileged:alpine-slim
2+
LABEL maintainer="MagicMirrorOrg"
3+
4+
USER root
5+
6+
RUN ln -s /dev/stdout /var/log/nginx/nodebb.access.log
7+
8+
USER nginx
9+
10+
COPY container/default.conf /etc/nginx/conf.d/
11+
COPY container/nginx.conf /etc/nginx/
12+
13+
COPY public /usr/share/nginx/website/
14+
15+
EXPOSE 8080 8082
16+
17+
HEALTHCHECK --timeout=10s --start-period=60s CMD wget -qO /dev/null http://0.0.0.0:8080

container/default.conf

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
25+
server {
26+
listen 8082;
27+
server_name localhost;
28+
29+
access_log /var/log/nginx/nodebb.access.log main;
30+
31+
gzip on;
32+
gzip_min_length 1000;
33+
gzip_proxied off;
34+
gzip_types text/plain application/xml text/javascript application/javascript application/x-javascript text/css application/json;
35+
36+
location ~ ^/assets/(.*) {
37+
root /usr/share/nginx/nodebb;
38+
try_files /public/$1 =404;
39+
}
40+
}

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+
}

0 commit comments

Comments
 (0)