Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat(deploy): add single kaneo container combining API and web

randoneering4edba3e76b03
diff --git a/.github/workflows/docker-manual.yml b/.github/workflows/docker-manual.yml
index 4f9b1eb4d..12e188334 100644
--- a/.github/workflows/docker-manual.yml
+++ b/.github/workflows/docker-manual.yml
@@ -24,6 +24,8 @@ jobs:
fail-fast: false
matrix:
include:
+ - dockerfile: ./Dockerfile.kaneo
+ image: ghcr.io/${{ github.repository_owner }}/kaneo
- dockerfile: ./apps/web/Dockerfile
image: ghcr.io/${{ github.repository_owner }}/web
- dockerfile: ./apps/api/Dockerfile
@@ -68,4 +70,4 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
- cache-to: type=gha,mode=max
\ No newline at end of file
+ cache-to: type=gha,mode=max
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index d3bab9948..3787a8575 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -24,6 +24,8 @@ jobs:
fail-fast: false
matrix:
include:
+ - dockerfile: ./Dockerfile.kaneo
+ image: ghcr.io/${{ github.repository_owner }}/kaneo
- dockerfile: ./apps/web/Dockerfile
image: ghcr.io/${{ github.repository_owner }}/web
- dockerfile: ./apps/api/Dockerfile
diff --git a/.gitignore b/.gitignore
index 3d978e52a..32b3bd997 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,4 +41,8 @@ yarn-error.log*
*.db
# Cache
-.cache/
\ No newline at end of file
+.cache/
+
+
+# Overrides
+compose.override.yml
diff --git a/Dockerfile.kaneo b/Dockerfile.kaneo
new file mode 100644
index 000000000..ace34b663
--- /dev/null
+++ b/Dockerfile.kaneo
@@ -0,0 +1,100 @@
+FROM --platform=$BUILDPLATFORM node:20.20.2-alpine AS api-builder
+
+RUN apk add --no-cache python3 make g++ && \
+ corepack enable && \
+ corepack prepare [email protected] --activate
+
+WORKDIR /app
+
+COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
+COPY packages/typescript-config/package.json ./packages/typescript-config/
+COPY packages/email/package.json ./packages/email/
+COPY packages/libs/package.json ./packages/libs/
+COPY apps/api/package.json ./apps/api/
+
+RUN pnpm install --frozen-lockfile
+
+COPY packages/typescript-config ./packages/typescript-config
+COPY packages/email ./packages/email
+COPY packages/libs ./packages/libs
+COPY apps/api ./apps/api
+
+WORKDIR /app/packages/email
+RUN pnpm run build
+
+WORKDIR /app/apps/api
+RUN sed -i 's/"extends": "@kaneo\/typescript-config\/base.json"/"extends": "..\/..\/packages\/typescript-config\/base.json"/g' /app/apps/api/tsconfig.json && \
+ pnpm run build
+
+FROM node:20.20.2-alpine AS api-runtime
+
+WORKDIR /app
+
+COPY --from=api-builder /app/package.json /app/pnpm-lock.yaml /app/pnpm-workspace.yaml ./
+COPY --from=api-builder /app/apps/api/package.json ./apps/api/
+COPY --from=api-builder /app/packages/typescript-config/package.json ./packages/typescript-config/
+COPY --from=api-builder /app/packages/libs/package.json ./packages/libs/
+COPY --from=api-builder /app/packages/email/package.json ./packages/email/
+
+RUN sed -i 's/"prepare": "husky"/"prepare": ""/g' package.json && \
+ corepack enable && \
+ corepack prepare [email protected] --activate && \
+ HUSKY=0 NODE_ENV=production pnpm install --prod --frozen-lockfile --no-optional
+
+COPY --from=api-builder /app/apps/api/dist ./apps/api/dist
+COPY --from=api-builder /app/apps/api/drizzle ./apps/api/drizzle
+COPY --from=api-builder /app/packages/email ./packages/email
+
+FROM --platform=$BUILDPLATFORM node:20.20.2-alpine AS web-builder
+
+RUN apk add --no-cache python3 make g++ && \
+ corepack enable && \
+ corepack prepare [email protected] --activate
+
+WORKDIR /app
+
+COPY pnpm-workspace.yaml pnpm-lock.yaml package.json ./
+COPY apps/web/package.json ./apps/web/
+COPY packages/typescript-config/package.json ./packages/typescript-config/
+COPY packages/libs/package.json ./packages/libs/
+
+RUN pnpm install --frozen-lockfile
+
+COPY packages/typescript-config ./packages/typescript-config
+COPY packages/libs ./packages/libs
+COPY i18n ./i18n
+COPY apps/web ./apps/web
+
+WORKDIR /app/apps/web
+RUN pnpm run build
+
+FROM node:20.20.2-alpine AS runtime
+
+RUN apk add --no-cache nginx && \
+ addgroup -g 1001 appuser && \
+ adduser -u 1001 -G appuser -D appuser && \
+ mkdir -p /app /app/apps/api/data /var/cache/nginx /var/run/nginx /var/log/nginx /var/lib/nginx/logs /var/lib/nginx/tmp /usr/share/nginx/html /docker-entrypoint.d && \
+ chown -R appuser:appuser /app /app/apps/api/data /var/cache/nginx /var/run/nginx /var/log/nginx /var/lib/nginx /usr/share/nginx/html /docker-entrypoint.d && \
+ touch /var/run/nginx.pid && \
+ chown appuser:appuser /var/run/nginx.pid && \
+ printf 'worker_processes auto;\nerror_log /var/log/nginx/error.log warn;\npid /var/run/nginx.pid;\nevents { worker_connections 1024; }\nhttp {\n include /etc/nginx/mime.types;\n default_type application/octet-stream;\n include /etc/nginx/conf.d/*.conf;\n}\n' > /etc/nginx/nginx.conf
+
+WORKDIR /app
+
+COPY --from=api-runtime --chown=appuser:appuser /app /app
+COPY --from=web-builder --chown=appuser:appuser /app/apps/web/dist /usr/share/nginx/html
+COPY --chown=appuser:appuser apps/web/nginx.kaneo.conf /etc/nginx/conf.d/default.conf
+COPY --chown=appuser:appuser apps/web/env.sh /docker-entrypoint.d/env.sh
+COPY --chown=appuser:appuser deploy/kaneo-entrypoint.sh /usr/local/bin/kaneo-entrypoint.sh
+
+RUN chmod +x /docker-entrypoint.d/env.sh /usr/local/bin/kaneo-entrypoint.sh
+
+ENV NODE_ENV=production
+
+USER appuser
+EXPOSE 5173
+
+HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
+ CMD wget --no-verbose --tries=1 --spider http://localhost:5173/api/health || exit 1
+
+CMD ["/usr/local/bin/kaneo-entrypoint.sh"]
diff --git a/README.md b/README.md
index d5e7ddafb..60991ff75 100644
--- a/README.md
+++ b/README.md
@@ -67,7 +67,7 @@ Perfect for quick deployments and production setups where you want things to jus
### Quick Start with Docker Compose
-The fastest way to try Kaneo is with Docker Compose. This sets up the API, web interface, and PostgreSQL database:
+The fastest way to try Kaneo is with Docker Compose. This sets up Kaneo and PostgreSQL with a single Kaneo container:
```yaml
services:
@@ -86,10 +86,10 @@ services:
timeout: 5s
retries: 5
- api:
- image: ghcr.io/usekaneo/api:latest
+ kaneo:
+ image: ghcr.io/usekaneo/kaneo:latest
ports:
- - "1337:1337"
+ - "5173:5173"
env_file:
- .env
depends_on:
@@ -97,21 +97,11 @@ services:
condition: service_healthy
restart: unless-stopped
- web:
- image: ghcr.io/usekaneo/web:latest
- ports:
- - "5173:5173"
- env_file:
- - .env
- depends_on:
- - api
- restart: unless-stopped
-
volumes:
postgres_data:
```
-Save this as `compose.yml`, create a `.env` file with your configuration (see the [documentation](https://kaneo.app/docs/core) for all required environment variables), run `docker compose up -d`, and open [http://localhost:5173](http://localhost:5173).
+Save this as `compose.yml`, create a `.env` file with your configuration, set `KANEO_CLIENT_URL=http://localhost:5173`, set `KANEO_API_URL=http://localhost:5173/api`, run `docker compose up -d`, and open [http://localhost:5173](http://localhost:5173).
> **Important:** See our [full documentation](https://kaneo.app/docs/core) for detailed setup instructions, environment variable configuration, and troubleshooting guides.
@@ -123,7 +113,7 @@ For development, see our [Environment Setup Guide](ENVIRONMENT_SETUP.md) for det
Kaneo requires several environment variables to be configured. The Docker Compose setup above handles the database automatically, but you'll need to configure environment variables for the API and web services.
-For complete configuration instructions, including all required environment variables, database setup for non-Docker deployments, and advanced settings, see the [documentation](https://kaneo.app/docs/core).
+For complete configuration instructions, including all required environment variables, database setup for non-Docker deployments, and advanced settings, see the [documentation](https://kaneo.app/docs/core). Advanced deployments can still use the separate `ghcr.io/usekaneo/api` and `ghcr.io/usekaneo/web` images.
## Kubernetes Deployment
diff --git a/apps/docs/core/installation/docker-compose.mdx b/apps/docs/core/installation/docker-compose.mdx
index fe74f4160..6a530cdde 100644
--- a/apps/docs/core/installation/docker-compose.mdx
+++ b/apps/docs/core/installation/docker-compose.mdx
@@ -24,10 +24,10 @@ services:
timeout: 5s
retries: 5
- api:
- image: ghcr.io/usekaneo/api:latest
+ kaneo:
+ image: ghcr.io/usekaneo/kaneo:latest
ports:
- - "1337:1337"
+ - "5173:5173"
env_file:
- .env
depends_on:
@@ -35,32 +35,32 @@ services:
condition: service_healthy
restart: unless-stopped
- web:
- image: ghcr.io/usekaneo/web:latest
- ports:
- - "5173:5173"
- env_file:
- - .env
- depends_on:
- - api
- restart: unless-stopped
-
volumes:
postgres_data:
```
## The services and volumes
-Kaneo utilities the following services:
+Kaneo uses the following services:
- `postgres`: The PostgreSQL database.
-- `api`: The API server.
-- `web`: The web application.
+- `kaneo`: The combined API and web container.
Additionally, the following volumes are used:
- `postgres_data`: The PostgreSQL data.
+## Required URL configuration
+
+For the combined image, point both URLs at the same public origin:
+
+```env
+KANEO_CLIENT_URL=http://localhost:5173
+KANEO_API_URL=http://localhost:5173/api
+```
+
+This keeps the browser on one origin while the container proxies `/api` requests to the internal API process.
+
## Notes on object storage
Kaneo uses S3-compatible object storage for private uploads in task descriptions and comments.
diff --git a/apps/web/nginx.kaneo.conf b/apps/web/nginx.kaneo.conf
new file mode 100644
index 000000000..73ba56ad7
--- /dev/null
+++ b/apps/web/nginx.kaneo.conf
@@ -0,0 +1,31 @@
+server {
+ listen 5173;
+ server_name localhost;
+
+ add_header X-Content-Type-Options "nosniff" always;
+ add_header X-Frame-Options "SAMEORIGIN" always;
+ add_header X-XSS-Protection "1; mode=block" always;
+ add_header Referrer-Policy "strict-origin-when-cross-origin" always;
+
+ gzip on;
+ gzip_vary on;
+ gzip_min_length 1000;
+ gzip_proxied any;
+ gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
+ gzip_comp_level 6;
+
+ location /api/ {
+ proxy_pass http://127.0.0.1:1337/api/;
+ proxy_http_version 1.1;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ }
+
+ location / {
+ root /usr/share/nginx/html;
+ index index.html;
+ try_files $uri $uri/ /index.html;
+ }
+}
diff --git a/compose.yml b/compose.yml
index 05bf98378..964136547 100644
--- a/compose.yml
+++ b/compose.yml
@@ -3,8 +3,6 @@ services:
image: postgres:16-alpine
env_file:
- .env
- ports:
- - "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
restart: unless-stopped
@@ -14,10 +12,10 @@ services:
timeout: 5s
retries: 5
- api:
- image: ghcr.io/usekaneo/api:latest
+ kaneo:
+ image: ghcr.io/usekaneo/kaneo:latest
ports:
- - "1337:1337"
+ - "5173:5173"
env_file:
- .env
depends_on:
@@ -25,15 +23,5 @@ services:
condition: service_healthy
restart: unless-stopped
- web:
- image: ghcr.io/usekaneo/web:latest
- ports:
- - "5173:5173"
- env_file:
- - .env
- depends_on:
- - api
- restart: unless-stopped
-
volumes:
postgres_data:
diff --git a/deploy/kaneo-entrypoint.sh b/deploy/kaneo-entrypoint.sh
new file mode 100644
index 000000000..c2aff1ae6
--- /dev/null
+++ b/deploy/kaneo-entrypoint.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+set -eu
+
+/docker-entrypoint.d/env.sh
+
+node --enable-source-maps /app/apps/api/dist/index.js &
+api_pid=$!
+
+echo "Waiting for API to be ready..."
+until wget --spider --quiet http://127.0.0.1:1337/api/health 2>/dev/null; do
+ if ! kill -0 "$api_pid" 2>/dev/null; then
+ echo "API process exited unexpectedly"
+ exit 1
+ fi
+ sleep 1
+done
+echo "API is ready"
+
+nginx -g "daemon off;" &
+nginx_pid=$!
+
+cleanup() {
+ kill "$api_pid" "$nginx_pid" 2>/dev/null || true
+}
+
+trap cleanup INT TERM
+
+while kill -0 "$api_pid" 2>/dev/null && kill -0 "$nginx_pid" 2>/dev/null; do
+ sleep 1
+done
+
+cleanup
+
+api_status=0
+nginx_status=0
+
+if ! wait "$api_pid"; then
+ api_status=$?
+fi
+
+if ! wait "$nginx_pid"; then
+ nginx_status=$?
+fi
+
+if [ "$api_status" -ne 0 ]; then
+ exit "$api_status"
+fi
+
+exit "$nginx_status"