feat(web01): Deploy Crab Fit on meet.dgnum.eu
Some checks failed
build configuration / build_storage01 (push) Successful in 47s
build configuration / build_compute01 (push) Successful in 1m11s
build configuration / build_vault01 (push) Successful in 42s
build configuration / build_web02 (push) Successful in 41s
build configuration / build_web01 (push) Has been cancelled

This commit is contained in:
Tom Hubrecht 2024-01-23 01:06:10 +01:00
parent d4e8f522e2
commit 6bdbccf9b2
12 changed files with 4330 additions and 2 deletions

View file

@ -10,6 +10,7 @@ lib.extra.mkConfig {
enabledServices = [ enabledServices = [
# List of services to enable # List of services to enable
"castopod" "castopod"
"crabfit"
"eleves" "eleves"
"linkal" "linkal"
"matterbridge" "matterbridge"

View file

@ -0,0 +1,14 @@
_:
{
imports = [ ./packages ];
services.crabfit = {
enable = true;
api.host = "api.meet.dgnum.eu";
frontend.host = "meet.dgnum.eu";
configureNginx = true;
};
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,18 @@
diff --git a/src/main.rs b/src/main.rs
index da3e2c3..e98facb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -99,7 +99,11 @@ async fn main() {
.layer(rate_limit)
.layer(TraceLayer::new_for_http());
- let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
+ let addr_string = env::var("API_LISTEN").unwrap_or("0.0.0.0:3000".to_string());
+
+ let addr: SocketAddr = addr_string
+ .parse()
+ .expect("Unable to parse listen address!");
println!(
"🦀 Crab Fit API listening at http://{} in {} mode",

View file

@ -0,0 +1,62 @@
{
lib,
rustPlatform,
fetchFromGitHub,
pkg-config,
protobuf,
openssl,
sqlite,
stdenv,
darwin,
}:
rustPlatform.buildRustPackage {
pname = "crabfit-api";
version = "unstable-2023-08-02";
src = fetchFromGitHub {
owner = "GRA0007";
repo = "crab.fit";
rev = "628f9eefc300bf1ed3d6cc3323332c2ed9b8a350";
hash = "sha256-jy8BrJSHukRenPbZHw4nPx3cSi7E2GSg//WOXDh90mY=";
};
sourceRoot = "source/api";
patches = [ ./addr.patch ];
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"google-cloud-0.2.1" = "sha256-3/sUeAXnpxO6kzx5+R7ukvMCEM001VoEPP6HmaRihHE=";
};
};
nativeBuildInputs = [
pkg-config
protobuf
];
buildInputs =
[
openssl
sqlite
]
++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
];
buildFeatures = [ "sql-adaptor" ];
PROTOC = "${protobuf}/bin/protoc";
meta = with lib; {
description = "Enter your availability to find a time that works for everyone";
homepage = "https://github.com/GRA0007/crab.fit";
license = licenses.gpl3;
maintainers = with maintainers; [ thubrecht ];
mainProgram = "crabfit-api";
};
}

View file

@ -0,0 +1,131 @@
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index d4c1466..83a99c0 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -1,6 +1,5 @@
import { Metadata } from 'next'
import { Karla } from 'next/font/google'
-import { Analytics } from '@vercel/analytics/react'
import Egg from '/src/components/Egg/Egg'
import Settings from '/src/components/Settings/Settings'
@@ -44,7 +43,6 @@ const RootLayout = async ({ children }: { children: React.ReactNode }) => {
{children}
- <Analytics />
</body>
</html>
}
diff --git a/src/app/page.tsx b/src/app/page.tsx
index ced131b..6b01a5d 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -43,13 +43,9 @@ const Page = async () => {
<DownloadButtons />
<P><Trans i18nKey="about.content.p3" t={t} i18n={i18n}>_<a href="https://bengrant.dev" target="_blank" rel="noreferrer noopener author">_</a>_</Trans></P>
- <P><Trans i18nKey="about.content.p4" t={t} i18n={i18n}>_<a href="https://github.com/GRA0007/crab.fit" target="_blank" rel="noreferrer noopener">_</a>_<Link href="/privacy" rel="license">_</Link>_</Trans></P>
<P>{t('about.content.p6')}</P>
- <P>{t('about.content.p5')}</P>
</Content>
</Section>
-
- <Footer />
</>
}
diff --git a/src/app/privacy/GoogleTranslate.tsx b/src/app/privacy/GoogleTranslate.tsx
deleted file mode 100644
index 57f28c5..0000000
--- a/src/app/privacy/GoogleTranslate.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-'use client'
-
-import { useEffect, useState } from 'react'
-
-const TRANSLATION_DISCLAIMER = 'While the translated document is provided for your convenience, the English version as displayed at https://crab.fit is legally binding.'
-
-interface GoogleTranslateProps {
- children: React.ReactNode
- language: string
-}
-
-// Show a link to translate the privacy policy to the user's preferred language
-const GoogleTranslate = ({ language, children }: GoogleTranslateProps) => {
- const [content, setContent] = useState<string>()
-
- useEffect(() => {
- setContent(document.querySelector<HTMLDivElement>('#policy')?.innerText)
- }, [])
-
- return content ? <p>
- <a
- href={`https://translate.google.com/?sl=en&tl=${language.substring(0, 2)}&text=${encodeURIComponent(`${TRANSLATION_DISCLAIMER}\n\n${content}`)}&op=translate`}
- target="_blank"
- rel="noreferrer noopener"
- >{children}</a>
- </p> : null
-}
-
-export default GoogleTranslate
diff --git a/src/app/privacy/page.tsx b/src/app/privacy/page.tsx
index 6fa88a5..3a78935 100644
--- a/src/app/privacy/page.tsx
+++ b/src/app/privacy/page.tsx
@@ -1,6 +1,5 @@
import { Metadata } from 'next'
-import GoogleTranslate from '/src/app/privacy/GoogleTranslate'
import Button from '/src/components/Button/Button'
import Content from '/src/components/Content/Content'
import Footer from '/src/components/Footer/Footer'
@@ -28,8 +27,6 @@ const Page = async () => {
<h1>{t('privacy:name')}</h1>
- {!i18n.language.startsWith('en') && <GoogleTranslate language={i18n.language}>{t('privacy:translate')}</GoogleTranslate>}
-
<h3>Crab Fit</h3>
<div id="policy">
<P>This SERVICE is provided by Benjamin Grant at no cost and is intended for use as is.</P>
@@ -37,12 +34,7 @@ const Page = async () => {
<P>If you choose to use the Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that is collected is used for providing and improving the Service. Your information will not be used or shared with anyone except as described in this Privacy Policy.</P>
<h2>Information Collection and Use</h2>
- <P>The Service uses third party services that may collect information used to identify you.</P>
- <P>Links to privacy policies of the third party service providers used by the Service:</P>
- <Ul>
- <li><a href="https://www.google.com/policies/privacy/" target="blank">Google Play Services</a> (only used for Google Calendar sync)</li>
- <li><a href="https://vercel.com/docs/concepts/analytics/privacy-policy" target="blank">Vercel Analytics</a></li>
- </Ul>
+ <P>The Service uses no third party services that may collect information used to identify you.</P>
<h2>Log Data</h2>
<P>When you use the Service, in the case of an error, data and information is collected to improve the Service, which may include your IP address, device name, operating system version, app configuration and the time and date of the error.</P>
@@ -51,16 +43,6 @@ const Page = async () => {
<P>Cookies are files with a small amount of data that are commonly used as anonymous unique identifiers. These are sent to your browser from the websites that you visit and are stored on your device's internal memory.</P>
<P>Cookies are used by Google Analytics to track you across the web and provide anonymous statistics to improve the Service.</P>
- <h2>Service Providers</h2>
- <P>Third-party companies may be employed for the following reasons:</P>
- <Ul>
- <li>To facilitate the Service</li>
- <li>To provide the Service on our behalf</li>
- <li>To perform Service-related services</li>
- <li>To assist in analyzing how the Service is used</li>
- </Ul>
- <P>To perform these tasks, the third parties may have access to your Personal Information, but are obligated not to disclose or use this information for any purpose except the above.</P>
-
<h2>Security</h2>
<P>Personal Information that is shared via the Service is protected, however remember that no method of transmission over the internet, or method of electronic storage is 100% secure and reliable, so take care when sharing Personal Information.</P>
<p className={styles.note}>Events that are created will be automatically permanently erased from storage after <strong>3 months</strong> of inactivity.</p>
@@ -76,7 +58,7 @@ const Page = async () => {
<P>Last updated: 2023-06-10</P>
<h2>Contact Us</h2>
- <P>If you have any questions or suggestions about the Privacy Policy, do not hesitate to contact us at <a href="mailto:contact@crab.fit">contact@crab.fit</a>.</P>
+ <P>If you have any questions or suggestions about the Privacy Policy, do not hesitate to contact us at <a href="mailto:contact@dgnum.eu">contact@dgnum.eu</a>.</P>
</div>
</Content>

View file

@ -0,0 +1,20 @@
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index d4c1466..76c9931 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -1,5 +1,5 @@
import { Metadata } from 'next'
-import { Karla } from 'next/font/google'
+import localFont from 'next/font/local'
import Egg from '/src/components/Egg/Egg'
import Settings from '/src/components/Settings/Settings'
@@ -10,7 +10,7 @@ import { useTranslation } from '/src/i18n/server'
import './global.css'
-const karla = Karla({ subsets: ['latin'] })
+const karla = localFont({ src: './fonts/karla.ttf' })
export const metadata: Metadata = {
metadataBase: new URL('https://crab.fit'),

View file

@ -0,0 +1,10 @@
diff --git a/next.config.js b/next.config.js
new file mode 100644
index 0000000..dfc4807
--- /dev/null
+++ b/next.config.js
@@ -0,0 +1,4 @@
+/** @type {import('next').NextConfig} */
+module.exports = {
+ output: 'standalone'
+}

View file

@ -0,0 +1,88 @@
{
lib,
stdenv,
fetchFromGitHub,
fetchYarnDeps,
nodejs,
yarn,
fixup_yarn_lock,
google-fonts,
api_url ? "http://127.0.0.1:3000"
}:
stdenv.mkDerivation (
finalAttrs: {
pname = "crabfit-frontend";
version = "unstable-2023-08-02";
src = fetchFromGitHub {
owner = "GRA0007";
repo = "crab.fit";
rev = "628f9eefc300bf1ed3d6cc3323332c2ed9b8a350";
hash = "sha256-jy8BrJSHukRenPbZHw4nPx3cSi7E2GSg//WOXDh90mY=";
};
sourceRoot = "source/frontend";
patches = [
./01-privacy.patch
./02-karla.patch
./03-standalone.patch
];
offlineCache = fetchYarnDeps {
yarnLock = "${finalAttrs.src}/frontend/yarn.lock";
hash = "sha256-jkyQygwHdLlEZ1tlSQOh72nANp2F29rZbTXvKQStvGc=";
};
nativeBuildInputs = [
nodejs
yarn
fixup_yarn_lock
];
configurePhase = ''
runHook preConfigure
export HOME="$PWD"
echo 'NEXT_PUBLIC_API_URL="${api_url}"' > .env.local
fixup_yarn_lock yarn.lock
yarn config --offline set yarn-offline-mirror ${finalAttrs.offlineCache}
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules
mkdir -p src/app/fonts
cp "${
google-fonts.override { fonts = [ "Karla" ]; }
}/share/fonts/truetype/Karla[wght].ttf" src/app/fonts/karla.ttf
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
NODE_ENV=production yarn build
runHook postBuild
'';
installPhase = ''
mkdir $out
cp -R .next/* $out
cp -R public $out/standalone/
cp -R .next/static $out/standalone/.next
ln -s /var/cache/crabfit $out/standalone/.next/cache
'';
meta = with lib; {
description = "Enter your availability to find a time that works for everyone";
homepage = "https://github.com/GRA0007/crab.fit";
license = licenses.gpl3;
maintainers = with maintainers; [ thubrecht ];
};
}
)

View file

@ -0,0 +1,10 @@
_:
{
nixpkgs.overlays = [
(self: _: {
crabfit-api = self.callPackage ./crabfit-api { };
crabfit-frontend = self.callPackage ./crabfit-frontend { };
})
];
}

View file

@ -51,6 +51,7 @@
"${sources.attic}/nixos/atticd.nix" "${sources.attic}/nixos/atticd.nix"
] ++ ((import sources.nix-modules { inherit lib; }).importModules [ ] ++ ((import sources.nix-modules { inherit lib; }).importModules [
"age-secrets" "age-secrets"
"services/crabfit"
"services/forgejo-nix-runners" "services/forgejo-nix-runners"
]); ]);
} }

View file

@ -107,9 +107,9 @@
"url": "https://git.hubrecht.ovh/hubrecht/nix-modules.git" "url": "https://git.hubrecht.ovh/hubrecht/nix-modules.git"
}, },
"branch": "main", "branch": "main",
"revision": "80f4df0b7bd2837882305fe267b6358afdcde0e9", "revision": "90eb1e4bfd3cc4a7a9d6bec2d4338219283ac3ad",
"url": null, "url": null,
"hash": "0j5p50zz4rsxmp5xhriq8rcy8gnn06x2p3jb8nsnryxlnadsm1im" "hash": "1g6klww6chr350z0ns7spnbaxrch540dn1fzgv2cy4ikin7w7dhy"
}, },
"nix-patches": { "nix-patches": {
"type": "GitRelease", "type": "GitRelease",