Skip to content

Commit

Permalink
ci: deploying on hetzner
Browse files Browse the repository at this point in the history
  • Loading branch information
aacevski committed Feb 2, 2025
1 parent 7a407c1 commit 74f2e46
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 120 deletions.
101 changes: 0 additions & 101 deletions .github/workflows/changelog.yml

This file was deleted.

2 changes: 1 addition & 1 deletion apps/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM node:lts-slim AS base
FROM --platform=$BUILDPLATFORM node:22-slim AS base
WORKDIR /app

COPY package.json .
Expand Down
1 change: 1 addition & 0 deletions apps/web/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_URL=KANEO_API_URL
5 changes: 4 additions & 1 deletion apps/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20-alpine AS builder
FROM node:22-alpine AS builder

RUN npm install -g bun

Expand Down Expand Up @@ -26,6 +26,9 @@ COPY --from=builder /app/apps/web/dist /usr/share/nginx/html

COPY apps/web/nginx.conf /etc/nginx/conf.d/default.conf

COPY apps/web/env.sh /docker-entrypoint.d/env.sh
RUN chmod +x /docker-entrypoint.d/env.sh

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
9 changes: 9 additions & 0 deletions apps/web/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
for i in $(env | grep KANEO_)
do
key=$(echo $i | cut -d '=' -f 1)
value=$(echo $i | cut -d '=' -f 2-)
echo $key=$value

find /usr/share/nginx/html -type f \( -name '*.js' -o -name '*.css' \) -exec sed -i "s|${key}|${value}|g" '{}' +
done
9 changes: 9 additions & 0 deletions apps/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script>
if (window.location.hostname === 'demo.kaneo.app') {
const script = document.createElement('script');
script.defer = true;
script.setAttribute('data-domain', 'demo.kaneo.app');
script.src = 'https://plausible.kaneo.app/js/script.js';
document.head.appendChild(script);
}
</script>
<title>Kaneo</title>
</head>

Expand Down
26 changes: 23 additions & 3 deletions apps/web/src/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
import TanStackRouterDevtools from "@/tanstack/router";
import type { LoggedInUser } from "@/types/user";
import type { QueryClient } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { Outlet, createRootRouteWithContext } from "@tanstack/react-router";
import { TanStackRouterDevtools } from "@tanstack/router-devtools";
import {
Outlet,
createRootRouteWithContext,
redirect,
} from "@tanstack/react-router";

export const Route = createRootRouteWithContext<{
queryClient: QueryClient;
user: LoggedInUser | null | undefined;
}>()({
component: RootComponent,
async beforeLoad({ context: { user }, location }) {
const isRouteUnprotected = location.pathname.includes("auth");
const isOnDashboard = location.pathname.includes("dashboard");

if (user === null && !isRouteUnprotected) {
throw redirect({
to: "/auth/sign-in",
});
}

if (user && !isOnDashboard) {
throw redirect({
to: "/dashboard",
});
}
},
});

function RootComponent() {
return (
<>
<div className="flex w-full h-screen flex-col md:flex-row bg-zinc-50 dark:bg-zinc-950 scrollbar-thin scrollbar-thumb-zinc-700 scrollbar-track-zinc-900">
<div className="flex w-full h-screen flex-row bg-zinc-50 dark:bg-zinc-950 scrollbar-thin scrollbar-thumb-zinc-700 scrollbar-track-zinc-900">
<Outlet />
</div>
<ReactQueryDevtools buttonPosition="top-right" />
Expand Down
12 changes: 12 additions & 0 deletions apps/web/src/tanstack/router.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react";

const TanStackRouterDevtools =
process.env.NODE_ENV === "production"
? () => null
: React.lazy(() =>
import("@tanstack/router-devtools").then((res) => ({
default: res.TanStackRouterDevtools,
})),
);

export default TanStackRouterDevtools;
57 changes: 43 additions & 14 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,49 @@
version: '3.8'

services:
api:
image: ghcr.io/kaneo-app/api:latest
environment:
- JWT_ACCESS=jwt_secret_goes_here
traefik:
image: "traefik:v3.3"
container_name: "traefik"
command:
- "--providers.docker=true"
- "--entryPoints.web.address=:80"
- "--entryPoints.websecure.address=:443"
ports:
- "1337:1337"
- "80:80"
- "443:443"

networks:
- traefik-net
volumes:
- .:/app
- "/var/run/docker.sock:/var/run/docker.sock:ro"

backend:
image: ghcr.io/kaneo-app/api:latest
labels:
- "traefik.enable=true"
- "traefik.http.routers.backend.rule=Host(`demo-api.kaneo.app`)"
- "traefik.http.routers.backend.entrypoints=web"
environment:
JWT_ACCESS: "change_me"
networks:
- traefik-net
restart: unless-stopped

web:
image: ghcr.io/kaneo-app/web:latest
ports:
- "80:80"
frontend:
build:
context: .
dockerfile: ./apps/web/Dockerfile
container_name: "kaneo-web"
environment:
KANEO_API_URL: "change_me"
labels:
- "traefik.enable=true"
- "traefik.http.routers.frontend.rule=Host(`demo.kaneo.app`)"
- "traefik.http.routers.frontend.entrypoints=web"
depends_on:
- api
restart: unless-stopped
- backend
restart: unless-stopped
networks:
- traefik-net

networks:
traefik-net:
driver: bridge

0 comments on commit 74f2e46

Please sign in to comment.