Add Docker web port image

This commit is contained in:
Christian Semmler 2025-07-01 12:36:37 -07:00
parent 12d4d6a89a
commit 386c3c1e62
No known key found for this signature in database
GPG Key ID: 086DAA1360BEEE5C
4 changed files with 131 additions and 0 deletions

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

@ -0,0 +1,52 @@
name: Publish web port Docker image
on:
push:
branches: ['master']
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
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,40 @@
FROM emscripten/emsdk:latest
ARG USE_ISLE_PIZZA=false
ARG CMAKE_VERSION=3.29.3
WORKDIR /src
USER root
RUN apt-get update && apt-get install -y git wget nginx && 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
COPY docker/emscripten/nginx.conf /etc/nginx/nginx.conf
COPY docker/emscripten/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.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 && \
cp -r /tmp/isle.pizza/* /src/build/ && \
rm -rf /tmp/isle.pizza;
EXPOSE 6931
USER root
ENTRYPOINT ["entrypoint.sh"]

View File

@ -0,0 +1,6 @@
#!/bin/sh
set -e
echo "Starting nginx web server on port 6931..."
exec nginx -c /etc/nginx/nginx.conf

View File

@ -0,0 +1,33 @@
daemon off;
events {
worker_connections 1024;
}
http {
types {
application/wasm wasm;
}
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 /src/build;
index index.html isle.html;
try_files $uri $uri/ =404;
}
location /assets/ {
alias /assets/;
autoindex off;
}
}
}