update contents
Build / build (push) Failing after 18m47s

This commit is contained in:
tomoyanonymous committed 2026-11-19 22:28:24 +09:00
1 parent 2250192537
commit 622433ff72
1 file changed
+56 -72
@@ -13,95 +13,79 @@ Pagesの機能がないため、別途サーバーを立ち上げてrsyncで同
## 下準備
鍵をssh-keygenで作っておく。(秘密鍵をGitea側のSecretsに置くので新しく生成しないとだめ)
鍵をssh-keygenで作っておく。
```sh
ssh-keygen -t ed25519
```
ファイル名は`rsync_webserver`と`rsync_webserver.pub`とかにしておく
秘密鍵をGitea側のSecretsに置く。公開鍵は後でcompose.ymlに書き込む
## Caddyサーバー側の構成
[tomoyanonymous/Caddy\_rsync\_webserver - Caddy\_rsync\_webserver - Tomoya Matsuura Gitea](https://git.matsuuratomoya.com/tomoyanonymous/Caddy_rsync_webserver)
### フォルダ構成
```sh
Dockerfile
docker-compose.yml
Caddyfile
docs/ #空フォルダ
rsync_webserver.pub #鍵をコピーしておく
```
rsyncでファイルを受け取る用のDockerイメージを作る
```Dockerfile
FROM ubuntu:latest
RUN apt-get update && apt-get install -y openssh-server rsync
RUN mkdir /var/run/sshd
RUN sed -i 's/#\?SyslogFacility AUTH/SyslogFacility AUTH/' /etc/ssh/sshd_config
RUN sed -i 's/#\?LogLevel INFO/LogLevel Info/' /etc/ssh/sshd_config
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
COPY rsync_webserver.pub /root/authorized_keys
RUN mkdir ~/.ssh && \
mv ~/authorized_keys ~/.ssh/authorized_keys && \
chmod 0600 ~/.ssh/authorized_keys && \
chmod 0700 ~/.ssh
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
```
パーミッションは必ず`~/.ssh/authorized_keys`が600、`~/.ssh`が700でないとssh接続できないので注意
`docker-compose.yml`でCaddyとの連携設定。共通のボリュームでhtmlを管理するが、今回はそのフォルダを`docs`という名前で作った。Caddyのイメージはそのまま使う。
元々は独自のSSHでrsyncのファイルを受け取りcaddyで公開するだけのイメージを作っていたが、既存イメージでやりくりするように変更した。Caddyファイルもcompose.ymlに埋め込んでしまう。
```yml
version: '3'
services:
ssh:
build: .
volumes:
- ./docs:/var/www/html
ports:
- '25222:22'
server:
image: caddy:latest
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./docs:/www/html
ports:
- "8080:80"
ssh:
# 以前は ubuntu に sshd と rsync を入れた独自イメージを build していたが、
# Portainer の Edge 環境では build できないので既製イメージにした。
image: lscr.io/linuxserver/openssh-server:latest
restart: unless-stopped
environment:
- PUID=1000
- PGID=1000
- USER_NAME=rsync
# CI (act_runner) の秘密鍵 PRIVATE_KEY に対応する公開鍵
- PUBLIC_KEY=ssh-ed25519 XXXXXXXXXXXXXXXXXXXXXXXXX
- DOCKER_MODS=linuxserver/mods:openssh-server-rsync
configs:
- source: www-owner
target: /custom-cont-init.d/10-www-owner
mode: 0755
volumes:
- docs:/var/www/html
ports:
- '25223:2222'
server:
image: caddy:latest
restart: unless-stopped
configs:
- source: caddyfile
target: /etc/caddy/Caddyfile
volumes:
- docs:/www/html:ro
ports:
- "8081:80"
volumes:
docs:
configs:
# 新しいボリュームは root 所有で作られるので、rsync ユーザーが書けるように起動時に持ち主を変える
www-owner:
content: |
#!/usr/bin/with-contenv sh
chown "$$PUID:$$PGID" /var/www/html
caddyfile:
content: |
:80 {
root * /www/html
file_server
# try_files {path}.html {path}
handle_errors {
rewrite * /404.html
file_server
}
}
```
Caddyファイルは最小限。
```Caddyfile
:80 {
root * /www/html
file_server
try_files {path}.html {path}
handle_errors {
rewrite * /404.html
file_server
}
}
```
この辺参考。[Serving static files using Caddy](https://thedevelopercafe.com/articles/serving-static-files-using-caddy-8513e8f36e46)。Quartzでは`/記事名.html`に`example.com/記事名`でアクセスする必要があるので`try_files`の行が必要。
`docs`内に適当な`index.html`を置いて`docker-compose build`、`docker-compose up -d`で立ち上げ、`DockerホストのIP:8080`で繋ぐとアクセスできる。
`docs`内に適当な`index.html`を置いてdocker-compose up -d`で立ち上げ、`DockerホストのIP:8080`で繋ぐとアクセスできる。
これをそのまま[[Cloudflare Tunnel]]で公開している。
@@ -119,7 +103,7 @@ Action RunnerつきでGiteaを立ち上げるところまでは省略。
- WEBSERVER_HOST (Caddyが立ち上がっているサーバーのIP)
- WEBSERVER_PORT (Caddyが立ち上がっているサーバーのSSH用ポート、上の例では25222)
- WEBSERVER_USER :root(これあんまり良くないのかな)
- WEBSERVER_USER :rsync
で、リポジトリに`/.gitea/workflows/ci.yaml`を作る。[Gitea Actionsの`ubuntu-latest`ラベルのランナーはデフォルトでDebianベースの`node:16-bullseye`のDockerイメージのエイリアス](https://docs.gitea.com/usage/actions/act-runner#labels)で(これまじでややこしい)、QuartzはNode18以降でないと動かない。