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
|
FROM node:20
|
||||||
|
|
||||||
WORKDIR /usr/src/todoblue
|
WORKDIR /usr/src/todoblue
|
||||||
COPY ./ ./
|
|
||||||
|
|
||||||
|
COPY ./package.json ./yarn.lock ./
|
||||||
RUN yarn install
|
RUN yarn install
|
||||||
|
|
||||||
|
COPY ./ ./
|
||||||
RUN yarn run build
|
RUN yarn run build
|
||||||
|
|
||||||
ENTRYPOINT ["yarn", "run", "start", "--port=8081"]
|
ENTRYPOINT ["yarn", "run", "start", "--port=8081"]
|
||||||
|
|
|
@ -1,20 +1,14 @@
|
||||||
"use client";
|
|
||||||
|
|
||||||
import style from "@/app/page.module.css"
|
import style from "@/app/page.module.css"
|
||||||
import {useServersideConfiguration} from "@/app/ServersideConfigurationManager"
|
|
||||||
import {default as React} from "react"
|
import {default as React} from "react"
|
||||||
|
|
||||||
|
|
||||||
export function RootFooter() {
|
export function RootFooter() {
|
||||||
const {baseURL} = useServersideConfiguration()
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<footer className={style.pageFooter}>
|
<footer className={style.pageFooter}>
|
||||||
<p>
|
<p>
|
||||||
© <a href="https://steffo.eu">Stefano Pigozzi</a> -
|
© <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://www.gnu.org/licenses/agpl-3.0.en.html">AGPL 3.0</a> -
|
||||||
<a href="https://github.com/Steffo99/todocolors">GitHub</a> -
|
<a href="https://github.com/Steffo99/todocolors">GitHub</a>
|
||||||
Using {baseURL}
|
|
||||||
</p>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
"use client";
|
|
||||||
|
|
||||||
import style from "@/app/page.module.css"
|
import style from "@/app/page.module.css"
|
||||||
import {useServersideConfiguration} from "@/app/ServersideConfigurationManager"
|
|
||||||
import {default as React} from "react"
|
import {default as React} from "react"
|
||||||
|
|
||||||
|
|
||||||
export function RootHeader() {
|
export function RootHeader() {
|
||||||
const {siteName} = useServersideConfiguration()
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className={style.pageHeader}>
|
<header className={style.pageHeader}>
|
||||||
<h1>
|
<h1>
|
||||||
{siteName}
|
Todoblue
|
||||||
</h1>
|
</h1>
|
||||||
</header>
|
</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"
|
import {useMemo} from "react"
|
||||||
|
|
||||||
|
|
||||||
export function useBoardWebSocketURL(name: string) {
|
const HTTP_TO_WS = {
|
||||||
const {baseURL} = useServersideConfiguration()
|
"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}
|
return {webSocketURL}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
import "./layout.css";
|
import "./layout.css";
|
||||||
import {AppBody} from "@/app/AppBody"
|
import {AppBody} from "@/app/AppBody"
|
||||||
import {ServersideConfigurationManager} from "@/app/ServersideConfigurationManager"
|
|
||||||
import {useServersideConfigurationEnvvars} from "@/app/useServersideConfigurationEnvvars"
|
|
||||||
import type {Metadata as NextMetadata} from "next"
|
import type {Metadata as NextMetadata} from "next"
|
||||||
import {default as React, ReactNode} from "react"
|
import {default as React, ReactNode} from "react"
|
||||||
|
|
||||||
|
@ -12,22 +10,18 @@ config.autoAddCss = false;
|
||||||
|
|
||||||
|
|
||||||
export const metadata: NextMetadata = {
|
export const metadata: NextMetadata = {
|
||||||
applicationName: process.env["TODOBLUE_SITE_NAME"] ?? "Todoblue",
|
applicationName: "Todoblue",
|
||||||
title: "Home",
|
title: "Home",
|
||||||
description: process.env["TODOBLUE_SITE_DESCRIPTION"] ?? "Self-hosted multiplayer todo app",
|
description: "Self-hosted multiplayer todo app",
|
||||||
viewport: {userScalable: false}
|
viewport: {userScalable: false}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function layout({children}: { children: ReactNode }) {
|
export default function layout({children}: { children: ReactNode }) {
|
||||||
const serversideConfiguration = useServersideConfigurationEnvvars()
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<ServersideConfigurationManager value={serversideConfiguration}>
|
<AppBody>
|
||||||
<AppBody>
|
{children}
|
||||||
{children}
|
</AppBody>
|
||||||
</AppBody>
|
|
||||||
</ServersideConfigurationManager>
|
|
||||||
</html>
|
</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
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
REDIS_CONN: "redis://redis:6379/" # You probably don't need to change this
|
REDIS_CONN: "redis://redis:6379/" # You probably don't need to change this
|
||||||
ports:
|
|
||||||
- "127.0.0.1:8080:8080"
|
|
||||||
blue:
|
blue:
|
||||||
image: "ghcr.io/steffo99/todocolors-blue"
|
image: "ghcr.io/steffo99/todocolors-blue"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
caddy:
|
||||||
NEXT_PUBLIC_API_BASE_URL: "ws://example.org:8080" # Change this to the URL where red will be accessible at
|
image: "caddy"
|
||||||
ports:
|
restart: unless-stopped
|
||||||
- "127.0.0.1:8081:8081"
|
volumes:
|
||||||
|
- "./data/caddy:/data"
|
||||||
|
- "./config/caddy/Caddyfile:/etc/caddy/Caddyfile"
|
||||||
|
|
Loading…
Reference in a new issue