mirror of
https://github.com/Steffo99/todocolors.git
synced 2024-11-23 16:54:18 +00:00
Fix dockerfiles again
This commit is contained in:
parent
5fb88c36b9
commit
7e24c46161
9 changed files with 35 additions and 99 deletions
|
@ -1,9 +1,11 @@
|
|||
FROM node:20
|
||||
|
||||
WORKDIR /usr/src/todoblue
|
||||
COPY ./ ./
|
||||
|
||||
COPY ./package.json ./yarn.lock ./
|
||||
RUN yarn install
|
||||
|
||||
COPY ./ ./
|
||||
RUN yarn run build
|
||||
|
||||
ENTRYPOINT ["yarn", "run", "start", "--port=8081"]
|
||||
|
|
|
@ -1,20 +1,14 @@
|
|||
"use client";
|
||||
|
||||
import style from "@/app/page.module.css"
|
||||
import {useServersideConfiguration} from "@/app/ServersideConfigurationManager"
|
||||
import {default as React} from "react"
|
||||
|
||||
|
||||
export function RootFooter() {
|
||||
const {baseURL} = useServersideConfiguration()
|
||||
|
||||
return (
|
||||
<footer className={style.pageFooter}>
|
||||
<p>
|
||||
© <a href="https://steffo.eu">Stefano Pigozzi</a> -
|
||||
<a href="https://www.gnu.org/licenses/agpl-3.0.en.html">AGPL 3.0</a> -
|
||||
<a href="https://github.com/Steffo99/todocolors">GitHub</a> -
|
||||
Using {baseURL}
|
||||
<a href="https://github.com/Steffo99/todocolors">GitHub</a>
|
||||
</p>
|
||||
</footer>
|
||||
)
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
"use client";
|
||||
|
||||
import style from "@/app/page.module.css"
|
||||
import {useServersideConfiguration} from "@/app/ServersideConfigurationManager"
|
||||
import {default as React} from "react"
|
||||
|
||||
|
||||
export function RootHeader() {
|
||||
const {siteName} = useServersideConfiguration()
|
||||
|
||||
return (
|
||||
<header className={style.pageHeader}>
|
||||
<h1>
|
||||
{siteName}
|
||||
Todoblue
|
||||
</h1>
|
||||
</header>
|
||||
)
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
"use client";
|
||||
import {createContext, ReactNode, useContext} from "react"
|
||||
|
||||
|
||||
/**
|
||||
* **Object** containing the site options configurable via runtime environment variables.
|
||||
*/
|
||||
export interface ServersideConfiguration {
|
||||
siteName: string,
|
||||
baseURL: string,
|
||||
}
|
||||
|
||||
/**
|
||||
* **Context** where the {@link ServersideConfiguration} is stored in.
|
||||
*/
|
||||
export const ServersideConfigurationContext = createContext<ServersideConfiguration | null>(null);
|
||||
|
||||
/**
|
||||
* **Component** acting as a provider for the {@link ServersideConfigurationContext} for its children.
|
||||
*
|
||||
* Required to execute only on the client.
|
||||
*
|
||||
* @param value The {@link ServersideConfiguration} to provide.
|
||||
* @param children The {@link ReactNode}s to provide the {@link ServersideConfiguration} to.
|
||||
* @constructor
|
||||
*/
|
||||
export function ServersideConfigurationManager({value, children}: {value: ServersideConfiguration, children: ReactNode}) {
|
||||
return (
|
||||
<ServersideConfigurationContext.Provider value={value}>
|
||||
{children}
|
||||
</ServersideConfigurationContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* **Hook** to access the globally provided {@link ServersideConfiguration} from children components.
|
||||
*/
|
||||
export function useServersideConfiguration(): ServersideConfiguration {
|
||||
const context = useContext(ServersideConfigurationContext);
|
||||
|
||||
if(context === null) {
|
||||
console.error("[useServersideConfiguration] Was used outside of a ServersideConfigurationContext!")
|
||||
throw Error("Used useServersideConfiguration outside of a ServersideConfigurationContext.")
|
||||
}
|
||||
|
||||
return context
|
||||
}
|
|
@ -1,10 +1,17 @@
|
|||
import {useServersideConfiguration} from "@/app/ServersideConfigurationManager"
|
||||
"use client";
|
||||
import {useMemo} from "react"
|
||||
|
||||
|
||||
export function useBoardWebSocketURL(name: string) {
|
||||
const {baseURL} = useServersideConfiguration()
|
||||
const HTTP_TO_WS = {
|
||||
"http:": "ws:",
|
||||
"https:": "wss:",
|
||||
}
|
||||
|
||||
const webSocketURL = useMemo(() => `${baseURL}/board/${name}/ws`, [name]);
|
||||
export function useBoardWebSocketURL(name: string) {
|
||||
// @ts-ignore
|
||||
const protocol = HTTP_TO_WS[window.location.protocol]
|
||||
const host = window.location.host
|
||||
|
||||
const webSocketURL = useMemo(() => `${protocol}//${host}/api/board/${name}/ws`, [name]);
|
||||
return {webSocketURL}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
import "./layout.css";
|
||||
import {AppBody} from "@/app/AppBody"
|
||||
import {ServersideConfigurationManager} from "@/app/ServersideConfigurationManager"
|
||||
import {useServersideConfigurationEnvvars} from "@/app/useServersideConfigurationEnvvars"
|
||||
import type {Metadata as NextMetadata} from "next"
|
||||
import {default as React, ReactNode} from "react"
|
||||
|
||||
|
@ -12,22 +10,18 @@ config.autoAddCss = false;
|
|||
|
||||
|
||||
export const metadata: NextMetadata = {
|
||||
applicationName: process.env["TODOBLUE_SITE_NAME"] ?? "Todoblue",
|
||||
applicationName: "Todoblue",
|
||||
title: "Home",
|
||||
description: process.env["TODOBLUE_SITE_DESCRIPTION"] ?? "Self-hosted multiplayer todo app",
|
||||
description: "Self-hosted multiplayer todo app",
|
||||
viewport: {userScalable: false}
|
||||
}
|
||||
|
||||
export default function layout({children}: { children: ReactNode }) {
|
||||
const serversideConfiguration = useServersideConfigurationEnvvars()
|
||||
|
||||
return (
|
||||
<html lang="en">
|
||||
<ServersideConfigurationManager value={serversideConfiguration}>
|
||||
<AppBody>
|
||||
{children}
|
||||
</AppBody>
|
||||
</ServersideConfigurationManager>
|
||||
<AppBody>
|
||||
{children}
|
||||
</AppBody>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
import "server-only";
|
||||
import {ServersideConfiguration} from "@/app/ServersideConfigurationManager"
|
||||
|
||||
|
||||
export function useServersideConfigurationEnvvars(): ServersideConfiguration {
|
||||
const siteName = process.env["TODOBLUE_SITE_NAME"]
|
||||
const baseURL = process.env["TODORED_BASE_URL"]
|
||||
|
||||
if(!siteName) {
|
||||
throw Error("TODOBLUE_SITE_NAME is not set.")
|
||||
}
|
||||
if(!baseURL) {
|
||||
throw Error("TODORED_BASE_URL is not set.")
|
||||
}
|
||||
|
||||
return {siteName, baseURL}
|
||||
}
|
8
todopod/config/caddy/Caddyfile
Normal file
8
todopod/config/caddy/Caddyfile
Normal file
|
@ -0,0 +1,8 @@
|
|||
:8080 {
|
||||
route /api/* {
|
||||
uri strip_prefix /api
|
||||
reverse_proxy "http://red:8080"
|
||||
}
|
||||
|
||||
reverse_proxy "http://blue:8081"
|
||||
}
|
|
@ -13,12 +13,12 @@ services:
|
|||
restart: unless-stopped
|
||||
environment:
|
||||
REDIS_CONN: "redis://redis:6379/" # You probably don't need to change this
|
||||
ports:
|
||||
- "127.0.0.1:8080:8080"
|
||||
blue:
|
||||
image: "ghcr.io/steffo99/todocolors-blue"
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
NEXT_PUBLIC_API_BASE_URL: "ws://example.org:8080" # Change this to the URL where red will be accessible at
|
||||
ports:
|
||||
- "127.0.0.1:8081:8081"
|
||||
caddy:
|
||||
image: "caddy"
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- "./data/caddy:/data"
|
||||
- "./config/caddy/Caddyfile:/etc/caddy/Caddyfile"
|
||||
|
|
Loading…
Reference in a new issue