Gemini: server (fly.io, non-functional)

This puts the framework for building a statically compiled agate into a scratch Docker image which can be run from fly.io (as well as the fly.toml that sets it up correctly).

This doesn't seem to work on fly.io itself at the moment, so more tinkering soon, but it works locally.
This commit is contained in:
JP Hastings-Spital 2024-04-30 19:59:10 +01:00
parent 7547001056
commit 68c939762e
5 changed files with 60 additions and 3 deletions

2
.dockerignore Normal file
View file

@ -0,0 +1,2 @@
*
!/public/

View file

@ -29,6 +29,7 @@ jobs:
HUGO_VERSION: 0.125.4 HUGO_VERSION: 0.125.4
PAGEFIND_VERSION: 1.1.0 PAGEFIND_VERSION: 1.1.0
TASK_VERSION: 3.36.0 TASK_VERSION: 3.36.0
RESTIC_VERSION: 0.16.4
steps: steps:
- name: Install Hugo CLI - name: Install Hugo CLI
run: | run: |
@ -44,6 +45,11 @@ jobs:
wget -q -O ${{ runner.temp }}/task.tar.gz https://github.com/go-task/task/releases/download/v${TASK_VERSION}/task_linux_amd64.tar.gz \ wget -q -O ${{ runner.temp }}/task.tar.gz https://github.com/go-task/task/releases/download/v${TASK_VERSION}/task_linux_amd64.tar.gz \
&& tar -xpf ${{ runner.temp }}/task.tar.gz task \ && tar -xpf ${{ runner.temp }}/task.tar.gz task \
&& mv task /usr/local/bin/task && mv task /usr/local/bin/task
- name: Install Restic CLI
run: |
wget -q -O ${{ runner.temp }}/restic.bz2 https://github.com/restic/restic/releases/download/v${RESTIC_VERSION}/restic_${RESTIC_VERSION}_linux_amd64.bz2 \
&& bunzip2 ${{ runner.temp }}/restic.bz2 \
&& mv restic /usr/local/bin/restic
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:

11
Dockerfile Normal file
View file

@ -0,0 +1,11 @@
FROM ghcr.io/rust-cross/rust-musl-cross:x86_64-unknown-linux-musl as agate
RUN cargo install agate
FROM scratch
COPY --from=agate /root/.cargo/bin/agate /bin/agate
COPY ./public/ /var/agate/content/
EXPOSE 1965
ENTRYPOINT ["/bin/agate", "--content", "/var/agate/content/", "--addr", "0.0.0.0:1965", "--only-tls13", "--central-conf", "--lang", "en-GB", "--certs", "/var/agate/certificates/", "--hostname", "byjp.cc"]

View file

@ -4,6 +4,7 @@ version: '3'
vars: vars:
domain: www.byjp.me domain: www.byjp.me
gmi_domain: byjp.cc
puma_dev_tld: .test puma_dev_tld: .test
env: env:
@ -54,14 +55,20 @@ tasks:
- find -E ./public -regex '.*\.(html|js|css|css\.map|webmanifest|xml|xsl|ico|opml)' -type f -delete - find -E ./public -regex '.*\.(html|js|css|css\.map|webmanifest|xml|xsl|ico|opml)' -type f -delete
# Remove specific unneeded files # Remove specific unneeded files
- rm -rf ./public/favicon*.png ./public/_redirects ./public/{apple,android,mstile}*.png ./public/safari-pinned-tab.svg ./public/robots.txt - rm -rf ./public/favicon*.png ./public/_redirects ./public/{apple,android,mstile}*.png ./public/safari-pinned-tab.svg ./public/robots.txt
# Remove specific unneeded direcctories # Remove specific unneeded directories
- rm -rf ./public/.well-known/ ./public/fonts/ ./public/standalone/project-prime/ - rm -rf ./public/.well-known/ ./public/fonts/ ./public/standalone/project-prime/
# Remove empty directories # Remove empty directories
- find ./public -type d -empty -delete - find ./public -type d -empty -delete
gemini-dev: gemini-dev:
desc: Builds the site & starts a gemini server (on the default port) for it. desc: Builds the site & starts a gemini server (on the default port) for it.
deps: [ build ]
cmds: cmds:
- agate --content public --lang en-GB --hostname "{{ .domain }}{{ .puma_dev_tld }}" --central-conf - agate --content public --addr 0.0.0.0:1965 --ed25519 --only-tls13 --lang en-GB --hostname "{{ .gmi_domain }}{{ .puma_dev_tld }}" --central-conf
gemini-deploy:
desc: Builds, reduces, and deploys the gemini version of the site with fly.
deps:
- build
- gemini-reduce
cmds:
- fly deploy

31
fly.toml Normal file
View file

@ -0,0 +1,31 @@
# fly.toml app configuration file generated for byjp-cc on 2024-04-30T15:16:09+01:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
app = 'byjp-cc'
primary_region = 'lhr'
[build]
[[files]]
guest_path = "/var/agate/certificates/byjp.cc/cert.der"
secret_name = "AGATE_CERT"
[[files]]
guest_path = "/var/agate/certificates/byjp.cc/key.der"
secret_name = "AGATE_KEY"
[[services]]
internal_port = 1965
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
[[services.ports]]
port = 1965
[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1