add option to set base path
All checks were successful
delpoy / build-and-deploy (push) Successful in 34s

This commit is contained in:
bytedream 2023-08-10 16:25:47 +02:00
parent 8badac5d09
commit 793c43adc0
5 changed files with 18 additions and 8 deletions

View File

@ -1,2 +1,3 @@
DATABASE_URI=sqlite://./database.db DATABASE_URI=sqlite://./database.db
PUBLIC_START_DATE=2023-12-26T00:00:00 PUBLIC_START_DATE=2023-12-26T00:00:00
PUBLIC_BASE_PATH=

View File

@ -28,7 +28,7 @@ jobs:
eval $(ssh-agent) eval $(ssh-agent)
ssh-add "$HOME/.ssh/deploy_key" ssh-add "$HOME/.ssh/deploy_key"
ssh-keyscan -t rsa "$HOST" >> "$HOME/.ssh/known_hosts" ssh-keyscan -t rsa "$HOST" >> "$HOME/.ssh/known_hosts"
ssh -o StrictHostKeyChecking=no $USER@$HOST "rm -r /opt/website; mkdir -p /opt/website" ssh -o StrictHostKeyChecking=no $USER@$HOST "rm -r /opt/website; mkdir -p /opt/website"
scp -r -o StrictHostKeyChecking=no $(ls -d -1 build/*) $(ls package*) $USER@$HOST:/opt/website scp -r -o StrictHostKeyChecking=no $(ls -d -1 build/*) $(ls package*) $USER@$HOST:/opt/website
ssh -o StrictHostKeyChecking=no $USER@$HOST "cd /opt/website; npm i --omit=dev; systemctl restart website" ssh -o StrictHostKeyChecking=no $USER@$HOST "cd /opt/website; npm i --omit=dev; systemctl restart website"

View File

@ -34,4 +34,5 @@ Configurations can be done with env variables
| `HOST` | Host the server should listen on | | `HOST` | Host the server should listen on |
| `PORT` | Port the server should listen on | | `PORT` | Port the server should listen on |
| `DATABASE_URI` | URI to the database as a connection string. Supported databases are [sqlite](https://www.sqlite.org/index.html) and [mariadb](https://mariadb.org/) | | `DATABASE_URI` | URI to the database as a connection string. Supported databases are [sqlite](https://www.sqlite.org/index.html) and [mariadb](https://mariadb.org/) |
| `PUBLIC_BASE_PATH` | If running the website on a sub-path, set this variable to the path so that assets etc. can find the correct location |
| `PUBLIC_START_DATE` | The start date when the event starts | | `PUBLIC_START_DATE` | The start date when the event starts |

View File

@ -1,16 +1,22 @@
<script> <script lang="ts">
import '../app.css'; import '../app.css';
import { env } from '$env/dynamic/public';
</script> </script>
<nav class="navbar fixed top-0 bg-base-100 h-12 z-40"> <nav class="navbar fixed top-0 bg-base-100 h-12 z-40">
<div class="navbar-start h-full"> <div class="navbar-start h-full">
<a class="h-full" href="/"> <a class="h-full" href="{env.PUBLIC_BASE_PATH}/">
<img class="rounded h-full" src="/img/craftattack-logo.webp" alt="Logo" /> <img
class="rounded h-full"
src="{env.PUBLIC_BASE_PATH}/img/craftattack-logo.webp"
alt="Logo"
/>
</a> </a>
</div> </div>
<div class="navbar-center flex space-x-20"> <div class="navbar-center flex space-x-20">
<a class="link" href="/register">Anmelden</a> <a class="link" href="{env.PUBLIC_BASE_PATH}/register">Anmelden</a>
<a class="link" href="/rules">Regeln</a> <a class="link" href="{env.PUBLIC_BASE_PATH}/rules">Regeln</a>
</div> </div>
<div class="navbar-end" /> <div class="navbar-end" />
</nav> </nav>

View File

@ -2,6 +2,7 @@
import Select from '$lib/components/Input/Select.svelte'; import Select from '$lib/components/Input/Select.svelte';
import Input from '$lib/components/Input/Input.svelte'; import Input from '$lib/components/Input/Input.svelte';
import { createEventDispatcher, onMount } from 'svelte'; import { createEventDispatcher, onMount } from 'svelte';
import { env } from '$env/dynamic/public';
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
@ -37,7 +38,7 @@
async function sendRegister() { async function sendRegister() {
// eslint-disable-next-line no-async-promise-executor // eslint-disable-next-line no-async-promise-executor
registerRequest = new Promise(async (resolve, reject) => { registerRequest = new Promise(async (resolve, reject) => {
const response = await fetch('/register', { const response = await fetch(`${env.PUBLIC_BASE_PATH}/register`, {
method: 'POST', method: 'POST',
body: new FormData(document.forms[0]) body: new FormData(document.forms[0])
}); });
@ -171,7 +172,8 @@
bind:inputElement={rulesInput} bind:inputElement={rulesInput}
/> />
<label for="rules"> <label for="rules">
Ich bin mit den <a class="link" href="/rules">Regeln</a> einverstanden und achte sie Ich bin mit den <a class="link" href="{env.PUBLIC_BASE_PATH}/rules">Regeln</a> einverstanden
und achte sie
<span class="text-red-700">*</span> <span class="text-red-700">*</span>
<br /> <br />
<p class="text-[.75rem]"> <p class="text-[.75rem]">