update cdn

This commit is contained in:
2026-03-24 10:13:48 +01:00
parent 84b8735385
commit 4e5479cf31
8 changed files with 103 additions and 75 deletions
+19
View File
@@ -0,0 +1,19 @@
- `mc alias set ...`
- `mc cp ~/pictures/memes_a_dalsi/sap500.png ranpu-test/44gyu-test1/xxx`
- create `nginx` service
- update secret envs for env replace
```
# prg1
DOMAIN=nginx.zerops.matejpavlicek.cz
STORAGE_HOST=storage-prg1.zerops.io
STORAGE_BUCKET=4gh42-bucket1
STORAGE_OBJECT=gopher_profilovka.png
# ranpu
DOMAIN=g99f14mbh7c3n9u5gdsi4d5kp90.ranpu.dev-zerops.cloud
STORAGE_HOST=storage-ranpu.zerops.io
STORAGE_BUCKET=44gyu-test1
STORAGE_OBJECT=xxx
```
- push to `nginx` service
- enable domain for it
+19 -15
View File
@@ -3,30 +3,34 @@
<title>CDN TEST</title>
</head>
<body>
<h1>TEST</h1>
<h1>STATIC</h1>
<p>
direct static
direct:
<img height="128" src="static/gopher_profilovka.png" alt="gopher"/>
</p>
<p>
cdn static
<img height="128" src="https://static.cdn.zerops.app/nginx.zerops.matejpavlicek.cz/static/gopher_profilovka.png" alt="gopher"/>
cdn:
<img height="128" src="https://static.cdn.zerops.app/%%DOMAIN%%/static/gopher_profilovka.png" alt="gopher"/>
</p>
<p>
direct s3
<img height="128" src="https://storage-prg1.zerops.io/4gh42-bucket1/gopher_profilovka.png" alt="gopher"/>
</p>
<p>
cdn s3
<img height="128" src="https://storage.cdn.zerops.app/4gh42-bucket1/gopher_profilovka.png" alt="gopher"/>
</p>
<p>
fetch static
fetch cdn:
<div id="image-container"></div>
</p>
<hr/>
<h1>STORAGE</h1>
<p>
direct:
<img height="128" src="https://%%STORAGE_HOST%%/%%STORAGE_BUCKET%%/%%STORAGE_OBJECT%%" alt="s3-image"/>
</p>
<p>
cdn:
<img height="128" src="https://storage.cdn.zerops.app/%%STORAGE_BUCKET%%/%%STORAGE_OBJECT%%" alt="s3-image"/>
</p>
<script>
fetch('https://static.cdn.zerops.app/nginx.zerops.matejpavlicek.cz/static/gopher_profilovka.png')
fetch('https://static.cdn.zerops.app/%%DOMAIN%%/static/gopher_profilovka.png')
.then(response => response.blob())
.then(blob => {
const objectURL = URL.createObjectURL(blob);
@@ -45,4 +49,4 @@
});
</script>
</body>
</html>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

+15
View File
@@ -0,0 +1,15 @@
services:
- hostname: nginx
type: nginx@latest
envSecrets:
STORAGE_HOST: storage-prg1.zerops.io
STORAGE_BUCKET: 4gh42-bucket1
STORAGE_OBJECT: gopher_profilovka.png
DOMAIN: nginx.zerops.matejpavlicek.cz
maxContainers: 1
# - hostname: app
# type: alpine@3.20
# maxContainers: 1
# - hostname: static
# type: static@latest
# maxContainers: 1
-11
View File
@@ -1,11 +0,0 @@
services:
- hostname: app
type: alpine@3.20
maxContainers: 1
- hostname: static
type: static@latest
maxContainers: 1
- hostname: nginx
type: nginx@latest
maxContainers: 1
startWithoutCode: true
+50
View File
@@ -0,0 +1,50 @@
zerops:
- setup: nginx
build:
os: alpine
deployFiles:
- nginx.conf
- index.html
- static/
run:
os: alpine
base: nginx@latest
prepareCommands:
- sudo apk update
- sudo apk add vim
ports:
- port: 80
httpSupport: true
envReplace:
target: index.html
delimiter: '%%'
siteConfigPath: nginx.conf
# - setup: app
# build:
# os: alpine
# base: go@1
# buildCommands:
# - go build -o app main.go
# cache: true
# deployFiles:
# - app
# run:
# os: alpine
# base: alpine@latest
# ports:
# - port: 8080
# httpSupport: true
# start: ./app
#
# - setup: static
# build:
# deployFiles:
# - index.html
# - static/
# run:
# os: alpine
# base: static@latest
# ports:
# - port: 80
# httpSupport: true
-49
View File
@@ -1,49 +0,0 @@
zerops:
- setup: app
build:
os: alpine
base:
- go@1
buildCommands:
- go build -o app main.go
cache: true
deployFiles:
- app
run:
os: alpine
base: alpine@latest
ports:
- port: 8080
httpSupport: true
start: ./app
- setup: static
build:
deployFiles:
- index.html
- static/
run:
os: alpine
base: static@latest
ports:
- port: 80
httpSupport: true
- setup: nginx
build:
deployFiles:
- index.html
- static/
- nginx.conf
addToRunPrepare:
-
run:
os: alpine
base: nginx@latest
prepareCommands:
- sudo apk update
- sudo apk add vim
ports:
- port: 80
httpSupport: true
siteConfigPath: nginx.conf