create staging environment #6

Merged
tudor merged 2 commits from staging-and-prod into master 2024-03-01 11:48:19 +02:00
10 changed files with 78 additions and 15 deletions

View File

@ -2,3 +2,4 @@ _site
flake.nix
flake.lock
.gitea
.fly*

View File

@ -34,6 +34,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Deploy!
run: nix run .#flyctl -- deploy --remote-only
run: nix run .#flyctl -- deploy --remote-only -c fly.prod.toml
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

View File

@ -2,7 +2,7 @@
auto_https off
}
http://tudorr.ro {
http://tudorr.ro, http://tudorrro-staging.fly.dev {
root * /usr/share/caddy
file_server
log

View File

@ -10,7 +10,10 @@ COPY --chown=deno _config.ts .
RUN deno task lume -h
COPY --chown=deno . .
RUN deno task lume
ARG MODE="staging"
RUN if [ "$MODE" = "prod" ]; then export TUDORR_RELEASE=1; fi \
&& deno task lume
FROM caddy:2

View File

@ -15,11 +15,23 @@ import rehypePrism from "npm:rehype-prism-plus/all";
import tailwindOptions from "./tailwind.config.js";
const isRelease = Deno.env.has("TUDORR_RELEASE")
&& Deno.env.get("TUDORR_RELEASE") !== "0"
&& Deno.env.get("TUDORR_RELEASE") !== "";
const site = lume({
src: "./src",
location: new URL("https://tudorr.ro"),
location: isRelease ? new URL("https://tudorr.ro")
: new URL("https://tudorrro-staging.fly.dev"),
});
if (isRelease) {
site.data("release", true);
console.log("🥳 Release mode on! 🥳");
} else {
site.data("release", false);
}
site.copy("static");
site.use(date({
@ -48,9 +60,11 @@ site.use(tailwindcss({
options: tailwindOptions,
}));
site.use(postcss());
site.use(sitemap({
query: "",
}));
if (isRelease) {
site.use(sitemap({
query: "",
}));
}
site.use(lightningCss());

25
fly.prod.toml Normal file
View File

@ -0,0 +1,25 @@
app = 'tudorrro'
primary_region = 'ams'
[build]
[build.args]
MODE="prod"
[http_service]
internal_port = 80
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ['app']
[[vm]]
cpu_kind = 'shared'
cpus = 1
memory_mb = 256
[checks]
[checks.health]
type = "http"
port = 80
path = "/health"

View File

@ -1,4 +1,4 @@
app = 'tudorrro'
app = 'tudorrro-staging'
primary_region = 'ams'
[build]
@ -11,13 +11,13 @@ primary_region = 'ams'
min_machines_running = 0
processes = ['app']
[checks]
[checks.health]
port = 80
type = 'http'
path = '/health'
[[vm]]
cpu_kind = 'shared'
cpus = 1
memory_mb = 256
[checks]
[checks.health]
type = "http"
port = 80
path = "/health"

View File

@ -3,7 +3,8 @@
"title": "tudor's website",
"description": "",
"siteName": "tudorr.ro",
"author": "Tudor Roman"
"author": "Tudor Roman",
"release": false
},
"layout": "base.vto",

View File

@ -51,6 +51,14 @@
</nav>
</header>
<main class="p-2 text-lg">
{{ if !release }}
<h1 class="text-3xl mb-4">Staging environment</h1>
<p class="mb-4">
You have reached my website's staging environment!
You are unlikely to find unpublished articles here, unfortunately.
I use this to test other changes, like changes to the layout.
</p>
{{ /if }}
{{ content }}
</main>
<footer class="mt-8">

11
src/robots.txt.vto Normal file
View File

@ -0,0 +1,11 @@
---
layout: ""
url: /robots.txt
---
User-agent: *
{{- if release }}
Allow: /
{{- else }}
Disallow: /
{{- /if }}