Add Docker image for Emscripten port (#466)

* Add Docker web port image

* Comment out master

* Optimize

* Slim down image

* Revert "Comment out master"

This reverts commit 115c9770e8e01c1a4bc2455eca944d4f7f4c1cf4.

* Allow running from ISO
This commit is contained in:
Christian Semmler 2025-07-01 15:47:05 -07:00 committed by GitHub
parent 1f1787b5ac
commit de31c12a9e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 119 additions and 0 deletions

55
.github/workflows/docker.yml vendored Normal file
View File

@ -0,0 +1,55 @@
name: Docker
on:
push:
branches: ['master']
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-emscripten
jobs:
publish-emscripten:
name: Publish web port
env:
IMAGE_NAME: ${{ github.repository }}-emscripten
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
file: docker/emscripten/Dockerfile
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

View File

@ -0,0 +1,37 @@
FROM emscripten/emsdk:latest AS builder
ARG CMAKE_VERSION=3.29.3
WORKDIR /src
USER root
RUN apt-get update && apt-get install -y git wget && rm -rf /var/lib/apt/lists/*
RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.sh -O /tmp/cmake.sh && \
chmod +x /tmp/cmake.sh && \
/tmp/cmake.sh --skip-license --prefix=/usr/local && \
rm /tmp/cmake.sh
RUN chown -R emscripten:emscripten /src
USER emscripten
COPY ISLE/emscripten/libwasmfs_fetch.js.patch /tmp/
RUN cd /emsdk/upstream/emscripten && \
git apply --check /tmp/libwasmfs_fetch.js.patch && \
git apply /tmp/libwasmfs_fetch.js.patch
COPY --chown=emscripten:emscripten . .
RUN emcmake cmake -S . -B build -DISLE_BUILD_CONFIG=OFF -DISLE_DEBUG=OFF -DCMAKE_BUILD_TYPE=Release -DISLE_EMSCRIPTEN_HOST=/assets && \
emmake cmake --build build -j 32
RUN echo "Fetching isle.pizza frontend..."; \
git clone --depth 1 https://github.com/isledecomp/isle.pizza /tmp/isle.pizza;
FROM nginx:alpine
COPY docker/emscripten/nginx.conf /etc/nginx/nginx.conf
COPY --from=builder /tmp/isle.pizza /usr/share/nginx/html
COPY --from=builder /src/build/isle.* /usr/share/nginx/html
EXPOSE 6931

View File

@ -0,0 +1,27 @@
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
server {
listen 6931;
server_name localhost;
add_header 'Cross-Origin-Embedder-Policy' 'require-corp';
add_header 'Cross-Origin-Opener-Policy' 'same-origin';
add_header 'Cross-Origin-Resource-Policy' 'cross-origin';
location / {
root /usr/share/nginx/html;
index index.html isle.html;
try_files $uri $uri/ =404;
}
location ~* ^/assets/(.*)$ {
alias /assets/;
try_files /$1 /DATA/disk/$1 =404;
}
}
}