build templates add

This commit is contained in:
icurfer 2025-01-12 01:20:21 +09:00
parent 44e342efa9
commit 5691b5afd5
3 changed files with 190 additions and 0 deletions

20
Dockerfile Normal file
View File

@ -0,0 +1,20 @@
# Nginx 기반 Docker 이미지
FROM nginx:alpine
# 기본 Nginx 설정 제거
RUN rm /etc/nginx/conf.d/default.conf
# Unity WebGL 빌드 파일 복사
COPY ./Build /usr/share/nginx/html/Build
COPY ./TemplateData /usr/share/nginx/html/TemplateData
#COPY ./index.html /usr/share/nginx/html/
COPY ./index-full.html /usr/share/nginx/html/index.html
# Nginx 커스텀 설정 복사
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
# 포트 공개
EXPOSE 80
# Nginx 실행
CMD ["nginx", "-g", "daemon off;"]

105
index-full.html Normal file
View File

@ -0,0 +1,105 @@
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unity Web Player | demo</title>
<link rel="shortcut icon" href="TemplateData/favicon.ico">
<link rel="stylesheet" href="TemplateData/style.css">
<style>
#unity-container {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
overflow: hidden;
}
#unity-canvas {
width: 100%;
height: 100%;
display: block;
}
</style>
</head>
<body>
<div id="unity-container" class="unity-desktop">
<canvas id="unity-canvas" tabindex="-1"></canvas>
<div id="unity-loading-bar">
<div id="unity-logo"></div>
<div id="unity-progress-bar-empty">
<div id="unity-progress-bar-full"></div>
</div>
</div>
<div id="unity-warning"></div>
<div id="unity-footer">
<div id="unity-logo-title-footer"></div>
<div id="unity-fullscreen-button"></div>
<div id="unity-build-title">demo</div>
</div>
</div>
<script>
var canvas = document.querySelector("#unity-canvas");
function resizeCanvas() {
var container = document.querySelector("#unity-container");
canvas.width = container.clientWidth;
canvas.height = container.clientHeight;
}
window.addEventListener("resize", resizeCanvas);
resizeCanvas();
var buildUrl = "Build";
var loaderUrl = buildUrl + "/demo3.loader.js";
var config = {
arguments: [],
dataUrl: buildUrl + "/demo3.data.gz",
frameworkUrl: buildUrl + "/demo3.framework.js.gz",
codeUrl: buildUrl + "/demo3.wasm.gz",
streamingAssetsUrl: "StreamingAssets",
companyName: "DefaultCompany",
productName: "demo",
productVersion: "1.0",
showBanner: function (msg, type) {
var warningBanner = document.querySelector("#unity-warning");
function updateBannerVisibility() {
warningBanner.style.display = warningBanner.children.length ? "block" : "none";
}
var div = document.createElement("div");
div.innerHTML = msg;
warningBanner.appendChild(div);
if (type === "error") div.style = "background: red; padding: 10px;";
else {
if (type === "warning") div.style = "background: yellow; padding: 10px;";
setTimeout(function () {
warningBanner.removeChild(div);
updateBannerVisibility();
}, 5000);
}
updateBannerVisibility();
},
};
var script = document.createElement("script");
script.src = loaderUrl;
script.onload = () => {
createUnityInstance(canvas, config, (progress) => {
document.querySelector("#unity-progress-bar-full").style.width = 100 * progress + "%";
}).then((unityInstance) => {
document.querySelector("#unity-loading-bar").style.display = "none";
document.querySelector("#unity-fullscreen-button").onclick = () => {
unityInstance.SetFullscreen(1);
};
resizeCanvas();
}).catch((message) => {
alert(message);
});
};
document.body.appendChild(script);
</script>
</body>
</html>

65
nginx.conf Normal file
View File

@ -0,0 +1,65 @@
server {
listen 80;
server_name localhost;
# Unity WebGL 빌드 파일의 기본 경로
root /usr/share/nginx/html;
index index.html;
# 기본 파일 제공
location / {
try_files $uri $uri/ /index.html;
expires max;
add_header Cache-Control "public, max-age=31536000";
}
# Gzip으로 압축된 WebAssembly 파일 처리
location ~ \.wasm\.gz$ {
gzip_static always;
add_header Content-Encoding gzip;
add_header Cache-Control "public, max-age=31536000";
default_type application/wasm;
try_files $uri =404;
}
# Gzip으로 압축된 JavaScript 파일 처리
location ~ \.js\.gz$ {
gzip_static always;
add_header Content-Encoding gzip;
add_header Content-Type application/javascript;
add_header Cache-Control "public, max-age=31536000";
try_files $uri =404;
}
# Gzip으로 압축된 CSS 파일 처리
location ~ \.css\.gz$ {
gzip_static always;
add_header Content-Encoding gzip;
add_header Content-Type text/css;
add_header Cache-Control "public, max-age=31536000";
try_files $uri =404;
}
# Gzip으로 압축된 HTML 파일 처리
location ~ \.html\.gz$ {
gzip_static always;
add_header Content-Encoding gzip;
add_header Content-Type text/html;
add_header Cache-Control "public, max-age=31536000";
try_files $uri =404;
}
# Gzip으로 압축된 데이터 파일 처리
location ~ \.data\.gz$ {
gzip_static always;
add_header Content-Encoding gzip;
add_header Content-Type application/octet-stream;
add_header Cache-Control "public, max-age=31536000";
try_files $uri =404;
}
# 404 에러 페이지 처리
error_page 404 /index.html;
}