mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-08-03 07:36:20 -04:00
Improve Web port Docker setup (#479)
This commit is contained in:
parent
10b6d28cf8
commit
8f429e85fb
@ -21,7 +21,14 @@ RUN cd /emsdk/upstream/emscripten && \
|
||||
git apply --check /tmp/libwasmfs_fetch.js.patch && \
|
||||
git apply /tmp/libwasmfs_fetch.js.patch
|
||||
|
||||
COPY --chown=emscripten:emscripten . .
|
||||
COPY --chown=emscripten:emscripten 3rdparty/ ./3rdparty/
|
||||
COPY --chown=emscripten:emscripten LEGO1/ ./LEGO1/
|
||||
COPY --chown=emscripten:emscripten ISLE/ ./ISLE/
|
||||
COPY --chown=emscripten:emscripten miniwin/ ./miniwin/
|
||||
COPY --chown=emscripten:emscripten util/ ./util/
|
||||
COPY --chown=emscripten:emscripten CMake/ ./CMake/
|
||||
COPY --chown=emscripten:emscripten packaging/ ./packaging/
|
||||
COPY --chown=emscripten:emscripten CMakeLists.txt .
|
||||
|
||||
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
|
||||
@ -29,9 +36,9 @@ RUN emcmake cmake -S . -B build -DISLE_BUILD_CONFIG=OFF -DISLE_DEBUG=OFF -DCMAKE
|
||||
RUN echo "Fetching isle.pizza frontend..."; \
|
||||
git clone --depth 1 https://github.com/isledecomp/isle.pizza /tmp/isle.pizza;
|
||||
|
||||
FROM nginx:alpine
|
||||
FROM openresty/openresty: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
|
||||
COPY docker/emscripten/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf
|
||||
COPY --from=builder /tmp/isle.pizza /usr/local/openresty/nginx/html
|
||||
COPY --from=builder /src/build/isle.* /usr/local/openresty/nginx/html
|
||||
EXPOSE 6931
|
||||
|
@ -3,7 +3,43 @@ events {
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
init_by_lua_block {
|
||||
function find_entry_in_dir(parent_dir, name_to_find)
|
||||
local safe_parent_dir = string.gsub(parent_dir, "'", "'\\''")
|
||||
local lower_name_to_find = string.lower(name_to_find)
|
||||
local pipe = io.popen("ls -A '" .. safe_parent_dir .. "' 2>/dev/null")
|
||||
if not pipe then return nil end
|
||||
|
||||
for entry in pipe:lines() do
|
||||
if string.lower(entry) == lower_name_to_find then
|
||||
pipe:close()
|
||||
return entry
|
||||
end
|
||||
end
|
||||
pipe:close()
|
||||
return nil
|
||||
end
|
||||
|
||||
function find_recursive_path(path_to_check)
|
||||
local current_resolved_path = "/"
|
||||
|
||||
for component in string.gmatch(path_to_check, "([^/]+)") do
|
||||
local found_entry = find_entry_in_dir(current_resolved_path, component)
|
||||
if not found_entry then
|
||||
return nil
|
||||
end
|
||||
|
||||
if current_resolved_path == "/" then
|
||||
current_resolved_path = current_resolved_path .. found_entry
|
||||
else
|
||||
current_resolved_path = current_resolved_path .. "/" .. found_entry
|
||||
end
|
||||
end
|
||||
return current_resolved_path
|
||||
end
|
||||
}
|
||||
|
||||
include /usr/local/openresty/nginx/conf/mime.types;
|
||||
|
||||
server {
|
||||
listen 6931;
|
||||
@ -14,14 +50,33 @@ http {
|
||||
add_header 'Cross-Origin-Resource-Policy' 'cross-origin';
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
root /usr/local/openresty/nginx/html;
|
||||
index index.html isle.html;
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location ~* ^/assets/(.*)$ {
|
||||
alias /assets/;
|
||||
try_files /$1 /DATA/disk/$1 =404;
|
||||
location /assets/ {
|
||||
content_by_lua_block {
|
||||
local request_uri = ngx.var.uri
|
||||
local resolved_path = find_recursive_path(request_uri)
|
||||
|
||||
if not resolved_path then
|
||||
local fallback_uri = ngx.re.sub(request_uri, [[^/assets/]], "/assets/DATA/disk/", "i")
|
||||
resolved_path = find_recursive_path(fallback_uri)
|
||||
end
|
||||
|
||||
if resolved_path then
|
||||
ngx.exec("/internal" .. resolved_path)
|
||||
else
|
||||
ngx.exit(ngx.HTTP_NOT_FOUND)
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
location /internal/assets/ {
|
||||
internal;
|
||||
root /;
|
||||
rewrite ^/internal(.*)$ $1 break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
3
docker/emscripten/ssl_example/Caddyfile
Normal file
3
docker/emscripten/ssl_example/Caddyfile
Normal file
@ -0,0 +1,3 @@
|
||||
https://localhost:6932 {
|
||||
reverse_proxy app:6931
|
||||
}
|
18
docker/emscripten/ssl_example/docker-compose.yml
Normal file
18
docker/emscripten/ssl_example/docker-compose.yml
Normal file
@ -0,0 +1,18 @@
|
||||
services:
|
||||
app:
|
||||
image: ghcr.io/isledecomp/isle-portable-emscripten:master
|
||||
ports:
|
||||
- "6931:6931"
|
||||
volumes:
|
||||
- ${ASSETS_PATH}:/assets
|
||||
|
||||
caddy:
|
||||
image: caddy:latest
|
||||
ports:
|
||||
- "6932:6932"
|
||||
volumes:
|
||||
- ./Caddyfile:/etc/caddy/Caddyfile
|
||||
- caddy_data:/data
|
||||
|
||||
volumes:
|
||||
caddy_data:
|
Loading…
x
Reference in New Issue
Block a user