feat: daytona ai (#1775)
Signed-off-by: Vedran <vedran.jukic@gmail.com> Signed-off-by: MDzaja <mirkodzaja0@gmail.com> Signed-off-by: Luka Brecic <luka.brecic3@gmail.com> Signed-off-by: Toma Puljak <toma.puljak@hotmail.com> Signed-off-by: fabjanvucina <fabjanvucina@gmail.com> Signed-off-by: Ivan Dagelic <dagelic.ivan@gmail.com> Signed-off-by: Goran Draganić <goran@daytona.io> Signed-off-by: Zoran Zorica <zoran.zorica@gmail.com>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
FROM buildpack-deps:jammy-curl
|
||||
|
||||
ARG TARGETARCH
|
||||
|
||||
# common tools
|
||||
RUN apt update && export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt -y install --no-install-recommends apt-utils vim htop telnet socat expect-dev tini psmisc libgit2-dev \
|
||||
python3 python3-pip
|
||||
|
||||
# build tools
|
||||
RUN apt update && export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt -y install --no-install-recommends openjdk-11-jdk protobuf-compiler libprotobuf-dev
|
||||
|
||||
# Telepresence
|
||||
RUN curl -fL https://app.getambassador.io/download/tel2oss/releases/download/v2.17.0/telepresence-linux-${TARGETARCH} -o /usr/local/bin/telepresence && \
|
||||
chmod a+x /usr/local/bin/telepresence
|
||||
|
||||
CMD ["tail", "-f", "/dev/null"]
|
||||
@@ -1,13 +1,65 @@
|
||||
{
|
||||
"name": "Daytona",
|
||||
"image": "ghcr.io/daytonaio/go-devcontainer:latest",
|
||||
"containerEnv": {
|
||||
"LOG_LEVEL": "debug",
|
||||
"DAYTONA_SERVER_MODE": "development",
|
||||
"CGO_ENABLED": "0",
|
||||
"DAYTONA_TARGET_ID": ""
|
||||
},
|
||||
"postCreateCommand": ".devcontainer/postcreate.sh",
|
||||
"postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
|
||||
"remoteUser": "daytona"
|
||||
}
|
||||
"name": "Daytona",
|
||||
"dockerComposeFile": "docker-compose.yaml",
|
||||
"service": "app",
|
||||
"workspaceFolder": "/workspaces/daytona",
|
||||
// Configure tool-specific properties.
|
||||
"containerEnv": {
|
||||
"COREPACK_ENABLE_DOWNLOAD_PROMPT": "0"
|
||||
},
|
||||
"remoteEnv": {
|
||||
"NX_DAEMON": "true",
|
||||
"NODE_ENV": "development"
|
||||
},
|
||||
"customizations": {
|
||||
// Configure properties specific to VS Code.
|
||||
"vscode": {
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
"extensions": [
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"nrwl.angular-console",
|
||||
"astro-build.astro-vscode",
|
||||
"unifiedjs.vscode-mdx",
|
||||
"timonwong.shellcheck",
|
||||
"foxundermoon.shell-format",
|
||||
"cschlosser.doxdocgen"
|
||||
],
|
||||
"settings": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
}
|
||||
}
|
||||
},
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/common-utils:2.5.3": {
|
||||
"installZsh": "true",
|
||||
"username": "daytona",
|
||||
"uid": "1000",
|
||||
"gid": "1000",
|
||||
"upgradePackages": "false"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/docker-in-docker:2.12.2": {
|
||||
"version": "24.0.7",
|
||||
"moby": false,
|
||||
"dockerDashComposeVersion": "v2"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/go:1.3.2": {
|
||||
"version": "1.23.5",
|
||||
"golangciLintVersion": "1.63.4"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/node:1.6.2": {
|
||||
"version": "22.14.0",
|
||||
"installYarnUsingApt": false
|
||||
},
|
||||
"ghcr.io/devcontainers/features/python:1": {},
|
||||
"./tools-feature": {
|
||||
"pipPackages": ["build", "twine"],
|
||||
"goTools": ["github.com/swaggo/swag/cmd/swag@v1.16.4", "github.com/mitranim/gow@latest"]
|
||||
}
|
||||
},
|
||||
"postStartCommand": "yarn",
|
||||
"postAttachCommand": "",
|
||||
"forwardPorts": [5556, "pgadmin:80", "registry-ui:5100", "maildev:1080", "minio:9000", "minio:9001"],
|
||||
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
||||
"remoteUser": "daytona"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# config.yaml
|
||||
issuer: http://localhost:5556/dex
|
||||
storage:
|
||||
type: memory
|
||||
web:
|
||||
http: 0.0.0.0:5556
|
||||
allowedOrigins: ['*']
|
||||
allowedHeaders: ['x-requested-with']
|
||||
staticClients:
|
||||
- id: daytona
|
||||
redirectURIs:
|
||||
- 'http://localhost:3000'
|
||||
- 'http://localhost:3000/api/oauth2-redirect.html'
|
||||
- 'http://localhost:3009/callback'
|
||||
name: 'Daytona'
|
||||
public: true
|
||||
enablePasswordDB: true
|
||||
staticPasswords:
|
||||
- email: 'dev@daytona.io'
|
||||
# password generated with:
|
||||
# echo password | htpasswd -BinC 10 admin | cut -d: -f2
|
||||
hash: '$2a$10$2b2cU8CPhOTaGrs1HRQuAueS7JTT5ZHsHSzYiFPm1leZck7Mc8T4W'
|
||||
username: 'admin'
|
||||
userID: '1234'
|
||||
@@ -0,0 +1,91 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
privileged: true
|
||||
volumes:
|
||||
- ..:/workspaces/daytona
|
||||
|
||||
dex:
|
||||
image: dexidp/dex:v2.42.0
|
||||
volumes:
|
||||
- ./dex/config.yaml:/etc/dex/config.yaml
|
||||
command: ['dex', 'serve', '/etc/dex/config.yaml']
|
||||
network_mode: service:app
|
||||
|
||||
db:
|
||||
image: postgres:11.9
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=pass
|
||||
- POSTGRES_USER=user
|
||||
- POSTGRES_DB=application_ctx
|
||||
|
||||
pgadmin:
|
||||
image: dpage/pgadmin4:9.2.0
|
||||
entrypoint: ['sh', '-c', 'chmod 600 /pgpass && exec /entrypoint.sh']
|
||||
environment:
|
||||
PGADMIN_DEFAULT_EMAIL: dev@daytona.io
|
||||
PGADMIN_DEFAULT_PASSWORD: pgadmin
|
||||
PGADMIN_CONFIG_SERVER_MODE: 'False'
|
||||
PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: 'False'
|
||||
user: root
|
||||
volumes:
|
||||
- ./pgadmin4/servers.json:/pgadmin4/servers.json
|
||||
- ./pgadmin4/pgpass:/pgpass
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
redis:
|
||||
image: redis:latest
|
||||
|
||||
registry-ui:
|
||||
image: joxit/docker-registry-ui:main
|
||||
restart: always
|
||||
environment:
|
||||
- SINGLE_REGISTRY=true
|
||||
- REGISTRY_TITLE=Docker Registry UI
|
||||
- DELETE_IMAGES=true
|
||||
- SHOW_CONTENT_DIGEST=true
|
||||
- NGINX_PROXY_PASS_URL=http://registry:5000
|
||||
- SHOW_CATALOG_NB_TAGS=true
|
||||
- CATALOG_MIN_BRANCHES=1
|
||||
- CATALOG_MAX_BRANCHES=1
|
||||
- TAGLIST_PAGE_SIZE=100
|
||||
- REGISTRY_SECURED=false
|
||||
- CATALOG_ELEMENTS_LIMIT=1000
|
||||
container_name: registry-ui
|
||||
|
||||
registry:
|
||||
image: registry:2.8.2
|
||||
restart: always
|
||||
environment:
|
||||
REGISTRY_HTTP_HEADERS_Access-Control-Allow-Origin: '[http://registry-ui.example.com]'
|
||||
REGISTRY_HTTP_HEADERS_Access-Control-Allow-Methods: '[HEAD,GET,OPTIONS,DELETE]'
|
||||
REGISTRY_HTTP_HEADERS_Access-Control-Allow-Credentials: '[true]'
|
||||
REGISTRY_HTTP_HEADERS_Access-Control-Allow-Headers: '[Authorization,Accept,Cache-Control]'
|
||||
REGISTRY_HTTP_HEADERS_Access-Control-Expose-Headers: '[Docker-Content-Digest]'
|
||||
REGISTRY_STORAGE_DELETE_ENABLED: 'true'
|
||||
volumes:
|
||||
- registry:/var/lib/registry
|
||||
container_name: registry
|
||||
|
||||
maildev:
|
||||
image: maildev/maildev
|
||||
|
||||
minio:
|
||||
image: minio/minio:latest
|
||||
environment:
|
||||
- MINIO_ROOT_USER=minioadmin
|
||||
- MINIO_ROOT_PASSWORD=minioadmin
|
||||
- MINIO_IDENTITY_STS_EXPIRY="24h"
|
||||
volumes:
|
||||
- minio_data:/data
|
||||
command: server /data --console-address ":9001"
|
||||
container_name: minio
|
||||
|
||||
volumes:
|
||||
registry: {}
|
||||
minio_data: {}
|
||||
@@ -0,0 +1 @@
|
||||
db:5432:*:user:pass
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"Servers": {
|
||||
"1": {
|
||||
"Name": "Daytona",
|
||||
"Group": "Servers",
|
||||
"Host": "db",
|
||||
"Port": 5432,
|
||||
"MaintenanceDB": "postgres",
|
||||
"Username": "user",
|
||||
"PassFile": "/pgpass"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
for rc in ~/.bashrc ~/.zshrc; do [ -f "$rc" ] && echo -e '\nalias dtn="DAYTONA_DEV=1 DAYTONA_CONFIG_DIR=$HOME/.config/daytona-dev go run cmd/daytona/main.go"' >> $rc; done
|
||||
|
||||
go install github.com/swaggo/swag/cmd/swag@v1.16.3
|
||||
|
||||
go mod tidy
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "Development tools",
|
||||
"id": "tools",
|
||||
"version": "1.0.0",
|
||||
"description": "Installs development tools.",
|
||||
"options": {
|
||||
"pipPackages": {
|
||||
"type": "array",
|
||||
"description": "List of pip packages to install",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"goTools": {
|
||||
"type": "array",
|
||||
"description": "List of Go tools to install",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"installsAfter": [
|
||||
"ghcr.io/devcontainers/features/go",
|
||||
"ghcr.io/devcontainers/features/python",
|
||||
"ghcr.io/devcontainers/features/docker-in-docker"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# SPDX-License-Identifier: AGPL-3.0
|
||||
|
||||
set -e
|
||||
|
||||
echo "Installing Python packages and Go tools..."
|
||||
|
||||
USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")
|
||||
for CURRENT_USER in "${POSSIBLE_USERS[@]}"; do
|
||||
if id -u "${CURRENT_USER}" > /dev/null 2>&1; then
|
||||
USERNAME=${CURRENT_USER}
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ "${USERNAME}" = "" ]; then
|
||||
USERNAME=root
|
||||
fi
|
||||
elif [ "${USERNAME}" = "none" ] || ! id -u "${USERNAME}" > /dev/null 2>&1; then
|
||||
USERNAME=root
|
||||
fi
|
||||
|
||||
export GOROOT="${TARGET_GOROOT:-"/usr/local/go"}"
|
||||
export GOPATH="${TARGET_GOPATH:-"/go"}"
|
||||
export GOCACHE=/tmp/gotools/cache
|
||||
|
||||
|
||||
sudo -E -u "${USERNAME}" bash -c '
|
||||
export PATH=$GOROOT/bin:$PATH
|
||||
export HOME=/home/${USER}
|
||||
|
||||
# Install pip packages
|
||||
if [ -n "$PIPPACKAGES" ]; then
|
||||
echo "Installing pip packages: $PIPPACKAGES"
|
||||
IFS=',' read -ra PACKAGES <<< "${PIPPACKAGES}"
|
||||
pip3 install --no-cache-dir "${PACKAGES[@]}"
|
||||
else
|
||||
echo "No pip packages specified. Skipping."
|
||||
fi
|
||||
|
||||
# Install Go tools
|
||||
if [ -n "$GOTOOLS" ]; then
|
||||
echo "Installing Go tools: $GOTOOLS"
|
||||
IFS=',' read -ra TOOLS <<< "${GOTOOLS}"
|
||||
for tool in "${TOOLS[@]}"; do
|
||||
go install $tool
|
||||
done
|
||||
else
|
||||
echo "No Go tools specified. Skipping."
|
||||
fi
|
||||
'
|
||||
|
||||
# Set insecure registry
|
||||
cat > /etc/docker/daemon.json <<EOF
|
||||
{
|
||||
"insecure-registries": ["registry:5000"]
|
||||
}
|
||||
EOF
|
||||
@@ -0,0 +1,13 @@
|
||||
# Editor configuration, see http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
||||
@@ -1 +0,0 @@
|
||||
*.sh eol=lf
|
||||
@@ -1,15 +0,0 @@
|
||||
# Each line is a file pattern followed by one or more owners.
|
||||
|
||||
# These owners will be the default owners for everything in
|
||||
# the repo. Unless a later match takes precedence,
|
||||
# @daytonaio/daytona-oss team members will be requested for
|
||||
# review when someone opens a pull request.
|
||||
* @daytonaio/daytona-oss
|
||||
|
||||
|
||||
# Owners of all documentation
|
||||
*.txt @daytonaio/operations
|
||||
*.md @daytonaio/operations
|
||||
COPYRIGHT @daytonaio/operations
|
||||
LICENSE @daytonaio/operations
|
||||
NOTICE @daytonaio/operations
|
||||
@@ -4,7 +4,6 @@ about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
@@ -12,9 +11,10 @@ A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
|
||||
1. Use these parameters '...'
|
||||
2. Click on '...'
|
||||
3. Execute the following command '...'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
@@ -23,9 +23,10 @@ A clear and concise description of what you expected to happen.
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. Ubuntu 22.04]
|
||||
- Daytona Version: [e.g. v0.0.1]
|
||||
**Environment (required fields):**
|
||||
|
||||
- Deployment: [Production/OSS/Staging]
|
||||
- Daytona client: [e.g. Python SDK v0.0.1 or Daytona CLI v0.0.1]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
|
||||
@@ -4,7 +4,6 @@ about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
|
||||
@@ -12,7 +12,9 @@ Please include a summary of the change or the feature being introduced. Include
|
||||
This PR addresses issue #X
|
||||
|
||||
## Screenshots
|
||||
|
||||
If relevant, please add screenshots.
|
||||
|
||||
## Notes
|
||||
|
||||
Please add any relevant notes if necessary.
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
name: "[PR] Validate build"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
# New commit on branch cancels running workflows of the same branch
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
binary-build:
|
||||
strategy:
|
||||
matrix:
|
||||
goos: [linux, darwin, windows]
|
||||
goarch: [amd64, arm64]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
- name: Build binaries
|
||||
run: |
|
||||
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_ENABLED=0 go build cmd/daytona/main.go
|
||||
@@ -1,17 +0,0 @@
|
||||
name: '[PR] License Check'
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
license-check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Check License Header
|
||||
uses: apache/skywalking-eyes/header@main
|
||||
with:
|
||||
token: ${{ github.token }}
|
||||
mode: 'check'
|
||||
@@ -1,65 +0,0 @@
|
||||
name: '[PR] Lint'
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
golangci:
|
||||
name: lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: false
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v4
|
||||
with:
|
||||
version: latest
|
||||
args: --timeout=5m ./...
|
||||
fmt-and-swagger:
|
||||
name: fmt-and-swagger
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- name: fmt-and-swagger
|
||||
run: |
|
||||
go install github.com/swaggo/swag/cmd/swag@v1.16.3
|
||||
./hack/swagger.sh
|
||||
git diff --exit-code pkg/apiclient/* || (echo "API clients are out of sync! Please generate with './hack/swagger.sh' and commit" && exit 1)
|
||||
git diff --exit-code '**/*.go' || (echo "Code is not formatted! Please run 'go fmt ./...' and commit" && exit 1)
|
||||
cli-docs:
|
||||
name: cli-docs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- name: cli-docs
|
||||
run: |
|
||||
./hack/generate-cli-docs.sh
|
||||
git diff --exit-code docs/* || (echo "CLI Documentation is out of sync! Please generate it with './hack/generate-cli-docs.sh' and commit" && exit 1)
|
||||
git diff --exit-code hack/docs/* || (echo "CLI Documentation is out of sync! Please generate it with './hack/generate-cli-docs.sh' and commit" && exit 1)
|
||||
test:
|
||||
name: Unit tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: false
|
||||
- run: go build -tags testing ./...
|
||||
- uses: robherley/go-test-action@v0
|
||||
with:
|
||||
testArguments: -tags testing ./...
|
||||
omit: untested
|
||||
@@ -0,0 +1,96 @@
|
||||
name: '[PR] Validate code'
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
# New commit on branch cancels running workflows of the same branch
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
golangci:
|
||||
name: Go lint
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
working-directory: [apps/daemon, apps/runner, apps/cli]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.work
|
||||
cache: false
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v4
|
||||
with:
|
||||
version: latest
|
||||
working-directory: ${{ matrix.working-directory }}
|
||||
args: --timeout=5m ./...
|
||||
- name: format
|
||||
run: |
|
||||
cd ${{ matrix.working-directory }}
|
||||
go fmt ./...
|
||||
git diff --exit-code '**/*.go' || (echo "Code is not formatted! Please run 'go fmt ./...' and commit" && exit 1)
|
||||
|
||||
format-lint-api-clients:
|
||||
name: Format, lint and generate API clients
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.work
|
||||
cache: true
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 21
|
||||
distribution: 'temurin'
|
||||
- run: corepack enable
|
||||
- name: generate-api-clients
|
||||
run: |
|
||||
go install github.com/swaggo/swag/cmd/swag@v1.16.4
|
||||
echo -e 'NX_PACKAGE_PUBLISH_VERSION=0.0.0-dev' > .env
|
||||
yarn
|
||||
mkdir -p dist/apps/api
|
||||
yarn generate:openapi && yarn nx run-many --target=generate:api-client --all --parallel=false
|
||||
yarn lint:fix
|
||||
yarn format
|
||||
git diff --exit-code || (echo "Code not formatted or linting errors! Hint: 'yarn generate:api-client', 'yarn lint:fix' and commit" && exit 1)
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.work
|
||||
cache: true
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
- run: corepack enable
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
- name: Build all
|
||||
run: |
|
||||
python3 -m pip install build twine
|
||||
yarn
|
||||
yarn build
|
||||
|
||||
license-check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Check License Header
|
||||
uses: apache/skywalking-eyes/header@main
|
||||
with:
|
||||
token: ${{ github.token }}
|
||||
mode: 'check'
|
||||
@@ -1,27 +0,0 @@
|
||||
name: Trigger External Workflow on Release
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
trigger-external-workflow:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Trigger release workflow
|
||||
if: github.event.release.prerelease == false
|
||||
uses: peter-evans/repository-dispatch@v3
|
||||
with:
|
||||
token: ${{ secrets.GITHUBBOT_TOKEN }}
|
||||
repository: daytonaio/daytona-release
|
||||
event-type: new-release
|
||||
client-payload: '{"release_tag": "${{ github.event.release.tag_name }}"}'
|
||||
|
||||
- name: Trigger prerelease workflow
|
||||
if: github.event.release.prerelease == true
|
||||
uses: peter-evans/repository-dispatch@v3
|
||||
with:
|
||||
token: ${{ secrets.GITHUBBOT_TOKEN }}
|
||||
repository: daytonaio/daytona-release
|
||||
event-type: new-prerelease
|
||||
client-payload: '{"prerelease_tag": "${{ github.event.release.tag_name }}"}'
|
||||
@@ -1,26 +0,0 @@
|
||||
name: '[Support] Stale-And-Close Inactive Issues And PRs'
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 1 * * *'
|
||||
# Remove all permissions by default. Actions are performed by Daytona Bot
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
if: github.repository == 'daytonaio/daytona'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# This step will add the stale comment and label for the first 15 days without activity. It won't close any task
|
||||
- uses: actions/stale@v5
|
||||
with:
|
||||
stale-issue-message: 'This Issue has been automatically marked as "stale" because it has not had recent activity (for 14 days). It will be closed if no further activity occurs. Thanks for the feedback.'
|
||||
stale-pr-message: 'This Pull Request has been automatically marked as "stale" because it has not had recent activity (for 14 days). It will be closed if no further activity occurs. Thank you for your contribution.'
|
||||
close-issue-message: 'Due to the lack of activity in the last 7 days since it was marked as "stale", we are closing this Issue. Do not hesitate to reopen it later if necessary.'
|
||||
close-pr-message: 'Due to the lack of activity in the last 7 days since it was marked as "stale", we are closing this Pull Request. Do not hesitate to reopen it later if necessary.'
|
||||
days-before-stale: 14
|
||||
days-before-close: 7
|
||||
exempt-issue-labels: on-hold,never stale,enhancement
|
||||
exempt-pr-labels: on-hold,never stale,enhancement
|
||||
operations-per-run: 100
|
||||
repo-token: ${{ secrets.GITHUBBOT_TOKEN }}
|
||||
+55
-6
@@ -1,11 +1,60 @@
|
||||
/build
|
||||
DEV_WORKSPACES
|
||||
./daytona
|
||||
.DS_Store
|
||||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# compiled output
|
||||
dist
|
||||
tmp
|
||||
out-tsc
|
||||
|
||||
# dependencies
|
||||
node_modules
|
||||
|
||||
*.exe
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
.cursor
|
||||
|
||||
main
|
||||
# IDE - VSCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
|
||||
# misc
|
||||
/.sass-cache
|
||||
/connect.lock
|
||||
/coverage
|
||||
/libpeerconnection.log
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
testem.log
|
||||
/typings
|
||||
|
||||
# System Files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
.nx/cache
|
||||
.nx/workspace-data
|
||||
|
||||
vite.config.*.timestamp*
|
||||
vitest.config.*.timestamp*
|
||||
|
||||
# yarn
|
||||
# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
|
||||
.pnp.*
|
||||
.yarn/*
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
|
||||
.eslintcache
|
||||
.tmp/
|
||||
.env.local
|
||||
|
||||
+2
-1
@@ -2,10 +2,11 @@ linters-settings:
|
||||
errcheck:
|
||||
exclude-functions:
|
||||
- (*github.com/gin-gonic/gin.Context).AbortWithError
|
||||
- (*github.com/gin-gonic/gin.Context).Error
|
||||
- io.Copy
|
||||
- syscall.Syscall
|
||||
- (github.com/gliderlabs/ssh.Session).Exit
|
||||
- (io.Writer).Write
|
||||
run:
|
||||
build-tags:
|
||||
- testing
|
||||
- testing
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
_
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
yarn lint-staged
|
||||
+13
-8
@@ -1,17 +1,22 @@
|
||||
header:
|
||||
license:
|
||||
spdx-id: Apache-2.0
|
||||
spdx-id: AGPL-3.0
|
||||
copyright-owner: Daytona Platforms Inc.
|
||||
content: |
|
||||
Copyright 2024 Daytona Platforms Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
Copyright 2025 Daytona Platforms Inc.
|
||||
SPDX-License-Identifier: AGPL-3.0
|
||||
paths:
|
||||
- "**/*.go"
|
||||
- "**/*.sh"
|
||||
- '**/*.go'
|
||||
- '**/*.sh'
|
||||
- '**/*.ts'
|
||||
- '**/*.py'
|
||||
|
||||
paths-ignore:
|
||||
- "**/apiclient/**"
|
||||
- "**/pkg/api/docs/docs.go"
|
||||
- ".devcontainer/postcreate.sh"
|
||||
- 'libs/api-client/**'
|
||||
- 'libs/runner-api-client/**'
|
||||
- 'libs/api-client-go/**'
|
||||
- 'libs/api-client-python/**'
|
||||
- 'apps/api/src/generate-openapi.ts'
|
||||
- 'apps/runner/pkg/api/docs/docs.go'
|
||||
|
||||
comment: on-failure
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/24eb4dce508ab81398d14d75179123fca425f12d/schema/markdownlint-cli2-config-schema.json",
|
||||
"config": {
|
||||
"no-emphasis-as-heading": false,
|
||||
"line-length": false,
|
||||
"no-inline-html": false,
|
||||
"first-line-h1": false,
|
||||
"no-bare-urls": false,
|
||||
"no-duplicate-heading": false,
|
||||
"emphasis-style": {
|
||||
"style": "underscore",
|
||||
},
|
||||
"ol-prefix": false,
|
||||
"fenced-code-language": false,
|
||||
"single-title": false,
|
||||
"heading-increment": false,
|
||||
"table-column-count": false,
|
||||
"table-pipe-style": false,
|
||||
"no-empty-links": false,
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Add files here to ignore them from prettier formatting
|
||||
/dist
|
||||
/coverage
|
||||
/.nx/cache
|
||||
/.nx/workspace-data
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"semi": false,
|
||||
"tabWidth": 2,
|
||||
"printWidth": 120
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
# path to a directory with all packages
|
||||
storage: ../tmp/local-registry/storage
|
||||
|
||||
# a list of other known repositories we can talk to
|
||||
uplinks:
|
||||
npmjs:
|
||||
url: https://registry.npmjs.org/
|
||||
maxage: 60m
|
||||
|
||||
packages:
|
||||
'**':
|
||||
# give all users (including non-authenticated users) full access
|
||||
# because it is a local registry
|
||||
access: $all
|
||||
publish: $all
|
||||
unpublish: $all
|
||||
|
||||
# if package is not available locally, proxy requests to npm registry
|
||||
proxy: npmjs
|
||||
|
||||
# log settings
|
||||
log:
|
||||
type: stdout
|
||||
format: pretty
|
||||
level: warn
|
||||
|
||||
publish:
|
||||
allow_offline: true # set offline to true to allow publish offline
|
||||
Vendored
+19
-51
@@ -5,67 +5,35 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "agent",
|
||||
"type": "go",
|
||||
"command": "yarn serve",
|
||||
"name": "Debug",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"program": "${workspaceFolder}/cmd/daytona",
|
||||
"console": "integratedTerminal",
|
||||
"env": {
|
||||
"DAYTONA_TARGET_ID": "TARGET_ID",
|
||||
"DAYTONA_WORKSPACE_ID": "WORKSPACE_ID",
|
||||
"DAYTONA_SERVER_URL": "http://localhost:3986",
|
||||
"DAYTONA_SERVER_API_KEY": "1234567890",
|
||||
},
|
||||
"args": [
|
||||
"agent"
|
||||
]
|
||||
"type": "node-terminal"
|
||||
},
|
||||
{
|
||||
"name": "Server",
|
||||
"type": "go",
|
||||
"command": "yarn serve:skip-runner",
|
||||
"name": "Debug - Skip Runner",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"program": "${workspaceFolder}/cmd/daytona",
|
||||
"console": "integratedTerminal",
|
||||
"args": [
|
||||
"serve"
|
||||
],
|
||||
"env": {
|
||||
"DAYTONA_DEV": "1",
|
||||
"DAYTONA_CONFIG_DIR": "/home/daytona/.config/daytona-dev",
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "CLI Create",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"program": "${workspaceFolder}/cmd/daytona",
|
||||
"console": "integratedTerminal",
|
||||
"args": [
|
||||
"create"
|
||||
],
|
||||
"env": {
|
||||
"DAYTONA_DEV": "1",
|
||||
"DAYTONA_CONFIG_DIR": "/home/daytona/.config/daytona-dev",
|
||||
}
|
||||
"type": "node-terminal"
|
||||
},
|
||||
{
|
||||
"name": "Runner",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"program": "${workspaceFolder}/cmd/daytona",
|
||||
"program": "${workspaceFolder}/apps/runner/cmd/runner",
|
||||
"console": "integratedTerminal",
|
||||
"args": [
|
||||
"runner",
|
||||
"serve"
|
||||
],
|
||||
"env": {
|
||||
"DAYTONA_DEV": "1",
|
||||
"DAYTONA_RUNNER_CONFIG_DIR": "/home/daytona/.config/daytona-runner",
|
||||
}
|
||||
"envFile": "${workspaceFolder}/apps/runner/.env",
|
||||
"output": "${workspaceFolder}/dist/apps/runner"
|
||||
},
|
||||
{
|
||||
"name": "Daemon",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"program": "${workspaceFolder}/apps/daemon/cmd/daemon",
|
||||
"console": "integratedTerminal",
|
||||
"output": "${workspaceFolder}/dist/apps/daemon"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"gopls": {
|
||||
"build.buildFlags": [
|
||||
"-tags",
|
||||
"testing"
|
||||
]
|
||||
},
|
||||
"go.testTags": "testing"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
enableInlineHunks: true
|
||||
|
||||
nodeLinker: node-modules
|
||||
+1
-3
@@ -85,9 +85,7 @@ While working on a PR, if you see something that can be refactored to comply, go
|
||||
API and service method conventions:
|
||||
|
||||
1. Avoid using model names in service methods
|
||||
- e.g. `Create` instead of `CreateTarget`, `Find` instead of `FindWorkspace`
|
||||
1. Use model names in service methods for "sub-models"
|
||||
- e.g. `ListPrebuilds` in `WorkspaceTemplateService`
|
||||
- e.g. `Create` instead of `CreateWorkspace`, `Find` instead of `FindWorkspace`
|
||||
1. Use appropriate verbs in the UI
|
||||
- e.g. `Create API Key` instead of `Generate API Key` since the method is called `Create`
|
||||
1. Refer to the table below for a connection between API and service methods
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
# Contributors
|
||||
|
||||
We contributors to Daytona:
|
||||
|
||||
* License all our contributions to the project under the Apache License, Version 2.0
|
||||
* Have the legal rights to license our contributions ourselves, or get permission to license them from our employers, clients, or others who may have them
|
||||
* Signoff on our commits with the Developer Certificate of Origin (DCO) Version 1.1 (https://developercertificate.org/)
|
||||
* Previously we added our names and GitHub handles to this CONTRIBUTORS.md file. We leave these names here to record the commits that came before.
|
||||
|
||||
-----------
|
||||
* Vedran Jukic (@vedranjukic)
|
||||
* Ivan Burazin (@ivan-burazin)
|
||||
* Chad Metcalf (@metcalfc)
|
||||
* Toma Puljak (@tpuljak)
|
||||
* Nikola Balic (@nkkko)
|
||||
* Goran Draganic (@gdraganic)
|
||||
* Ivan Dagelić (@idagelic)
|
||||
* Fabjan Vučina (@fabjanvucina)
|
||||
* Rutik Thakre (@Rutik7066, @rutikt7066)
|
||||
* Neo (@neo773)
|
||||
* Ezhil Shanmugham (@ezhil56x)
|
||||
* Tarun Chauhan (@tarunrajput)
|
||||
* Deepak gupta (@guptadeepak8)
|
||||
* Vineeth Kumar (@vineeth-vk11)
|
||||
* Jay Kumar (@35C4n0r)
|
||||
* Twac (@Twacqwq)
|
||||
* Mirko Dzaja (@MDzaja)
|
||||
* Luke Bryant (@LDavidBryant)
|
||||
* Marijan Cipcic (@marijancip123)
|
||||
* Sara Lucija Dragicevic (@saralucijad)
|
||||
* Ante Projić (@aprojic)
|
||||
* Bruno Grbavac (@brunogrbavac)
|
||||
* Juraj Štefanić (@stefanicjuraj)
|
||||
* Ivan Kunjasic (@IvanKunjasic)
|
||||
* Mo Jaafar (@mojafa)
|
||||
* Ivan Novak (@inovak)
|
||||
* Nikola Radisic (@radisicc)
|
||||
* Andre Johnson (@andrejohnson2)
|
||||
@@ -1,201 +1,661 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
1. Definitions.
|
||||
Preamble
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
0. Definitions.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
1. Source Code.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
2. Basic Permissions.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
@@ -1,72 +0,0 @@
|
||||
# Default values
|
||||
VERSION ?= v0.0.0-dev
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
DAYTONA_CONFIG_DIR ?= $(APPDATA)/daytona
|
||||
else
|
||||
DAYTONA_CONFIG_DIR ?= $(HOME)/.config/daytona
|
||||
endif
|
||||
|
||||
OUTPUT_DIR ?= $(DAYTONA_CONFIG_DIR)/server/binaries/$(VERSION)
|
||||
|
||||
# Supported OSs and ARCHs
|
||||
OS_LIST := darwin linux windows
|
||||
ARCH_LIST := amd64 arm64
|
||||
|
||||
# Infer ARCH if not provided
|
||||
ifeq ($(ARCH),)
|
||||
UNAME_M := $(shell uname -m)
|
||||
ifeq ($(findstring $(UNAME_M),x86_64 AMD64),$(UNAME_M))
|
||||
ARCH := amd64
|
||||
else ifeq ($(findstring $(UNAME_M),arm64 ARM64 aarch64),$(UNAME_M))
|
||||
ARCH := arm64
|
||||
else
|
||||
$(error Unable to infer ARCH from $(UNAME_M), please specify manually)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Default target
|
||||
all: build-all
|
||||
|
||||
# Build for all OS and ARCH combinations
|
||||
build-all:
|
||||
@for os in $(OS_LIST); do \
|
||||
for arch in $(ARCH_LIST); do \
|
||||
$(MAKE) build OS=$$os ARCH=$$arch; \
|
||||
done; \
|
||||
done
|
||||
|
||||
# Build for a specific OS and ARCH
|
||||
build:
|
||||
@if [ -z "$(OS)" ]; then \
|
||||
echo "Error: OS must be specified."; \
|
||||
echo "Usage: make build OS=<os> [ARCH=<arch>]"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@echo "Building for $(OS)-$(ARCH)"
|
||||
@mkdir -p $(OUTPUT_DIR)
|
||||
@GOOS=$(OS) GOARCH=$(ARCH) go build -o $(OUTPUT_DIR)/daytona-$(OS)-$(ARCH)$(if $(filter windows,$(OS)),.exe) cmd/daytona/main.go
|
||||
|
||||
# Clean build artifacts
|
||||
clean:
|
||||
@rm -rf $(OUTPUT_DIR)
|
||||
|
||||
# Help target
|
||||
help:
|
||||
@sh -c '\
|
||||
echo "Available targets:"; \
|
||||
echo " make : Build for all supported OS and ARCH combinations"; \
|
||||
echo " make build OS=<os> [ARCH=<arch>] : Build for a specific OS and ARCH"; \
|
||||
echo " make clean : Remove build artifacts"; \
|
||||
echo ""; \
|
||||
echo "Supported OS : $(OS_LIST)"; \
|
||||
echo "Supported ARCH: $(ARCH_LIST)"; \
|
||||
echo ""; \
|
||||
echo "Environment variables:"; \
|
||||
echo " VERSION : Set the version (default: v0.0.0-dev)"; \
|
||||
echo " DAYTONA_CONFIG_DIR: Set the config directory (default: ~/.config/daytona)"; \
|
||||
echo " OUTPUT_DIR : Override the output directory"; \
|
||||
echo ""; \
|
||||
echo "Note: If ARCH is not specified, it will be inferred from the current machine."'
|
||||
|
||||
.PHONY: all build-all build clean help
|
||||
@@ -2,4 +2,4 @@ Daytona
|
||||
Copyright the various Daytona software authors.
|
||||
|
||||
The initial developer of the software is Daytona Platforms, Inc. (https://daytona.io).
|
||||
Copyright 2024 Daytona Platforms, Inc. All Rights Reserved.
|
||||
Copyright 2025 Daytona Platforms, Inc. All Rights Reserved.
|
||||
|
||||
+1
-1
@@ -32,4 +32,4 @@ While we encourage packaging and distribution of our open-source project, we hav
|
||||
|
||||
If you have any questions about packaging Daytona or need clarification on these guidelines, especially regarding naming conventions, please open an issue in our GitHub repository.
|
||||
|
||||
We appreciate your contribution to making Daytona more accessible to users across different platforms, while respecting our project's identity!
|
||||
We appreciate your contribution to making Daytona more accessible to users across different platforms, while respecting our project's identity!
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div align="center">
|
||||
|
||||
[](https://www.daytona.io/docs)
|
||||
[](#license)
|
||||

|
||||
[](https://goreportcard.com/report/github.com/daytonaio/daytona)
|
||||
[](https://github.com/daytonaio/daytona/issues)
|
||||

|
||||
@@ -19,140 +19,115 @@
|
||||
</div>
|
||||
|
||||
<h3 align="center">
|
||||
Set up a development environment on any infrastructure using a single command:
|
||||
Run AI Code.
|
||||
<br/>
|
||||
Secure and Elastic Infrastructure for
|
||||
Running Your AI-Generated Code.
|
||||
</h3>
|
||||
|
||||
<div style="width: 80%; margin: 0 auto;">
|
||||
|
||||

|
||||
|
||||
</div>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://www.daytona.io/docs"> Documentation </a>·
|
||||
<a href="https://github.com/daytonaio/daytona/issues/new?assignees=&labels=bug&projects=&template=bug_report.md&title=%F0%9F%90%9B+Bug+Report%3A+"> Report Bug </a>·
|
||||
<a href="https://github.com/daytonaio/daytona/issues/new?assignees=&labels=enhancement&projects=&template=feature_request.md&title=%F0%9F%9A%80+Feature%3A+"> Request Feature </a>·
|
||||
<a href="https://go.daytona.io/slack"> Join Our Slack </a>·
|
||||
<a href="https://x.com/daytonaio"> Connect On X </a>
|
||||
<a href="https://go.daytona.io/slack"> Join our Slack </a>·
|
||||
<a href="https://x.com/daytonaio"> Connect on X </a>
|
||||
</p>
|
||||
|
||||
<div align="center">
|
||||
---
|
||||
|
||||
# Open Source Development Environment Manager
|
||||
</div>
|
||||
## Installation
|
||||
|
||||
For detailed/manual setup steps click [here](https://www.daytona.io/docs/installation/installation/#installation)
|
||||
|
||||
### Mac / Linux
|
||||
### Python SDK
|
||||
|
||||
```bash
|
||||
curl -sfL get.daytona.io | sudo bash && daytona server -y && daytona
|
||||
pip install daytona-sdk
|
||||
```
|
||||
|
||||
### Windows
|
||||
|
||||
```pwsh
|
||||
powershell -Command "irm https://get.daytona.io/windows | iex; daytona serve"
|
||||
```
|
||||
|
||||
### Create your first dev environment by opening a new terminal, and running:
|
||||
### TypeScript SDK
|
||||
|
||||
```bash
|
||||
daytona create
|
||||
npm install @daytonaio/sdk
|
||||
```
|
||||
|
||||
**Start coding.**
|
||||
|
||||
---
|
||||
|
||||
## Features
|
||||
|
||||
- **Quick Setup**: Activate a fully configured development environment with a single command - `daytona create`.
|
||||
- **Runs everywhere**: Spin up your development environment on any machine; local, remote, cloud-based, physical server or a VM & on any architecture; x86 or ARM.
|
||||
- **Various Providers Support**: Choose popular providers like AWS, GCP, Azure, DigitalOcean & [more](https://github.com/orgs/daytonaio/repositories?q=daytona-provider) or use Docker on bare metal.
|
||||
- **IDE Support** : Seamlessly supports [VS Code](https://github.com/microsoft/vscode), [JetBrains](https://www.jetbrains.com/remote-development/gateway/) products and more, ready to use without configuration. Also includes a built-in Web IDE for convenience.
|
||||
- **Git Provider Integration**: GitHub, GitLab, Bitbucket and [other](https://www.daytona.io/docs/configuration/git-providers/#add-a-git-provider) Git providers can be connected allowing you to start working on a specific branch or PR and to push changes immediately.
|
||||
- **Configuration File Support**: Support for [dev container](https://containers.dev/) and an upcoming expansion to DevFile, Nix & Flox.
|
||||
- **Prebuilds System**: Drastically improve environment build times by prebuilding them based on Git Providers' hook events.
|
||||
- **Reverse Proxy Integration**: Enable collaboration and streamline feedback loops by leveraging our reverse proxy. Access preview ports and the Web IDE seamlessly, even behind firewalls.
|
||||
- **Security**: Automatically creates a VPN connection between the client machine and the development environment, ensuring a fully secure connection.
|
||||
- **Works on my Machine**: Never experience it again.
|
||||
|
||||
*For a complete feature set including Authentication, Authorization, Observability, Resource Management and IDP, check out our [enterprise offering](https://daytona.zapier.app/).
|
||||
- **Lightning-Fast Infrastructure**: Sub-90ms Sandbox creation from code to execution.
|
||||
- **Separated & Isolated Runtime**: Execute AI-generated code with zero risk to your infrastructure.
|
||||
- **Massive Parallelization for Concurrent AI Workflows**: Fork Sandbox filesystem and memory state (Coming soon!)
|
||||
- **Programmatic Control**: File, Git, LSP, and Execute API
|
||||
- **Unlimited Persistence**: Your Sandboxes can live forever
|
||||
- **OCI/Docker Compatibility**: Use any OCI/Docker image to create a Sandbox
|
||||
|
||||
---
|
||||
|
||||
## Getting Started
|
||||
## Quick Start
|
||||
|
||||
### Requirements
|
||||
1. Create an account at https://app.daytona.io
|
||||
1. Generate a [new API key](https://app.daytona.io/dashboard/keys)
|
||||
1. Follow the [Getting Started docs](https://www.daytona.io/docs/getting-started/) to start using the Daytona SDK
|
||||
|
||||
Before starting the installation script, if developing locally, ensure [Docker](https://www.docker.com/products/docker-desktop/) is installed and running.
|
||||
## Creating your first Sandbox
|
||||
|
||||
### Initializing Daytona
|
||||
### Python SDK
|
||||
|
||||
To initialize Daytona, follow these steps:
|
||||
```py
|
||||
from daytona_sdk import Daytona, DaytonaConfig, CreateSandboxParams
|
||||
|
||||
**1. Start the Daytona Server:**
|
||||
Use this command to initiate the Daytona Server in daemon mode or use `daytona serve` to run it in the foreground:
|
||||
# Initialize the Daytona client
|
||||
daytona = Daytona(DaytonaConfig(api_key="YOUR_API_KEY"))
|
||||
|
||||
```bash
|
||||
daytona server
|
||||
# Create the Sandbox instance
|
||||
sandbox = daytona.create(CreateSandboxParams(language="python"))
|
||||
|
||||
# Run code securely inside the Sandbox
|
||||
response = sandbox.process.code_run('print("Sum of 3 and 4 is " + str(3 + 4))')
|
||||
if response.exit_code != 0:
|
||||
print(f"Error running code: {response.exit_code} {response.result}")
|
||||
else:
|
||||
print(response.result)
|
||||
|
||||
# Clean up the Sandbox
|
||||
daytona.remove(sandbox)
|
||||
```
|
||||
|
||||
**2. Register Your Git Provider of Choice:**
|
||||
Daytona supports GitHub, GitLab, Bitbucket and [more](https://www.daytona.io/docs/configuration/git-providers/#add-a-git-provider) Git Providers. Use this command to set them up:
|
||||
### Typescript SDK
|
||||
|
||||
```bash
|
||||
daytona git-provider create
|
||||
```
|
||||
```jsx
|
||||
import { Daytona } from '@daytonaio/sdk'
|
||||
|
||||
**3. Create Your First Target:** (optional)
|
||||
By default, Daytona uses the Docker provider to spin up environments on your local machine. For remote development environment setups, use the following command:
|
||||
async function main() {
|
||||
// Initialize the Daytona client
|
||||
const daytona = new Daytona({
|
||||
apiKey: 'YOUR_API_KEY',
|
||||
})
|
||||
|
||||
```bash"
|
||||
daytona target create
|
||||
```
|
||||
let sandbox
|
||||
try {
|
||||
// Create the Sandbox instance
|
||||
sandbox = await daytona.create({
|
||||
language: 'python',
|
||||
})
|
||||
// Run code securely inside the Sandbox
|
||||
const response = await sandbox.process.codeRun('print("Sum of 3 and 4 is " + str(3 + 4))')
|
||||
if (response.exitCode !== 0) {
|
||||
console.error('Error running code:', response.exitCode, response.result)
|
||||
} else {
|
||||
console.log(response.result)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Sandbox flow error:', error)
|
||||
} finally {
|
||||
if (sandbox) await daytona.remove(sandbox)
|
||||
}
|
||||
}
|
||||
|
||||
**4. Choose Your IDE:**
|
||||
The default IDE for Daytona is the local VS Code installation. To switch to the Web IDE or any other IDE, use:
|
||||
|
||||
```bash
|
||||
daytona ide
|
||||
```
|
||||
|
||||
Now that you have installed and initialized Daytona, you may proceed to setting up your development environments and starting to code instantly.
|
||||
|
||||
**4. Create Your First Daytona Development Environment:**
|
||||
|
||||
Creating development environments with Daytona is a straightforward process accomplished with just one command which prompts you for two things:
|
||||
|
||||
1. Choose the target/provider to decide where to create the dev environment.
|
||||
2. Select or type in the Git repository you wish to start off with.
|
||||
|
||||
After making your selections, press enter, and Daytona will handle the rest.
|
||||
|
||||
```bash
|
||||
daytona create
|
||||
```
|
||||
|
||||
*You can add the `--no-ide` flag to skip opening the IDE and then use `daytona code` once you're ready to start coding. More info [here](https://www.daytona.io/docs/about/getting-started/).
|
||||
|
||||
**5. Manage the Daytona Server daemon:**
|
||||
|
||||
```bash
|
||||
daytona server [start|stop|restart]
|
||||
main().catch(console.error)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Extend Daytona Through Providers
|
||||
|
||||
Daytona is designed to be infrastructure-agnostic, capable of creating and managing development environments across various platforms. Providers are the components that encapsulate the logic for provisioning compute resources on a specific platform. They allow for the configuration of different target configurations thus enabling, for instance, multiple AWS profiles within an AWS provider.
|
||||
|
||||
How does it work? When executing the `daytona create` command, Daytona communicates the environment details to the selected provider, which then provisions the necessary compute resources. Once provisioned, Daytona sets up the environment on these resources, allowing the user to interact with the environment seamlessly.
|
||||
|
||||
Providers are independent projects that adhere to the Daytona Provider interface. View all currently supported providers [here](https://github.com/orgs/daytonaio/repositories?q=daytona-provider).
|
||||
|
||||
## Contributing
|
||||
|
||||
Daytona is Open Source under the [Apache License 2.0](LICENSE), and is the [copyright of its contributors](NOTICE). If you would like to contribute to the software, read the Developer Certificate of Origin Version 1.1 (https://developercertificate.org/). Afterwards, navigate to the [contributing guide](CONTRIBUTING.md) to get started.
|
||||
Daytona is Open Source under the [GNU GENERAL PUBLIC LICENSE](LICENSE), and is the [copyright of its contributors](NOTICE). If you would like to contribute to the software, read the Developer Certificate of Origin Version 1.1 (https://developercertificate.org/). Afterwards, navigate to the [contributing guide](CONTRIBUTING.md) to get started.
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
PORT=3001
|
||||
|
||||
DB_HOST=db
|
||||
DB_PORT=5432
|
||||
DB_USERNAME=user
|
||||
DB_PASSWORD=pass
|
||||
DB_DATABASE=application_ctx
|
||||
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
||||
|
||||
OIDC_CLIENT_ID=daytona
|
||||
OIDC_ISSUER_BASE_URL=http://localhost:5556/dex
|
||||
OIDC_AUDIENCE=daytona
|
||||
|
||||
DEFAULT_IMAGE=ubuntu:22.04
|
||||
DASHBOARD_URL=http://localhost:3000
|
||||
|
||||
POSTHOG_API_KEY=
|
||||
POSTHOG_HOST=
|
||||
|
||||
TRANSIENT_REGISTRY_URL=http://localhost:5000
|
||||
TRANSIENT_REGISTRY_ADMIN=admin
|
||||
TRANSIENT_REGISTRY_PASSWORD=password
|
||||
TRANSIENT_REGISTRY_PROJECT_ID=daytona
|
||||
|
||||
INTERNAL_REGISTRY_URL=http://localhost:5000
|
||||
INTERNAL_REGISTRY_ADMIN=admin
|
||||
INTERNAL_REGISTRY_PASSWORD=password
|
||||
INTERNAL_REGISTRY_PROJECT_ID=daytona
|
||||
|
||||
SMTP_HOST=maildev
|
||||
SMTP_PORT=1025
|
||||
SMTP_USER=
|
||||
SMTP_PASSWORD=
|
||||
SMTP_SECURE=
|
||||
EMAIL_FROM="Daytona Team <no-reply@daytona.io>"
|
||||
|
||||
S3_ENDPOINT=http://minio:9000
|
||||
S3_REGION=us-east-1
|
||||
S3_ACCESS_KEY=minioadmin
|
||||
S3_SECRET_KEY=minioadmin
|
||||
S3_DEFAULT_BUCKET=daytona
|
||||
|
||||
ENVIRONMENT=dev
|
||||
@@ -0,0 +1,9 @@
|
||||
# This file is generated by Nx.
|
||||
#
|
||||
# Build the docker image with `npx nx docker-build daytona`.
|
||||
# Tip: Modify "docker-build" options in project.json to change docker build args.
|
||||
#
|
||||
# Run the container with `docker run -p 3000:3000 -t daytona`.
|
||||
FROM docker.io/node:lts-alpine
|
||||
|
||||
TODO
|
||||
@@ -0,0 +1,3 @@
|
||||
import baseConfig from '../../eslint.config.mjs'
|
||||
|
||||
export default [...baseConfig]
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
export default {
|
||||
displayName: 'daytona',
|
||||
preset: '../../jest.preset.js',
|
||||
testEnvironment: 'node',
|
||||
transform: {
|
||||
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
|
||||
},
|
||||
moduleFileExtensions: ['ts', 'js', 'html'],
|
||||
coverageDirectory: '../../coverage/apps/daytona',
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"name": "api",
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "apps/api/src",
|
||||
"projectType": "application",
|
||||
"tags": [],
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@nx/webpack:webpack",
|
||||
"options": {
|
||||
"outputPath": "dist/apps/api",
|
||||
"main": "apps/api/src/main.ts",
|
||||
"tsConfig": "apps/api/tsconfig.app.json",
|
||||
"generatePackageJson": true,
|
||||
"target": "node",
|
||||
"compiler": "tsc",
|
||||
"sourceMap": true,
|
||||
"webpackConfig": "apps/api/webpack.config.js"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"optimization": true,
|
||||
"extractLicenses": true,
|
||||
"inspect": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"openapi": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"command": "yarn ts-node apps/api/src/generate-openapi.ts -o dist/apps/api/openapi.json",
|
||||
"env": {
|
||||
"TS_NODE_PROJECT": "apps/api/tsconfig.app.json",
|
||||
"NODE_OPTIONS": "--require tsconfig-paths/register",
|
||||
"SKIP_CONNECTIONS": "true"
|
||||
}
|
||||
}
|
||||
},
|
||||
"serve": {
|
||||
"executor": "@nx/js:node",
|
||||
"defaultConfiguration": "development",
|
||||
"dependsOn": ["build"],
|
||||
"options": {
|
||||
"buildTarget": "api:build",
|
||||
"runBuildTargetDependencies": false,
|
||||
"watch": true
|
||||
},
|
||||
"configurations": {
|
||||
"development": {
|
||||
"buildTarget": "api:build:development"
|
||||
},
|
||||
"production": {
|
||||
"buildTarget": "api:build:production"
|
||||
}
|
||||
}
|
||||
},
|
||||
"format": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"command": "cd {projectRoot} && prettier --write \"**/*.{ts,json,mjs}\" --config ../../.prettierrc"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"options": {
|
||||
"passWithNoTests": true
|
||||
}
|
||||
},
|
||||
"docker-build": {
|
||||
"dependsOn": ["build"],
|
||||
"command": "docker build -f apps/api/Dockerfile . -t api"
|
||||
},
|
||||
"migration:generate": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"command": "npx ts-node -P ./tsconfig.json -r tsconfig-paths/register ../../node_modules/typeorm/cli.js migration:generate -d ./src/data-source.ts ./src/migrations/migration"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Module } from '@nestjs/common'
|
||||
import { TypeOrmModule } from '@nestjs/typeorm'
|
||||
import { AnalyticsService } from './services/analytics.service'
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([AnalyticsService])],
|
||||
providers: [AnalyticsService],
|
||||
exports: [AnalyticsService],
|
||||
})
|
||||
export class AnalyticsModule {}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
import { OnEvent } from '@nestjs/event-emitter'
|
||||
import { WorkspaceEvents } from '../../workspace/constants/workspace-events.constants'
|
||||
import { WorkspaceCreatedEvent } from '../../workspace/events/workspace-create.event'
|
||||
import { WorkspaceDesiredStateUpdatedEvent } from '../../workspace/events/workspace-desired-state-updated.event'
|
||||
import { WorkspaceDestroyedEvent } from '../../workspace/events/workspace-destroyed.event'
|
||||
import { WorkspacePublicStatusUpdatedEvent } from '../../workspace/events/workspace-public-status-updated.event'
|
||||
import { WorkspaceResizedEvent } from '../../workspace/events/workspace-resized.event'
|
||||
import { WorkspaceStartedEvent } from '../../workspace/events/workspace-started.event'
|
||||
import { WorkspaceStateUpdatedEvent } from '../../workspace/events/workspace-state-updated.event'
|
||||
import { WorkspaceStoppedEvent } from '../../workspace/events/workspace-stopped.event'
|
||||
import { PostHog } from 'posthog-node'
|
||||
import { OnAsyncEvent } from '../../common/decorators/on-async-event.decorator'
|
||||
import { Organization } from '../../organization/entities/organization.entity'
|
||||
import { OrganizationEvents } from '../../organization/constants/organization-events.constant'
|
||||
|
||||
@Injectable()
|
||||
export class AnalyticsService {
|
||||
private readonly logger = new Logger(AnalyticsService.name)
|
||||
private readonly posthog?: PostHog
|
||||
|
||||
constructor() {
|
||||
if (!process.env.POSTHOG_API_KEY) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!process.env.POSTHOG_HOST) {
|
||||
return
|
||||
}
|
||||
|
||||
// Initialize PostHog client
|
||||
// Make sure to set POSTHOG_API_KEY in your environment variables
|
||||
this.posthog = new PostHog(process.env.POSTHOG_API_KEY, {
|
||||
host: process.env.POSTHOG_HOST,
|
||||
})
|
||||
}
|
||||
|
||||
@OnEvent(WorkspaceEvents.CREATED)
|
||||
async handleWorkspaceCreatedEvent(event: WorkspaceCreatedEvent) {
|
||||
this.logger.debug(`Workspace created: ${JSON.stringify(event)}`)
|
||||
}
|
||||
|
||||
@OnEvent(WorkspaceEvents.STARTED)
|
||||
async handleWorkspaceStartedEvent(event: WorkspaceStartedEvent) {
|
||||
this.logger.debug(`Workspace started: ${JSON.stringify(event)}`)
|
||||
}
|
||||
|
||||
@OnEvent(WorkspaceEvents.STOPPED)
|
||||
async handleWorkspaceStoppedEvent(event: WorkspaceStoppedEvent) {
|
||||
this.logger.debug(`Workspace stopped: ${JSON.stringify(event)}`)
|
||||
}
|
||||
|
||||
@OnEvent(WorkspaceEvents.DESTROYED)
|
||||
async handleWorkspaceDestroyedEvent(event: WorkspaceDestroyedEvent) {
|
||||
this.logger.debug(`Workspace destroyed: ${JSON.stringify(event)}`)
|
||||
}
|
||||
|
||||
@OnEvent(WorkspaceEvents.RESIZED)
|
||||
async handleWorkspaceResizedEvent(event: WorkspaceResizedEvent) {
|
||||
this.logger.debug(`Workspace resized: ${JSON.stringify(event)}`)
|
||||
}
|
||||
|
||||
@OnEvent(WorkspaceEvents.PUBLIC_STATUS_UPDATED)
|
||||
async handleWorkspacePublicStatusUpdatedEvent(event: WorkspacePublicStatusUpdatedEvent) {
|
||||
this.logger.debug(`Workspace public status updated: ${JSON.stringify(event)}`)
|
||||
}
|
||||
|
||||
@OnEvent(WorkspaceEvents.DESIRED_STATE_UPDATED)
|
||||
async handleWorkspaceDesiredStateUpdatedEvent(event: WorkspaceDesiredStateUpdatedEvent) {
|
||||
this.logger.debug(`Workspace desired state updated: ${JSON.stringify(event)}`)
|
||||
}
|
||||
|
||||
@OnEvent(WorkspaceEvents.STATE_UPDATED)
|
||||
async handleWorkspaceStateUpdatedEvent(event: WorkspaceStateUpdatedEvent) {
|
||||
this.logger.debug(`Workspace state updated: ${JSON.stringify(event)}`)
|
||||
}
|
||||
|
||||
@OnAsyncEvent({
|
||||
event: OrganizationEvents.CREATED,
|
||||
})
|
||||
async handlePersonalOrganizationCreatedEvent(payload: Organization) {
|
||||
if (!payload.personal) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.posthog) {
|
||||
return
|
||||
}
|
||||
|
||||
this.posthog.groupIdentify({
|
||||
groupType: 'organization',
|
||||
groupKey: payload.id,
|
||||
properties: {
|
||||
name: `Personal - ${payload.createdBy}`,
|
||||
created_at: payload.createdAt,
|
||||
created_by: payload.createdBy,
|
||||
personal: payload.personal,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Controller, Post, Get, Delete, Param, Body, UseGuards, ForbiddenException, HttpCode } from '@nestjs/common'
|
||||
import { ApiKeyService } from './api-key.service'
|
||||
import { CreateApiKeyDto } from './dto/create-api-key.dto'
|
||||
import { ApiHeader, ApiOAuth2, ApiOperation, ApiResponse, ApiTags, ApiBearerAuth } from '@nestjs/swagger'
|
||||
import { ApiKeyResponseDto } from './dto/api-key-response.dto'
|
||||
import { ApiKeyListDto } from './dto/api-key-list.dto'
|
||||
import { CombinedAuthGuard } from '../auth/combined-auth.guard'
|
||||
import { CustomHeaders } from '../common/constants/header.constants'
|
||||
import { AuthContext } from '../common/decorators/auth-context.decorator'
|
||||
import { OrganizationAuthContext } from '../common/interfaces/auth-context.interface'
|
||||
import { OrganizationMemberRole } from '../organization/enums/organization-member-role.enum'
|
||||
import { OrganizationResourcePermission } from '../organization/enums/organization-resource-permission.enum'
|
||||
import { OrganizationResourceActionGuard } from '../organization/guards/organization-resource-action.guard'
|
||||
import { SystemRole } from '../user/enums/system-role.enum'
|
||||
|
||||
@ApiTags('api-keys')
|
||||
@Controller('api-keys')
|
||||
@ApiHeader(CustomHeaders.ORGANIZATION_ID)
|
||||
@UseGuards(CombinedAuthGuard, OrganizationResourceActionGuard)
|
||||
@ApiOAuth2(['openid', 'profile', 'email'])
|
||||
@ApiBearerAuth()
|
||||
export class ApiKeyController {
|
||||
constructor(private readonly apiKeyService: ApiKeyService) {}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({
|
||||
summary: 'Create API key',
|
||||
operationId: 'createApiKey',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 201,
|
||||
description: 'API key created successfully.',
|
||||
type: ApiKeyResponseDto,
|
||||
})
|
||||
async createApiKey(
|
||||
@AuthContext() authContext: OrganizationAuthContext,
|
||||
@Body() createApiKeyDto: CreateApiKeyDto,
|
||||
): Promise<ApiKeyResponseDto> {
|
||||
this.validateRequestedApiKeyPermissions(authContext, createApiKeyDto.permissions)
|
||||
|
||||
const { apiKey, value } = await this.apiKeyService.createApiKey(
|
||||
authContext.organizationId,
|
||||
authContext.userId,
|
||||
createApiKeyDto.name,
|
||||
createApiKeyDto.permissions,
|
||||
)
|
||||
|
||||
return ApiKeyResponseDto.fromApiKey(apiKey, value)
|
||||
}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({
|
||||
summary: 'List API keys',
|
||||
operationId: 'listApiKeys',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'API keys retrieved successfully.',
|
||||
type: [ApiKeyListDto],
|
||||
})
|
||||
@ApiResponse({ status: 500, description: 'Error fetching API keys.' })
|
||||
async getApiKeys(@AuthContext() authContext: OrganizationAuthContext): Promise<ApiKeyListDto[]> {
|
||||
const apiKeys = await this.apiKeyService.getApiKeys(authContext.organizationId, authContext.userId)
|
||||
return apiKeys.map((apiKey) => ApiKeyListDto.fromApiKey(apiKey))
|
||||
}
|
||||
|
||||
@Get(':name')
|
||||
@ApiOperation({
|
||||
summary: 'Get API key',
|
||||
operationId: 'getApiKey',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'API key retrieved successfully.',
|
||||
type: ApiKeyListDto,
|
||||
})
|
||||
async getApiKey(
|
||||
@AuthContext() authContext: OrganizationAuthContext,
|
||||
@Param('name') name: string,
|
||||
): Promise<ApiKeyListDto> {
|
||||
const apiKey = await this.apiKeyService.getApiKeyByName(authContext.organizationId, authContext.userId, name)
|
||||
return ApiKeyListDto.fromApiKey(apiKey)
|
||||
}
|
||||
|
||||
@Delete(':name')
|
||||
@ApiOperation({
|
||||
summary: 'Delete API key',
|
||||
operationId: 'deleteApiKey',
|
||||
})
|
||||
@ApiResponse({ status: 204, description: 'API key deleted successfully.' })
|
||||
@HttpCode(204)
|
||||
async deleteApiKey(@AuthContext() authContext: OrganizationAuthContext, @Param('name') name: string) {
|
||||
await this.apiKeyService.deleteApiKey(authContext.organizationId, authContext.userId, name)
|
||||
}
|
||||
|
||||
private validateRequestedApiKeyPermissions(
|
||||
authContext: OrganizationAuthContext,
|
||||
requestedPermissions: OrganizationResourcePermission[],
|
||||
): void {
|
||||
if (authContext.role === SystemRole.ADMIN) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!authContext.organizationUser) {
|
||||
throw new ForbiddenException(`Insufficient permissions for assigning: ${requestedPermissions.join(', ')}`)
|
||||
}
|
||||
|
||||
if (authContext.organizationUser.role === OrganizationMemberRole.OWNER) {
|
||||
return
|
||||
}
|
||||
|
||||
const organizationUserPermissions = new Set(
|
||||
authContext.organizationUser.assignedRoles.flatMap((role) => role.permissions),
|
||||
)
|
||||
|
||||
const forbiddenPermissions = requestedPermissions.filter(
|
||||
(permission) => !organizationUserPermissions.has(permission),
|
||||
)
|
||||
|
||||
if (forbiddenPermissions.length) {
|
||||
throw new ForbiddenException(`Insufficient permissions for assigning: ${forbiddenPermissions.join(', ')}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Column, Entity, PrimaryColumn } from 'typeorm'
|
||||
import { OrganizationResourcePermission } from '../organization/enums/organization-resource-permission.enum'
|
||||
|
||||
@Entity()
|
||||
export class ApiKey {
|
||||
@PrimaryColumn({
|
||||
type: 'uuid',
|
||||
})
|
||||
organizationId: string
|
||||
|
||||
@PrimaryColumn()
|
||||
userId: string
|
||||
|
||||
@PrimaryColumn()
|
||||
name: string
|
||||
|
||||
@Column({ unique: true, default: '' })
|
||||
keyHash: string
|
||||
|
||||
@Column({
|
||||
default: '',
|
||||
})
|
||||
keyPrefix: string
|
||||
|
||||
@Column({
|
||||
default: '',
|
||||
})
|
||||
keySuffix: string
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: OrganizationResourcePermission,
|
||||
array: true,
|
||||
})
|
||||
permissions: OrganizationResourcePermission[]
|
||||
|
||||
@Column()
|
||||
createdAt: Date
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Module } from '@nestjs/common'
|
||||
import { ApiKeyController } from './api-key.controller'
|
||||
import { ApiKeyService } from './api-key.service'
|
||||
import { ApiKey } from './api-key.entity'
|
||||
import { TypeOrmModule } from '@nestjs/typeorm'
|
||||
import { OrganizationModule } from '../organization/organization.module'
|
||||
|
||||
@Module({
|
||||
imports: [OrganizationModule, TypeOrmModule.forFeature([ApiKey])],
|
||||
controllers: [ApiKeyController],
|
||||
providers: [ApiKeyService],
|
||||
exports: [ApiKeyService],
|
||||
})
|
||||
export class ApiKeyModule {}
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { ConflictException, Injectable, Logger, NotFoundException } from '@nestjs/common'
|
||||
import { InjectRepository } from '@nestjs/typeorm'
|
||||
import { Repository } from 'typeorm'
|
||||
import { ApiKey } from './api-key.entity'
|
||||
import * as crypto from 'crypto'
|
||||
import { OrganizationUser } from '../organization/entities/organization-user.entity'
|
||||
import { OrganizationMemberRole } from '../organization/enums/organization-member-role.enum'
|
||||
import { OrganizationResourcePermission } from '../organization/enums/organization-resource-permission.enum'
|
||||
import { OrganizationUserService } from '../organization/services/organization-user.service'
|
||||
|
||||
@Injectable()
|
||||
export class ApiKeyService {
|
||||
private readonly logger = new Logger(ApiKeyService.name)
|
||||
|
||||
constructor(
|
||||
@InjectRepository(ApiKey)
|
||||
private apiKeyRepository: Repository<ApiKey>,
|
||||
private organizationUserService: OrganizationUserService,
|
||||
) {}
|
||||
|
||||
private generateApiKeyValue(): string {
|
||||
return `dtn_${crypto.randomBytes(32).toString('hex')}`
|
||||
}
|
||||
|
||||
private generateApiKeyHash(value: string): string {
|
||||
return crypto.createHash('sha256').update(value).digest('hex')
|
||||
}
|
||||
|
||||
private getApiKeyPrefix(value: string): string {
|
||||
return value.substring(0, 3)
|
||||
}
|
||||
|
||||
private getApiKeySuffix(value: string): string {
|
||||
return value.slice(-3)
|
||||
}
|
||||
|
||||
async createApiKey(
|
||||
organizationId: string,
|
||||
userId: string,
|
||||
name: string,
|
||||
permissions: OrganizationResourcePermission[],
|
||||
): Promise<{ apiKey: ApiKey; value: string }> {
|
||||
const existingKey = await this.apiKeyRepository.findOne({ where: { organizationId, userId, name } })
|
||||
if (existingKey) {
|
||||
throw new ConflictException('API key with this name already exists')
|
||||
}
|
||||
|
||||
const value = this.generateApiKeyValue()
|
||||
|
||||
const apiKey = await this.apiKeyRepository.save({
|
||||
organizationId,
|
||||
userId,
|
||||
name,
|
||||
keyHash: this.generateApiKeyHash(value),
|
||||
keyPrefix: this.getApiKeyPrefix(value),
|
||||
keySuffix: this.getApiKeySuffix(value),
|
||||
permissions,
|
||||
createdAt: new Date(),
|
||||
})
|
||||
|
||||
return { apiKey, value }
|
||||
}
|
||||
|
||||
async getApiKeys(organizationId: string, userId: string): Promise<ApiKey[]> {
|
||||
const apiKeys = await this.apiKeyRepository.find({ where: { organizationId, userId } })
|
||||
|
||||
const organizationUser = await this.organizationUserService.findOne(organizationId, userId)
|
||||
if (!organizationUser) {
|
||||
throw new NotFoundException('Organization user (API key owner) not found')
|
||||
}
|
||||
|
||||
return apiKeys.map((apiKey) => {
|
||||
return {
|
||||
...apiKey,
|
||||
permissions: this.getEffectivePermissions(apiKey, organizationUser),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async getApiKeyByName(organizationId: string, userId: string, name: string): Promise<ApiKey> {
|
||||
const apiKey = await this.apiKeyRepository.findOne({
|
||||
where: {
|
||||
organizationId,
|
||||
userId,
|
||||
name,
|
||||
},
|
||||
})
|
||||
|
||||
if (!apiKey) {
|
||||
throw new NotFoundException('API key not found')
|
||||
}
|
||||
|
||||
const organizationUser = await this.organizationUserService.findOne(organizationId, userId)
|
||||
if (!organizationUser) {
|
||||
throw new NotFoundException('Organization user (API key owner) not found')
|
||||
}
|
||||
|
||||
apiKey.permissions = this.getEffectivePermissions(apiKey, organizationUser)
|
||||
return apiKey
|
||||
}
|
||||
|
||||
async getApiKeyByValue(value: string): Promise<ApiKey> {
|
||||
const apiKey = await this.apiKeyRepository.findOne({
|
||||
where: {
|
||||
keyHash: this.generateApiKeyHash(value),
|
||||
},
|
||||
})
|
||||
|
||||
if (!apiKey) {
|
||||
throw new NotFoundException('API key not found')
|
||||
}
|
||||
|
||||
const organizationUser = await this.organizationUserService.findOne(apiKey.organizationId, apiKey.userId)
|
||||
if (!organizationUser) {
|
||||
throw new NotFoundException('Organization user (API key owner) not found')
|
||||
}
|
||||
|
||||
apiKey.permissions = this.getEffectivePermissions(apiKey, organizationUser)
|
||||
return apiKey
|
||||
}
|
||||
|
||||
async deleteApiKey(organizationId: string, userId: string, name: string): Promise<void> {
|
||||
const apiKey = await this.apiKeyRepository.findOne({ where: { organizationId, userId, name } })
|
||||
|
||||
if (!apiKey) {
|
||||
throw new NotFoundException('API key not found')
|
||||
}
|
||||
|
||||
await this.apiKeyRepository.remove(apiKey)
|
||||
}
|
||||
|
||||
private getEffectivePermissions(
|
||||
apiKey: ApiKey,
|
||||
organizationUser: OrganizationUser,
|
||||
): OrganizationResourcePermission[] {
|
||||
if (organizationUser.role === OrganizationMemberRole.OWNER) {
|
||||
return apiKey.permissions
|
||||
}
|
||||
const organizationUserPermissions = new Set(organizationUser.assignedRoles.flatMap((role) => role.permissions))
|
||||
return apiKey.permissions.filter((permission) => organizationUserPermissions.has(permission))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { ApiProperty, ApiSchema } from '@nestjs/swagger'
|
||||
import { OrganizationResourcePermission } from '../../organization/enums/organization-resource-permission.enum'
|
||||
import { ApiKey } from '../api-key.entity'
|
||||
|
||||
@ApiSchema({ name: 'ApiKeyList' })
|
||||
export class ApiKeyListDto {
|
||||
@ApiProperty({
|
||||
description: 'The name of the API key',
|
||||
example: 'My API Key',
|
||||
})
|
||||
name: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The masked API key value',
|
||||
example: 'bb_********************def',
|
||||
})
|
||||
value: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'When the API key was created',
|
||||
example: '2024-03-14T12:00:00.000Z',
|
||||
})
|
||||
createdAt: Date
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The list of organization resource permissions assigned to the API key',
|
||||
enum: OrganizationResourcePermission,
|
||||
isArray: true,
|
||||
})
|
||||
permissions: OrganizationResourcePermission[]
|
||||
|
||||
constructor(partial: Partial<ApiKeyListDto>) {
|
||||
Object.assign(this, partial)
|
||||
}
|
||||
|
||||
static fromApiKey(apiKey: ApiKey): ApiKeyListDto {
|
||||
const maskedValue = `${apiKey.keyPrefix}********************${apiKey.keySuffix}`
|
||||
|
||||
return new ApiKeyListDto({
|
||||
name: apiKey.name,
|
||||
value: maskedValue,
|
||||
createdAt: apiKey.createdAt,
|
||||
permissions: apiKey.permissions,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { ApiProperty, ApiSchema } from '@nestjs/swagger'
|
||||
import { OrganizationResourcePermission } from '../../organization/enums/organization-resource-permission.enum'
|
||||
import { ApiKey } from '../api-key.entity'
|
||||
|
||||
@ApiSchema({ name: 'ApiKeyResponse' })
|
||||
export class ApiKeyResponseDto {
|
||||
@ApiProperty({
|
||||
description: 'The name of the API key',
|
||||
example: 'My API Key',
|
||||
})
|
||||
name: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The API key value',
|
||||
example: 'bb_sk_1234567890abcdef',
|
||||
})
|
||||
value: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'When the API key was created',
|
||||
example: '2024-03-14T12:00:00.000Z',
|
||||
})
|
||||
createdAt: Date
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The list of organization resource permissions assigned to the API key',
|
||||
enum: OrganizationResourcePermission,
|
||||
isArray: true,
|
||||
})
|
||||
permissions: OrganizationResourcePermission[]
|
||||
|
||||
static fromApiKey(apiKey: ApiKey, value: string): ApiKeyResponseDto {
|
||||
return {
|
||||
name: apiKey.name,
|
||||
value,
|
||||
createdAt: apiKey.createdAt,
|
||||
permissions: apiKey.permissions,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { ArrayNotEmpty, IsArray, IsEnum, IsNotEmpty, IsString } from 'class-validator'
|
||||
import { ApiProperty, ApiSchema } from '@nestjs/swagger'
|
||||
import { OrganizationResourcePermission } from '../../organization/enums/organization-resource-permission.enum'
|
||||
|
||||
@ApiSchema({ name: 'CreateApiKey' })
|
||||
export class CreateApiKeyDto {
|
||||
@ApiProperty({
|
||||
description: 'The name of the API key',
|
||||
example: 'My API Key',
|
||||
required: true,
|
||||
})
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
name: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The list of organization resource permissions assigned to the API key',
|
||||
enum: OrganizationResourcePermission,
|
||||
isArray: true,
|
||||
required: true,
|
||||
})
|
||||
@IsArray()
|
||||
@ArrayNotEmpty()
|
||||
@IsEnum(OrganizationResourcePermission, { each: true })
|
||||
permissions: OrganizationResourcePermission[]
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Module, NestModule, MiddlewareConsumer, RequestMethod } from '@nestjs/common'
|
||||
import { VersionHeaderMiddleware } from './common/middleware/version-header.middleware'
|
||||
import { AppService } from './app.service'
|
||||
import { UserModule } from './user/user.module'
|
||||
import { TeamModule } from './team/team.module'
|
||||
import { TypeOrmModule } from '@nestjs/typeorm'
|
||||
import { WorkspaceModule } from './workspace/workspace.module'
|
||||
import { AuthModule } from './auth/auth.module'
|
||||
import { ServeStaticModule } from '@nestjs/serve-static'
|
||||
import { join } from 'path'
|
||||
import { ApiKeyModule } from './api-key/api-key.module'
|
||||
import { ThrottlerModule } from '@nestjs/throttler'
|
||||
import { DockerRegistryModule } from './docker-registry/docker-registry.module'
|
||||
import { RedisModule } from '@nestjs-modules/ioredis'
|
||||
import { ScheduleModule } from '@nestjs/schedule'
|
||||
import { EventEmitterModule } from '@nestjs/event-emitter'
|
||||
import { UsageModule } from './usage/usage.module'
|
||||
import { AnalyticsModule } from './analytics/analytics.module'
|
||||
import { OrganizationModule } from './organization/organization.module'
|
||||
import { EmailModule } from './email/email.module'
|
||||
import { TypedConfigService } from './config/typed-config.service'
|
||||
import { TypedConfigModule } from './config/typed-config.module'
|
||||
import { NotificationModule } from './notification/notification.module'
|
||||
import { ObjectStorageModule } from './object-storage/object-storage.module'
|
||||
import { CustomNamingStrategy } from './common/utils/naming-strategy.util'
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypedConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
}),
|
||||
TypeOrmModule.forRootAsync({
|
||||
inject: [TypedConfigService],
|
||||
useFactory: (configService: TypedConfigService) => {
|
||||
return {
|
||||
type: 'postgres',
|
||||
host: configService.getOrThrow('database.host'),
|
||||
port: configService.getOrThrow('database.port'),
|
||||
username: configService.getOrThrow('database.username'),
|
||||
password: configService.getOrThrow('database.password'),
|
||||
database: configService.getOrThrow('database.database'),
|
||||
autoLoadEntities: true,
|
||||
migrations: [join(__dirname, 'migrations/**/*{.ts,.js}')],
|
||||
migrationsRun: !configService.getOrThrow('production'),
|
||||
namingStrategy: new CustomNamingStrategy(),
|
||||
manualInitialization: configService.get('skipConnections'),
|
||||
}
|
||||
},
|
||||
}),
|
||||
ServeStaticModule.forRoot({
|
||||
rootPath: join(__dirname, '..', 'dashboard'),
|
||||
exclude: ['/api/*'],
|
||||
renderPath: '/',
|
||||
serveStaticOptions: {
|
||||
cacheControl: false,
|
||||
},
|
||||
}),
|
||||
ThrottlerModule.forRoot([
|
||||
{
|
||||
ttl: 1000,
|
||||
limit: 10,
|
||||
},
|
||||
]),
|
||||
RedisModule.forRootAsync({
|
||||
inject: [TypedConfigService],
|
||||
useFactory: (configService: TypedConfigService) => {
|
||||
return {
|
||||
type: 'single',
|
||||
options: {
|
||||
host: configService.getOrThrow('redis.host'),
|
||||
port: configService.getOrThrow('redis.port'),
|
||||
tls: configService.get('redis.tls'),
|
||||
lazyConnect: configService.get('skipConnections'),
|
||||
},
|
||||
}
|
||||
},
|
||||
}),
|
||||
EventEmitterModule.forRoot(),
|
||||
ApiKeyModule,
|
||||
AuthModule,
|
||||
UserModule,
|
||||
TeamModule,
|
||||
WorkspaceModule,
|
||||
DockerRegistryModule,
|
||||
ScheduleModule.forRoot(),
|
||||
UsageModule,
|
||||
AnalyticsModule,
|
||||
OrganizationModule,
|
||||
EmailModule.forRootAsync({
|
||||
inject: [TypedConfigService],
|
||||
useFactory: (configService: TypedConfigService) => {
|
||||
return {
|
||||
host: configService.get('smtp.host'),
|
||||
port: configService.get('smtp.port'),
|
||||
user: configService.get('smtp.user'),
|
||||
password: configService.get('smtp.password'),
|
||||
secure: configService.get('smtp.secure'),
|
||||
from: configService.get('smtp.from'),
|
||||
dashboardUrl: configService.getOrThrow('dashboardUrl'),
|
||||
}
|
||||
},
|
||||
}),
|
||||
NotificationModule,
|
||||
ObjectStorageModule,
|
||||
],
|
||||
controllers: [],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule implements NestModule {
|
||||
configure(consumer: MiddlewareConsumer) {
|
||||
consumer.apply(VersionHeaderMiddleware).forRoutes({ path: '*', method: RequestMethod.ALL })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Injectable, Logger, OnApplicationBootstrap } from '@nestjs/common'
|
||||
import { DockerRegistryService } from './docker-registry/services/docker-registry.service'
|
||||
import { RegistryType } from './docker-registry/enums/registry-type.enum'
|
||||
import { OrganizationService } from './organization/services/organization.service'
|
||||
import { UserService } from './user/user.service'
|
||||
import { ApiKeyService } from './api-key/api-key.service'
|
||||
import { EventEmitterReadinessWatcher } from '@nestjs/event-emitter'
|
||||
import { ImageService } from './workspace/services/image.service'
|
||||
import { SystemRole } from './user/enums/system-role.enum'
|
||||
import { TypedConfigService } from './config/typed-config.service'
|
||||
|
||||
const DAYTONA_ADMIN_USER_ID = 'daytona-admin'
|
||||
|
||||
@Injectable()
|
||||
export class AppService implements OnApplicationBootstrap {
|
||||
private readonly logger = new Logger(AppService.name)
|
||||
|
||||
constructor(
|
||||
private readonly dockerRegistryService: DockerRegistryService,
|
||||
private readonly configService: TypedConfigService,
|
||||
private readonly userService: UserService,
|
||||
private readonly organizationService: OrganizationService,
|
||||
private readonly apiKeyService: ApiKeyService,
|
||||
private readonly eventEmitterReadinessWatcher: EventEmitterReadinessWatcher,
|
||||
private readonly imageService: ImageService,
|
||||
) {}
|
||||
|
||||
async onApplicationBootstrap() {
|
||||
await this.initializeAdminUser()
|
||||
await this.initializeTransientRegistry()
|
||||
await this.initializeInternalRegistry()
|
||||
await this.initializeDefaultImage()
|
||||
}
|
||||
|
||||
private async initializeAdminUser(): Promise<void> {
|
||||
if (await this.userService.findOne(DAYTONA_ADMIN_USER_ID)) {
|
||||
return
|
||||
}
|
||||
|
||||
await this.eventEmitterReadinessWatcher.waitUntilReady()
|
||||
const user = await this.userService.create({
|
||||
id: DAYTONA_ADMIN_USER_ID,
|
||||
name: 'Daytona Admin',
|
||||
personalOrganizationQuota: {
|
||||
totalCpuQuota: 0,
|
||||
totalMemoryQuota: 0,
|
||||
totalDiskQuota: 0,
|
||||
maxCpuPerWorkspace: 0,
|
||||
maxMemoryPerWorkspace: 0,
|
||||
maxDiskPerWorkspace: 0,
|
||||
maxConcurrentWorkspaces: 0,
|
||||
workspaceQuota: 0,
|
||||
imageQuota: 100,
|
||||
maxImageSize: 100,
|
||||
totalImageSize: 1000,
|
||||
},
|
||||
role: SystemRole.ADMIN,
|
||||
})
|
||||
const personalOrg = await this.organizationService.findPersonal(user.id)
|
||||
await this.apiKeyService.createApiKey(personalOrg.id, user.id, DAYTONA_ADMIN_USER_ID, [])
|
||||
}
|
||||
|
||||
private async initializeTransientRegistry(): Promise<void> {
|
||||
const existingRegistry = await this.dockerRegistryService.getDefaultTransientRegistry()
|
||||
if (existingRegistry) {
|
||||
return
|
||||
}
|
||||
|
||||
let registryUrl = this.configService.getOrThrow('transientRegistry.url')
|
||||
const registryAdmin = this.configService.getOrThrow('transientRegistry.admin')
|
||||
const registryPassword = this.configService.getOrThrow('transientRegistry.password')
|
||||
const registryProjectId = this.configService.getOrThrow('transientRegistry.projectId')
|
||||
|
||||
if (!registryUrl || !registryAdmin || !registryPassword || !registryProjectId) {
|
||||
this.logger.warn('Registry configuration not found, skipping transient registry setup')
|
||||
return
|
||||
}
|
||||
|
||||
registryUrl = registryUrl.replace(/^(https?:\/\/)/, '')
|
||||
|
||||
this.logger.log('Initializing default transient registry...')
|
||||
|
||||
await this.dockerRegistryService.create({
|
||||
name: 'Transient Registry',
|
||||
url: registryUrl,
|
||||
username: registryAdmin,
|
||||
password: registryPassword,
|
||||
project: registryProjectId,
|
||||
registryType: RegistryType.TRANSIENT,
|
||||
isDefault: true,
|
||||
})
|
||||
|
||||
this.logger.log('Default transient registry initialized successfully')
|
||||
}
|
||||
|
||||
private async initializeInternalRegistry(): Promise<void> {
|
||||
const existingRegistry = await this.dockerRegistryService.getDefaultInternalRegistry()
|
||||
if (existingRegistry) {
|
||||
return
|
||||
}
|
||||
|
||||
let registryUrl = this.configService.getOrThrow('internalRegistry.url')
|
||||
const registryAdmin = this.configService.getOrThrow('internalRegistry.admin')
|
||||
const registryPassword = this.configService.getOrThrow('internalRegistry.password')
|
||||
const registryProjectId = this.configService.getOrThrow('internalRegistry.projectId')
|
||||
|
||||
if (!registryUrl || !registryAdmin || !registryPassword || !registryProjectId) {
|
||||
this.logger.warn('Registry configuration not found, skipping internal registry setup')
|
||||
return
|
||||
}
|
||||
|
||||
registryUrl = registryUrl.replace(/^(https?:\/\/)/, '')
|
||||
|
||||
this.logger.log('Initializing default internal registry...')
|
||||
|
||||
await this.dockerRegistryService.create({
|
||||
name: 'Internal Registry',
|
||||
url: registryUrl,
|
||||
username: registryAdmin,
|
||||
password: registryPassword,
|
||||
project: registryProjectId,
|
||||
registryType: RegistryType.INTERNAL,
|
||||
isDefault: true,
|
||||
})
|
||||
|
||||
this.logger.log('Default internal registry initialized successfully')
|
||||
}
|
||||
|
||||
private async initializeDefaultImage(): Promise<void> {
|
||||
const adminPersonalOrg = await this.organizationService.findPersonal(DAYTONA_ADMIN_USER_ID)
|
||||
|
||||
try {
|
||||
const existingImage = await this.imageService.getImageByName(
|
||||
this.configService.getOrThrow('defaultImage'),
|
||||
adminPersonalOrg.id,
|
||||
)
|
||||
if (existingImage) {
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
this.logger.log('Default image not found, creating...')
|
||||
}
|
||||
|
||||
await this.imageService.createImage(
|
||||
adminPersonalOrg.id,
|
||||
{
|
||||
name: this.configService.getOrThrow('defaultImage'),
|
||||
},
|
||||
null,
|
||||
true,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
|
||||
line-height: 1.5;
|
||||
color: #000;
|
||||
max-width: 980px;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
}
|
||||
.container {
|
||||
border: 1px solid #e1e4e8;
|
||||
border-radius: 6px;
|
||||
padding: 40px 20px;
|
||||
margin: 20px;
|
||||
}
|
||||
h1 {
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.invitation-text {
|
||||
margin: 20px 0;
|
||||
}
|
||||
.org-link {
|
||||
color: #0080ff;
|
||||
text-decoration: none;
|
||||
}
|
||||
.button {
|
||||
display: inline-block;
|
||||
padding: 12px 24px;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
color: white;
|
||||
background-color: #08ae78;
|
||||
border-radius: 6px;
|
||||
text-decoration: none;
|
||||
margin: 20px 0;
|
||||
}
|
||||
.expiration {
|
||||
margin: 20px 0;
|
||||
}
|
||||
.alternate-link {
|
||||
margin: 20px 0;
|
||||
}
|
||||
.footer {
|
||||
clear: both;
|
||||
margin-top: 10px;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
.footer p {
|
||||
color: #9a9ea6;
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
margin: 5px 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="daytona-logo">
|
||||
<img src="https://www.daytona.io/brand/social-daytona-icon-light.png" width="72" height="72" alt="Daytona logo">
|
||||
</div>
|
||||
|
||||
<h1><% if (invitedBy) { %><%= invitedBy %> has invited you to join the <%= organizationName %> organization<% } else { %>You have been invited to join the <%= organizationName %> organization<% } %></h1>
|
||||
|
||||
<div class="invitation-text">
|
||||
<p class="expiration">This invitation expires on <%= expiresAt %></p>
|
||||
|
||||
<a href="<%= invitationLink %>" class="button">Join <%= organizationName %></a>
|
||||
|
||||
<p class="alternate-link">Button not working? Paste the following link into your browser:<br>
|
||||
<a href="<%= invitationLink %>" class="org-link"><%= invitationLink %></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<p>* If you were not expecting this invitation, please disregard this email.</p>
|
||||
<p>Copyright © <%= new Date().getFullYear() %> Daytona Platforms, Inc. All Rights Reserved</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Injectable, UnauthorizedException, Logger, OnModuleInit } from '@nestjs/common'
|
||||
import { PassportStrategy } from '@nestjs/passport'
|
||||
import { Strategy } from 'passport-http-bearer'
|
||||
import { ApiKeyService } from '../api-key/api-key.service'
|
||||
import { UserService } from '../user/user.service'
|
||||
import { AuthContext } from '../common/interfaces/auth-context.interface'
|
||||
|
||||
@Injectable()
|
||||
export class ApiKeyStrategy extends PassportStrategy(Strategy, 'api-key') implements OnModuleInit {
|
||||
private readonly logger = new Logger(ApiKeyStrategy.name)
|
||||
|
||||
constructor(
|
||||
private readonly apiKeyService: ApiKeyService,
|
||||
private readonly userService: UserService,
|
||||
) {
|
||||
super()
|
||||
this.logger.log('ApiKeyStrategy constructor called')
|
||||
}
|
||||
|
||||
onModuleInit() {
|
||||
this.logger.log('ApiKeyStrategy initialized')
|
||||
}
|
||||
|
||||
async validate(token: string): Promise<AuthContext> {
|
||||
this.logger.debug('Validate method called')
|
||||
this.logger.debug(`Validating API key: ${token.substring(0, 8)}...`)
|
||||
|
||||
try {
|
||||
const apiKey = await this.apiKeyService.getApiKeyByValue(token)
|
||||
this.logger.debug(`API key found for userId: ${apiKey.userId}`)
|
||||
|
||||
let user = await this.userService.findOne(apiKey.userId)
|
||||
if (!user) {
|
||||
this.logger.debug(`Creating new user for userId: ${apiKey.userId}`)
|
||||
user = await this.userService.create({
|
||||
id: apiKey.userId,
|
||||
name: 'API Key User',
|
||||
})
|
||||
}
|
||||
|
||||
const result = {
|
||||
userId: user.id,
|
||||
role: user.role,
|
||||
email: user.email,
|
||||
apiKey,
|
||||
organizationId: apiKey.organizationId,
|
||||
}
|
||||
|
||||
this.logger.debug('Authentication successful', result)
|
||||
return result
|
||||
} catch (error) {
|
||||
this.logger.debug('Error in validate method:', error)
|
||||
throw new UnauthorizedException('Invalid API key')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Module } from '@nestjs/common'
|
||||
import { PassportModule } from '@nestjs/passport'
|
||||
import { JwtStrategy } from './jwt.strategy'
|
||||
import { ApiKeyStrategy } from './api-key.strategy'
|
||||
import { UserModule } from '../user/user.module'
|
||||
import { ApiKeyModule } from '../api-key/api-key.module'
|
||||
import { TypedConfigService } from '../config/typed-config.service'
|
||||
import { HttpModule, HttpService } from '@nestjs/axios'
|
||||
import { OidcMetadata } from 'oidc-client-ts'
|
||||
import { firstValueFrom } from 'rxjs'
|
||||
import { UserService } from '../user/user.service'
|
||||
import { TypedConfigModule } from '../config/typed-config.module'
|
||||
import { catchError, map } from 'rxjs/operators'
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
PassportModule.register({
|
||||
defaultStrategy: ['jwt', 'api-key'],
|
||||
property: 'user',
|
||||
session: false,
|
||||
}),
|
||||
TypedConfigModule,
|
||||
UserModule,
|
||||
ApiKeyModule,
|
||||
HttpModule,
|
||||
],
|
||||
providers: [
|
||||
ApiKeyStrategy,
|
||||
{
|
||||
provide: JwtStrategy,
|
||||
useFactory: async (userService: UserService, httpService: HttpService, configService: TypedConfigService) => {
|
||||
// Get the OpenID configuration from the issuer
|
||||
const discoveryUrl = `${configService.get('oidc.issuer')}/.well-known/openid-configuration`
|
||||
const metadata = await firstValueFrom(
|
||||
httpService.get(discoveryUrl).pipe(
|
||||
map((response) => response.data as OidcMetadata),
|
||||
catchError((error) => {
|
||||
throw new Error(`Failed to fetch OpenID configuration: ${error.message}`)
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
||||
return new JwtStrategy(
|
||||
{
|
||||
audience: configService.get('oidc.audience'),
|
||||
issuer: metadata.issuer,
|
||||
jwksUri: metadata.jwks_uri,
|
||||
},
|
||||
userService,
|
||||
)
|
||||
},
|
||||
inject: [UserService, HttpService, TypedConfigService],
|
||||
},
|
||||
],
|
||||
exports: [PassportModule, JwtStrategy, ApiKeyStrategy],
|
||||
})
|
||||
export class AuthModule {}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Injectable, ExecutionContext, Logger } from '@nestjs/common'
|
||||
import { AuthGuard } from '@nestjs/passport'
|
||||
|
||||
@Injectable()
|
||||
export class CombinedAuthGuard extends AuthGuard(['jwt', 'api-key']) {
|
||||
private readonly logger = new Logger(CombinedAuthGuard.name)
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
this.logger.debug('CombinedAuthGuard constructor called')
|
||||
}
|
||||
|
||||
async canActivate(context: ExecutionContext): Promise<boolean> {
|
||||
this.logger.debug('CombinedAuthGuard.canActivate called')
|
||||
try {
|
||||
const result = await super.canActivate(context)
|
||||
this.logger.debug('Authentication result:', result)
|
||||
return result as boolean
|
||||
} catch (error) {
|
||||
this.logger.debug('Authentication error:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
handleRequest(err: any, user: any, info: any, context: ExecutionContext) {
|
||||
this.logger.debug('CombinedAuthGuard.handleRequest called')
|
||||
this.logger.debug('Error:', err)
|
||||
this.logger.debug('User:', user)
|
||||
this.logger.debug('Info:', info)
|
||||
|
||||
if (err || !user) {
|
||||
this.logger.debug('Authentication failed')
|
||||
return super.handleRequest(err, user, info, context)
|
||||
}
|
||||
|
||||
this.logger.debug('Authentication successful')
|
||||
return user
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
import { PassportStrategy } from '@nestjs/passport'
|
||||
import { ExtractJwt, Strategy } from 'passport-jwt'
|
||||
import { passportJwtSecret } from 'jwks-rsa'
|
||||
import { createRemoteJWKSet, JWTPayload, jwtVerify } from 'jose'
|
||||
import { UserService } from '../user/user.service'
|
||||
import { AuthContext } from '../common/interfaces/auth-context.interface'
|
||||
import { Request } from 'express'
|
||||
import { CustomHeaders } from '../common/constants/header.constants'
|
||||
import { DEFAULT_ORGANIZATION_QUOTA } from '../common/constants/default-organization-quota'
|
||||
|
||||
interface JwtStrategyConfig {
|
||||
jwksUri: string
|
||||
audience: string
|
||||
issuer: string
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class JwtStrategy extends PassportStrategy(Strategy) {
|
||||
private readonly logger = new Logger(JwtStrategy.name)
|
||||
private JWKS: ReturnType<typeof createRemoteJWKSet>
|
||||
|
||||
constructor(
|
||||
private readonly options: JwtStrategyConfig,
|
||||
private readonly userService: UserService,
|
||||
) {
|
||||
super({
|
||||
secretOrKeyProvider: passportJwtSecret({
|
||||
cache: true,
|
||||
rateLimit: true,
|
||||
jwksRequestsPerMinute: 5,
|
||||
jwksUri: options.jwksUri,
|
||||
}),
|
||||
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
||||
audience: options.audience,
|
||||
issuer: options.issuer,
|
||||
algorithms: ['RS256'],
|
||||
passReqToCallback: true,
|
||||
})
|
||||
this.JWKS = createRemoteJWKSet(new URL(options.jwksUri))
|
||||
this.logger.debug('JwtStrategy initialized')
|
||||
}
|
||||
|
||||
async validate(request: Request, payload: any): Promise<AuthContext> {
|
||||
const userId = payload.sub
|
||||
let user = await this.userService.findOne(userId)
|
||||
|
||||
if (user && !user.emailVerified && payload.email_verified) {
|
||||
await this.userService.update(user.id, {
|
||||
emailVerified: payload.email_verified,
|
||||
})
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
user = await this.userService.create({
|
||||
id: userId,
|
||||
name: payload.name || payload.username || 'Unknown',
|
||||
email: payload.email || '',
|
||||
emailVerified: payload.email_verified || false,
|
||||
personalOrganizationQuota: DEFAULT_ORGANIZATION_QUOTA,
|
||||
})
|
||||
this.logger.debug(`Created new user with ID: ${userId}`)
|
||||
} else if (user.name === 'Unknown' || !user.email) {
|
||||
await this.userService.update(user.id, {
|
||||
name: payload.name || payload.username || 'Unknown',
|
||||
email: payload.email || '',
|
||||
})
|
||||
this.logger.debug(`Updated name and email address for existing user with ID: ${userId}`)
|
||||
}
|
||||
|
||||
const organizationId = request.get(CustomHeaders.ORGANIZATION_ID.name)
|
||||
|
||||
return {
|
||||
userId: user.id,
|
||||
role: user.role,
|
||||
email: user.email,
|
||||
organizationId,
|
||||
}
|
||||
}
|
||||
|
||||
async verifyToken(token: string): Promise<JWTPayload> {
|
||||
const { payload } = await jwtVerify(token, this.JWKS, {
|
||||
audience: this.options.audience,
|
||||
issuer: this.options.issuer,
|
||||
algorithms: ['RS256'],
|
||||
})
|
||||
return payload
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Injectable, ExecutionContext, Logger, CanActivate } from '@nestjs/common'
|
||||
import { Reflector } from '@nestjs/core'
|
||||
import { RequiredSystemRole } from '../common/decorators/required-system-role.decorator'
|
||||
import { SystemRole } from '../user/enums/system-role.enum'
|
||||
import { AuthContext } from '../common/interfaces/auth-context.interface'
|
||||
|
||||
@Injectable()
|
||||
export class SystemActionGuard implements CanActivate {
|
||||
protected readonly logger = new Logger(SystemActionGuard.name)
|
||||
|
||||
constructor(private readonly reflector: Reflector) {}
|
||||
|
||||
async canActivate(context: ExecutionContext): Promise<boolean> {
|
||||
const request = context.switchToHttp().getRequest()
|
||||
// TODO: initialize authContext safely
|
||||
const authContext: AuthContext = request.user
|
||||
|
||||
const requiredRole =
|
||||
this.reflector.get(RequiredSystemRole, context.getHandler()) ||
|
||||
this.reflector.get(RequiredSystemRole, context.getClass())
|
||||
|
||||
if (!requiredRole) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (requiredRole === SystemRole.ADMIN) {
|
||||
return authContext.role === SystemRole.ADMIN
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { CreateOrganizationQuotaDto } from '../../organization/dto/create-organization-quota.dto'
|
||||
|
||||
export const DEFAULT_ORGANIZATION_QUOTA: CreateOrganizationQuotaDto = {
|
||||
totalCpuQuota: 20,
|
||||
totalMemoryQuota: 40,
|
||||
totalDiskQuota: 50,
|
||||
maxCpuPerWorkspace: 4,
|
||||
maxMemoryPerWorkspace: 8,
|
||||
maxDiskPerWorkspace: 10,
|
||||
maxConcurrentWorkspaces: 10,
|
||||
workspaceQuota: 10,
|
||||
imageQuota: 5,
|
||||
maxImageSize: 5,
|
||||
totalImageSize: 10,
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
export const CustomHeaders: {
|
||||
[key: string]: {
|
||||
name: string
|
||||
description?: string
|
||||
required?: boolean
|
||||
schema?: {
|
||||
type?: string
|
||||
}
|
||||
}
|
||||
} = {
|
||||
ORGANIZATION_ID: {
|
||||
name: 'X-Daytona-Organization-ID',
|
||||
description: 'Use with JWT to specify the organization ID',
|
||||
required: false,
|
||||
schema: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
SOURCE: {
|
||||
name: 'X-Daytona-Source',
|
||||
description: 'Use to specify the source of the request',
|
||||
required: false,
|
||||
schema: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { createParamDecorator, ExecutionContext } from '@nestjs/common'
|
||||
|
||||
export const AuthContext = createParamDecorator((data: unknown, ctx: ExecutionContext) => {
|
||||
const request = ctx.switchToHttp().getRequest()
|
||||
return request.user
|
||||
})
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { OnEvent, OnEventMetadata } from '@nestjs/event-emitter'
|
||||
|
||||
export function OnAsyncEvent({ event, options = {} }: OnEventMetadata): MethodDecorator {
|
||||
return OnEvent(event, {
|
||||
...options,
|
||||
promisify: true,
|
||||
suppressErrors: false,
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Reflector } from '@nestjs/core'
|
||||
import { SystemRole } from '../../user/enums/system-role.enum'
|
||||
|
||||
export const RequiredSystemRole = Reflector.createDecorator<SystemRole>()
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { createParamDecorator, ExecutionContext } from '@nestjs/common'
|
||||
|
||||
export const User = createParamDecorator((data: string, ctx: ExecutionContext) => {
|
||||
const request = ctx.switchToHttp().getRequest()
|
||||
const user = request.user
|
||||
|
||||
return data ? user?.[data] : user
|
||||
})
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Injectable, NestInterceptor, ExecutionContext, CallHandler, Logger } from '@nestjs/common'
|
||||
import { Observable } from 'rxjs'
|
||||
|
||||
@Injectable()
|
||||
export class ContentTypeInterceptor implements NestInterceptor {
|
||||
private readonly logger = new Logger(ContentTypeInterceptor.name)
|
||||
|
||||
async intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<any>> {
|
||||
const request = context.switchToHttp().getRequest()
|
||||
|
||||
// Check if we have raw body data but no parsed body
|
||||
if (request.readable) {
|
||||
// Create a promise to handle the body parsing
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
let rawBody = ''
|
||||
|
||||
// Collect the raw body data
|
||||
request.on('data', (chunk: Buffer) => {
|
||||
rawBody += chunk.toString()
|
||||
})
|
||||
|
||||
// Once we have all the data, try to parse it as JSON
|
||||
request.on('end', () => {
|
||||
try {
|
||||
if (rawBody) {
|
||||
request.body = JSON.parse(rawBody)
|
||||
request.headers['content-type'] = 'application/json'
|
||||
}
|
||||
resolve()
|
||||
} catch (e) {
|
||||
this.logger.error('Failed to parse JSON body:', e)
|
||||
resolve() // Still resolve even on error to prevent hanging
|
||||
}
|
||||
})
|
||||
|
||||
// Handle potential errors
|
||||
request.on('error', (error) => {
|
||||
this.logger.error('Error reading request body:', error)
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Add Content-Type header if it's missing and there's a request body
|
||||
if (request.body && Object.keys(request.body).length > 0 && !request.get('content-type')) {
|
||||
request.headers['content-type'] = 'application/json'
|
||||
}
|
||||
|
||||
return next.handle()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { ApiKey } from '../../api-key/api-key.entity'
|
||||
import { OrganizationUser } from '../../organization/entities/organization-user.entity'
|
||||
import { SystemRole } from '../../user/enums/system-role.enum'
|
||||
|
||||
export interface AuthContext {
|
||||
userId: string
|
||||
email: string
|
||||
role: SystemRole
|
||||
apiKey?: ApiKey
|
||||
organizationId?: string
|
||||
}
|
||||
|
||||
export interface OrganizationAuthContext extends AuthContext {
|
||||
organizationId: string
|
||||
organizationUser?: OrganizationUser
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { ArgumentsHost, Catch, ExceptionFilter, HttpException, HttpStatus, NotFoundException } from '@nestjs/common'
|
||||
import { join } from 'path'
|
||||
|
||||
@Catch(NotFoundException)
|
||||
export class NotFoundExceptionFilter implements ExceptionFilter {
|
||||
catch(exception: unknown, host: ArgumentsHost) {
|
||||
const ctx = host.switchToHttp()
|
||||
const request = ctx.getRequest()
|
||||
|
||||
if (!request.path.startsWith('/api/')) {
|
||||
const response = ctx.getResponse()
|
||||
response.sendFile(join(__dirname, '..', 'dashboard', 'index.html'))
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: refactor (this is duplicate code from /src/filters/all-exceptions.filter.ts)
|
||||
let statusCode: number
|
||||
let message: string
|
||||
let error: string
|
||||
|
||||
if (exception instanceof HttpException) {
|
||||
statusCode = exception.getStatus()
|
||||
const response = exception.getResponse()
|
||||
if (typeof response === 'object' && response !== null) {
|
||||
message = (response as any).message || exception.message
|
||||
error = (response as any).error || 'Http Exception'
|
||||
} else {
|
||||
message = exception.message
|
||||
error = 'Http Exception'
|
||||
}
|
||||
} else if (exception instanceof Error) {
|
||||
const customError = this.handleCustomError(exception.message)
|
||||
statusCode = customError.statusCode
|
||||
error = customError.errorType
|
||||
message = exception.message
|
||||
} else {
|
||||
statusCode = HttpStatus.INTERNAL_SERVER_ERROR
|
||||
message = 'Internal server error'
|
||||
error = 'Unknown Error'
|
||||
}
|
||||
|
||||
const responseBody = {
|
||||
statusCode,
|
||||
timestamp: new Date().toISOString(),
|
||||
path: request.path,
|
||||
error,
|
||||
message,
|
||||
}
|
||||
ctx.getResponse().status(statusCode).json(responseBody)
|
||||
return
|
||||
}
|
||||
|
||||
private handleCustomError(errorMessage: string): {
|
||||
statusCode: number
|
||||
errorType: string
|
||||
} {
|
||||
switch (errorMessage) {
|
||||
case 'Workspace not found':
|
||||
return {
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
errorType: 'Not Found',
|
||||
}
|
||||
case 'Unauthorized access':
|
||||
return {
|
||||
statusCode: HttpStatus.UNAUTHORIZED,
|
||||
errorType: 'Unauthorized',
|
||||
}
|
||||
case 'Forbidden operation':
|
||||
return {
|
||||
statusCode: HttpStatus.FORBIDDEN,
|
||||
errorType: 'Forbidden',
|
||||
}
|
||||
default:
|
||||
return {
|
||||
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
errorType: 'Internal Server Error',
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Injectable, NestMiddleware } from '@nestjs/common'
|
||||
import { Request, Response, NextFunction } from 'express'
|
||||
// import { version } from '../../../package.json'
|
||||
|
||||
@Injectable()
|
||||
export class VersionHeaderMiddleware implements NestMiddleware {
|
||||
use(req: Request, res: Response, next: NextFunction) {
|
||||
// TODO: Fetch version from package.json
|
||||
// res.setHeader('X-Daytona-Api-Version', `v${version}`)
|
||||
next()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
export function fromAxiosError(error: any): Error {
|
||||
return new Error(error.response?.data?.message || error.response?.data || error.message || error)
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { DefaultNamingStrategy, NamingStrategyInterface, Table } from 'typeorm'
|
||||
|
||||
export class CustomNamingStrategy extends DefaultNamingStrategy implements NamingStrategyInterface {
|
||||
primaryKeyName(tableOrName: Table | string, columnNames: string[]) {
|
||||
const table = tableOrName instanceof Table ? tableOrName.name : tableOrName
|
||||
const columnsSnakeCase = columnNames.join('_')
|
||||
return `${table}_${columnsSnakeCase}_pk`
|
||||
}
|
||||
|
||||
foreignKeyName(tableOrName: Table | string, columnNames: string[]): string {
|
||||
const table = tableOrName instanceof Table ? tableOrName.name : tableOrName
|
||||
const columnsSnakeCase = columnNames.join('_')
|
||||
return `${table}_${columnsSnakeCase}_fk`
|
||||
}
|
||||
|
||||
uniqueConstraintName(tableOrName: Table | string, columnNames: string[]): string {
|
||||
const table = tableOrName instanceof Table ? tableOrName.name : tableOrName
|
||||
const columnsSnakeCase = columnNames.join('_')
|
||||
return `${table}_${columnsSnakeCase}_unique`
|
||||
}
|
||||
|
||||
indexName(tableOrName: Table | string, columnNames: string[]): string {
|
||||
const table = tableOrName instanceof Table ? tableOrName.name : tableOrName
|
||||
const columnsSnakeCase = columnNames.join('_')
|
||||
return `${table}_${columnsSnakeCase}_index`
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
const configuration = {
|
||||
production: process.env.NODE_ENV === 'production',
|
||||
environment: process.env.ENVIRONMENT,
|
||||
port: parseInt(process.env.PORT, 10),
|
||||
appUrl: process.env.APP_URL,
|
||||
database: {
|
||||
host: process.env.DB_HOST,
|
||||
port: parseInt(process.env.DB_PORT || '5432', 10),
|
||||
username: process.env.DB_USERNAME,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_DATABASE,
|
||||
},
|
||||
redis: {
|
||||
host: process.env.REDIS_HOST,
|
||||
port: parseInt(process.env.REDIS_PORT || '6379', 10),
|
||||
tls: process.env.REDIS_TLS === 'true' ? {} : undefined,
|
||||
},
|
||||
posthog: {
|
||||
apiKey: process.env.POSTHOG_API_KEY,
|
||||
host: process.env.POSTHOG_HOST,
|
||||
},
|
||||
oidc: {
|
||||
clientId: process.env.OIDC_CLIENT_ID || process.env.OID_CLIENT_ID,
|
||||
issuer: process.env.OIDC_ISSUER_BASE_URL || process.env.OID_ISSUER_BASE_URL,
|
||||
audience: process.env.OIDC_AUDIENCE || process.env.OID_AUDIENCE,
|
||||
},
|
||||
smtp: {
|
||||
host: process.env.SMTP_HOST,
|
||||
port: parseInt(process.env.SMTP_PORT || '587', 10),
|
||||
user: process.env.SMTP_USER,
|
||||
password: process.env.SMTP_PASSWORD,
|
||||
secure: process.env.SMTP_SECURE === 'true',
|
||||
from: process.env.SMTP_EMAIL_FROM || 'noreply@mail.daytona.io',
|
||||
},
|
||||
defaultImage: process.env.DEFAULT_IMAGE,
|
||||
dashboardUrl: process.env.DASHBOARD_URL,
|
||||
transientRegistry: {
|
||||
url: process.env.TRANSIENT_REGISTRY_URL,
|
||||
admin: process.env.TRANSIENT_REGISTRY_ADMIN,
|
||||
password: process.env.TRANSIENT_REGISTRY_PASSWORD,
|
||||
projectId: process.env.TRANSIENT_REGISTRY_PROJECT_ID,
|
||||
},
|
||||
internalRegistry: {
|
||||
url: process.env.INTERNAL_REGISTRY_URL,
|
||||
admin: process.env.INTERNAL_REGISTRY_ADMIN,
|
||||
password: process.env.INTERNAL_REGISTRY_PASSWORD,
|
||||
projectId: process.env.INTERNAL_REGISTRY_PROJECT_ID,
|
||||
},
|
||||
s3: {
|
||||
endpoint: process.env.S3_ENDPOINT,
|
||||
region: process.env.S3_REGION,
|
||||
accessKey: process.env.S3_ACCESS_KEY,
|
||||
secretKey: process.env.S3_SECRET_KEY,
|
||||
defaultBucket: process.env.S3_DEFAULT_BUCKET,
|
||||
},
|
||||
skipConnections: process.env.SKIP_CONNECTIONS === 'true',
|
||||
}
|
||||
|
||||
export { configuration }
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Global, Module, DynamicModule } from '@nestjs/common'
|
||||
import { ConfigModule as NestConfigModule, ConfigModuleOptions } from '@nestjs/config'
|
||||
import { TypedConfigService } from './typed-config.service'
|
||||
import { configuration } from './configuration'
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
imports: [
|
||||
NestConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
load: [() => configuration],
|
||||
}),
|
||||
],
|
||||
providers: [TypedConfigService],
|
||||
exports: [TypedConfigService],
|
||||
})
|
||||
export class TypedConfigModule {
|
||||
static forRoot(options: Partial<ConfigModuleOptions> = {}): DynamicModule {
|
||||
return {
|
||||
module: TypedConfigModule,
|
||||
imports: [
|
||||
NestConfigModule.forRoot({
|
||||
...options,
|
||||
}),
|
||||
],
|
||||
providers: [TypedConfigService],
|
||||
exports: [TypedConfigService],
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { ConfigService } from '@nestjs/config'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { configuration } from './configuration'
|
||||
|
||||
type Configuration = typeof configuration
|
||||
|
||||
// Helper type to get nested property paths
|
||||
type Paths<T> = T extends object
|
||||
? {
|
||||
[K in keyof T]: K extends string ? (T[K] extends object ? `${K}` | `${K}.${Paths<T[K]>}` : `${K}`) : never
|
||||
}[keyof T]
|
||||
: never
|
||||
|
||||
// Helper type to get the type of a property at a given path
|
||||
type PathValue<T, P extends string> = P extends `${infer K}.${infer Rest}`
|
||||
? K extends keyof T
|
||||
? T[K] extends object
|
||||
? PathValue<T[K], Rest>
|
||||
: never
|
||||
: never
|
||||
: P extends keyof T
|
||||
? T[P]
|
||||
: never
|
||||
|
||||
@Injectable()
|
||||
export class TypedConfigService {
|
||||
constructor(private configService: ConfigService) {}
|
||||
|
||||
/**
|
||||
* Get a configuration value with type safety
|
||||
* @param key The configuration key (can be nested using dot notation)
|
||||
* @returns The configuration value with proper typing
|
||||
*/
|
||||
get<K extends Paths<Configuration>>(key: K): PathValue<Configuration, K> {
|
||||
return this.configService.get(key)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration value with type safety, throwing an error if undefined
|
||||
* @param key The configuration key (can be nested using dot notation)
|
||||
* @returns The configuration value with proper typing
|
||||
* @throws Error if the configuration value is undefined
|
||||
*/
|
||||
getOrThrow<K extends Paths<Configuration>>(key: K): NonNullable<PathValue<Configuration, K>> {
|
||||
const value = this.get(key)
|
||||
if (value === undefined) {
|
||||
throw new Error(`Configuration key "${key}" is undefined`)
|
||||
}
|
||||
return value as NonNullable<PathValue<Configuration, K>>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { DataSource } from 'typeorm'
|
||||
import { CustomNamingStrategy } from './common/utils/naming-strategy.util'
|
||||
import { join } from 'path'
|
||||
import { config } from 'dotenv'
|
||||
|
||||
config({ path: [join(__dirname, '../.env'), join(__dirname, '../.env.local')] })
|
||||
|
||||
const AppDataSource = new DataSource({
|
||||
type: 'postgres' as const,
|
||||
host: process.env.DB_HOST,
|
||||
port: parseInt(process.env.DB_PORT!, 10),
|
||||
username: process.env.DB_USERNAME,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_DATABASE,
|
||||
synchronize: false,
|
||||
migrations: [join(__dirname, 'migrations/**/*{.ts,.js}')],
|
||||
migrationsRun: false,
|
||||
logging: process.env.DB_LOGGING === 'true',
|
||||
namingStrategy: new CustomNamingStrategy(),
|
||||
entities: [join(__dirname, '**/*.entity.ts')],
|
||||
})
|
||||
|
||||
export default AppDataSource
|
||||
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards, HttpCode } from '@nestjs/common'
|
||||
import { ApiTags, ApiOperation, ApiResponse, ApiOAuth2, ApiHeader, ApiParam, ApiBearerAuth } from '@nestjs/swagger'
|
||||
import { CombinedAuthGuard } from '../../auth/combined-auth.guard'
|
||||
import { DockerRegistryService } from '../services/docker-registry.service'
|
||||
import { CreateDockerRegistryDto } from '../dto/create-docker-registry.dto'
|
||||
import { UpdateDockerRegistryDto } from '../dto/update-docker-registry.dto'
|
||||
import { DockerRegistryDto } from '../dto/docker-registry.dto'
|
||||
import { RegistryPushAccessDto } from '../../workspace/dto/registry-push-access-dto'
|
||||
import { DockerRegistryAccessGuard } from '../guards/docker-registry-access.guard'
|
||||
import { DockerRegistry } from '../decorators/docker-registry.decorator'
|
||||
import { DockerRegistry as DockerRegistryEntity } from '../entities/docker-registry.entity'
|
||||
import { CustomHeaders } from '../../common/constants/header.constants'
|
||||
import { AuthContext } from '../../common/decorators/auth-context.decorator'
|
||||
import { OrganizationAuthContext } from '../../common/interfaces/auth-context.interface'
|
||||
import { RequiredOrganizationResourcePermissions } from '../../organization/decorators/required-organization-resource-permissions.decorator'
|
||||
import { OrganizationResourcePermission } from '../../organization/enums/organization-resource-permission.enum'
|
||||
import { OrganizationResourceActionGuard } from '../../organization/guards/organization-resource-action.guard'
|
||||
|
||||
@ApiTags('docker-registry')
|
||||
@Controller('docker-registry')
|
||||
@ApiHeader(CustomHeaders.ORGANIZATION_ID)
|
||||
@UseGuards(CombinedAuthGuard, OrganizationResourceActionGuard)
|
||||
@ApiOAuth2(['openid', 'profile', 'email'])
|
||||
@ApiBearerAuth()
|
||||
export class DockerRegistryController {
|
||||
constructor(private readonly dockerRegistryService: DockerRegistryService) {}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({
|
||||
summary: 'Create registry',
|
||||
operationId: 'createRegistry',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 201,
|
||||
description: 'The docker registry has been successfully created.',
|
||||
type: DockerRegistryDto,
|
||||
})
|
||||
@RequiredOrganizationResourcePermissions([OrganizationResourcePermission.WRITE_REGISTRIES])
|
||||
create(
|
||||
@AuthContext() authContext: OrganizationAuthContext,
|
||||
@Body() createDockerRegistryDto: CreateDockerRegistryDto,
|
||||
): Promise<DockerRegistryDto> {
|
||||
return this.dockerRegistryService.create(createDockerRegistryDto, authContext.organizationId)
|
||||
}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({
|
||||
summary: 'List registries',
|
||||
operationId: 'listRegistries',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'List of all docker registries',
|
||||
type: [DockerRegistryDto],
|
||||
})
|
||||
findAll(@AuthContext() authContext: OrganizationAuthContext): Promise<DockerRegistryDto[]> {
|
||||
return this.dockerRegistryService.findAll(authContext.organizationId)
|
||||
}
|
||||
|
||||
@Get('registry-push-access')
|
||||
@HttpCode(200)
|
||||
@ApiOperation({
|
||||
summary: 'Get temporary registry access for pushing images',
|
||||
operationId: 'getTransientPushAccess',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Temporary registry access has been generated',
|
||||
type: RegistryPushAccessDto,
|
||||
})
|
||||
@RequiredOrganizationResourcePermissions([OrganizationResourcePermission.WRITE_REGISTRIES])
|
||||
async getTransientPushAccess(@AuthContext() authContext: OrganizationAuthContext): Promise<RegistryPushAccessDto> {
|
||||
return this.dockerRegistryService.getRegistryPushAccess(authContext.organizationId, authContext.userId)
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({
|
||||
summary: 'Get registry',
|
||||
operationId: 'getRegistry',
|
||||
})
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
description: 'ID of the docker registry',
|
||||
type: 'string',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The docker registry',
|
||||
type: DockerRegistryDto,
|
||||
})
|
||||
@UseGuards(DockerRegistryAccessGuard)
|
||||
async findOne(@DockerRegistry() registry: DockerRegistryEntity): Promise<DockerRegistryDto> {
|
||||
return registry
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
@ApiOperation({
|
||||
summary: 'Update registry',
|
||||
operationId: 'updateRegistry',
|
||||
})
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
description: 'ID of the docker registry',
|
||||
type: 'string',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The docker registry has been successfully updated.',
|
||||
type: DockerRegistryDto,
|
||||
})
|
||||
@RequiredOrganizationResourcePermissions([OrganizationResourcePermission.WRITE_REGISTRIES])
|
||||
@UseGuards(DockerRegistryAccessGuard)
|
||||
async update(
|
||||
@Param('id') registryId: string,
|
||||
@Body() updateDockerRegistryDto: UpdateDockerRegistryDto,
|
||||
): Promise<DockerRegistryDto> {
|
||||
return this.dockerRegistryService.update(registryId, updateDockerRegistryDto)
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@ApiOperation({
|
||||
summary: 'Delete registry',
|
||||
operationId: 'deleteRegistry',
|
||||
})
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
description: 'ID of the docker registry',
|
||||
type: 'string',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 204,
|
||||
description: 'The docker registry has been successfully deleted.',
|
||||
})
|
||||
@HttpCode(204)
|
||||
@RequiredOrganizationResourcePermissions([OrganizationResourcePermission.DELETE_REGISTRIES])
|
||||
@UseGuards(DockerRegistryAccessGuard)
|
||||
async remove(@Param('id') registryId: string): Promise<void> {
|
||||
return this.dockerRegistryService.remove(registryId)
|
||||
}
|
||||
|
||||
@Post(':id/set-default')
|
||||
@ApiOperation({
|
||||
summary: 'Set default registry',
|
||||
operationId: 'setDefaultRegistry',
|
||||
})
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
description: 'ID of the docker registry',
|
||||
type: 'string',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'The docker registry has been set as default.',
|
||||
type: DockerRegistryDto,
|
||||
})
|
||||
@RequiredOrganizationResourcePermissions([OrganizationResourcePermission.WRITE_REGISTRIES])
|
||||
@UseGuards(DockerRegistryAccessGuard)
|
||||
async setDefault(@Param('id') registryId: string): Promise<DockerRegistryDto> {
|
||||
return this.dockerRegistryService.setDefault(registryId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { createParamDecorator, ExecutionContext } from '@nestjs/common'
|
||||
|
||||
export const DockerRegistry = createParamDecorator((data: unknown, ctx: ExecutionContext) => {
|
||||
const request = ctx.switchToHttp().getRequest()
|
||||
return request.dockerRegistry
|
||||
})
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Module } from '@nestjs/common'
|
||||
import { TypeOrmModule } from '@nestjs/typeorm'
|
||||
import { DockerRegistry } from './entities/docker-registry.entity'
|
||||
import { DockerRegistryService } from './services/docker-registry.service'
|
||||
import { DockerRegistryController } from './controllers/docker-registry.controller'
|
||||
import { HttpModule } from '@nestjs/axios'
|
||||
import { DockerRegistryProvider } from './providers/docker-registry.provider'
|
||||
import { DOCKER_REGISTRY_PROVIDER } from './providers/docker-registry.provider.interface'
|
||||
import { OrganizationModule } from '../organization/organization.module'
|
||||
|
||||
@Module({
|
||||
imports: [OrganizationModule, TypeOrmModule.forFeature([DockerRegistry]), HttpModule],
|
||||
controllers: [DockerRegistryController],
|
||||
providers: [
|
||||
{
|
||||
provide: DOCKER_REGISTRY_PROVIDER,
|
||||
useClass: DockerRegistryProvider,
|
||||
},
|
||||
DockerRegistryService,
|
||||
],
|
||||
exports: [DockerRegistryService],
|
||||
})
|
||||
export class DockerRegistryModule {}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { IsString, IsUrl, IsEnum } from 'class-validator'
|
||||
import { ApiProperty, ApiSchema } from '@nestjs/swagger'
|
||||
import { RegistryType } from './../../docker-registry/enums/registry-type.enum'
|
||||
|
||||
@ApiSchema({ name: 'CreateDockerRegistry' })
|
||||
export class CreateDockerRegistryDto {
|
||||
@ApiProperty({
|
||||
description: 'Registry name',
|
||||
})
|
||||
@IsString()
|
||||
name: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Registry URL',
|
||||
})
|
||||
@IsUrl()
|
||||
url: string
|
||||
|
||||
@ApiProperty({ description: 'Registry username' })
|
||||
@IsString()
|
||||
username: string
|
||||
|
||||
@ApiProperty({ description: 'Registry password' })
|
||||
@IsString()
|
||||
password: string
|
||||
|
||||
@ApiProperty({ description: 'Registry project' })
|
||||
@IsString()
|
||||
project: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Registry type',
|
||||
enum: RegistryType,
|
||||
default: RegistryType.INTERNAL,
|
||||
})
|
||||
@IsEnum(RegistryType)
|
||||
registryType: RegistryType
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Set as default registry',
|
||||
default: false,
|
||||
})
|
||||
isDefault?: boolean
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { ApiProperty, ApiSchema } from '@nestjs/swagger'
|
||||
import { RegistryType } from './../../docker-registry/enums/registry-type.enum'
|
||||
|
||||
@ApiSchema({ name: 'DockerRegistry' })
|
||||
export class DockerRegistryDto {
|
||||
@ApiProperty({
|
||||
description: 'Registry ID',
|
||||
example: '123e4567-e89b-12d3-a456-426614174000',
|
||||
})
|
||||
id: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Registry name',
|
||||
example: 'My Docker Hub',
|
||||
})
|
||||
name: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Registry URL',
|
||||
example: 'https://registry.hub.docker.com',
|
||||
})
|
||||
url: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Registry username',
|
||||
example: 'username',
|
||||
})
|
||||
username: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Registry project',
|
||||
example: 'my-project',
|
||||
})
|
||||
project: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Registry type',
|
||||
enum: RegistryType,
|
||||
example: RegistryType.INTERNAL,
|
||||
})
|
||||
registryType: RegistryType
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Creation timestamp',
|
||||
example: '2024-01-31T12:00:00Z',
|
||||
})
|
||||
createdAt: Date
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Last update timestamp',
|
||||
example: '2024-01-31T12:00:00Z',
|
||||
})
|
||||
updatedAt: Date
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { IsString, IsOptional } from 'class-validator'
|
||||
import { ApiProperty, ApiSchema } from '@nestjs/swagger'
|
||||
|
||||
@ApiSchema({ name: 'UpdateDockerRegistry' })
|
||||
export class UpdateDockerRegistryDto {
|
||||
@ApiProperty({
|
||||
description: 'Registry name',
|
||||
required: true,
|
||||
})
|
||||
@IsString()
|
||||
name: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Registry username',
|
||||
required: true,
|
||||
})
|
||||
@IsString()
|
||||
username: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Registry password',
|
||||
required: false,
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
password?: string
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { RegistryType } from './../../docker-registry/enums/registry-type.enum'
|
||||
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
|
||||
|
||||
@Entity()
|
||||
export class DockerRegistry {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string
|
||||
|
||||
@Column()
|
||||
name: string
|
||||
|
||||
@Column()
|
||||
url: string
|
||||
|
||||
@Column()
|
||||
username: string
|
||||
|
||||
@Column()
|
||||
password: string
|
||||
|
||||
@Column({ default: false })
|
||||
isDefault: boolean
|
||||
|
||||
@Column()
|
||||
project: string
|
||||
|
||||
@Column({ nullable: true, type: 'uuid' })
|
||||
organizationId?: string
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: RegistryType,
|
||||
default: RegistryType.INTERNAL,
|
||||
})
|
||||
registryType: RegistryType
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedAt: Date
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
export enum RegistryType {
|
||||
INTERNAL = 'internal',
|
||||
ORGANIZATION = 'organization',
|
||||
PUBLIC = 'public',
|
||||
TRANSIENT = 'transient',
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Injectable, CanActivate, ExecutionContext, NotFoundException, ForbiddenException } from '@nestjs/common'
|
||||
import { DockerRegistryService } from '../services/docker-registry.service'
|
||||
import { OrganizationAuthContext } from '../../common/interfaces/auth-context.interface'
|
||||
import { SystemRole } from '../../user/enums/system-role.enum'
|
||||
|
||||
@Injectable()
|
||||
export class DockerRegistryAccessGuard implements CanActivate {
|
||||
constructor(private readonly dockerRegistryService: DockerRegistryService) {}
|
||||
|
||||
async canActivate(context: ExecutionContext): Promise<boolean> {
|
||||
const request = context.switchToHttp().getRequest()
|
||||
const dockerRegistryId: string = request.params.dockerRegistryId || request.params.registryId || request.params.id
|
||||
|
||||
// TODO: initialize authContext safely
|
||||
const authContext: OrganizationAuthContext = request.user
|
||||
|
||||
try {
|
||||
const dockerRegistry = await this.dockerRegistryService.findOneOrFail(dockerRegistryId)
|
||||
if (authContext.role !== SystemRole.ADMIN && dockerRegistry.organizationId !== authContext.organizationId) {
|
||||
throw new ForbiddenException('Request organization ID does not match resource organization ID')
|
||||
}
|
||||
request.dockerRegistry = dockerRegistry
|
||||
return true
|
||||
} catch (error) {
|
||||
throw new NotFoundException(`Docker registry with ID ${dockerRegistryId} not found`)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
export const DOCKER_REGISTRY_PROVIDER = 'DOCKER_REGISTRY_PROVIDER'
|
||||
|
||||
export interface IDockerRegistryProvider {
|
||||
createRobotAccount(
|
||||
url: string,
|
||||
auth: { username: string; password: string },
|
||||
robotConfig: {
|
||||
name: string
|
||||
description: string
|
||||
duration: number
|
||||
level: string
|
||||
permissions: Array<{
|
||||
kind: string
|
||||
namespace: string
|
||||
access: Array<{ resource: string; action: string }>
|
||||
}>
|
||||
},
|
||||
): Promise<{ name: string; secret: string }>
|
||||
|
||||
deleteArtifact(
|
||||
baseUrl: string,
|
||||
auth: { username: string; password: string },
|
||||
params: { project: string; repository: string; tag: string },
|
||||
): Promise<void>
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { HttpService } from '@nestjs/axios'
|
||||
import { firstValueFrom } from 'rxjs'
|
||||
import { IDockerRegistryProvider } from './docker-registry.provider.interface'
|
||||
|
||||
@Injectable()
|
||||
export class DockerRegistryProvider implements IDockerRegistryProvider {
|
||||
constructor(private readonly httpService: HttpService) {}
|
||||
|
||||
async createRobotAccount(
|
||||
url: string,
|
||||
auth: { username: string; password: string },
|
||||
robotConfig: {
|
||||
name: string
|
||||
description: string
|
||||
duration: number
|
||||
level: string
|
||||
permissions: Array<{
|
||||
kind: string
|
||||
namespace: string
|
||||
access: Array<{ resource: string; action: string }>
|
||||
}>
|
||||
},
|
||||
): Promise<{ name: string; secret: string }> {
|
||||
const response = await firstValueFrom(this.httpService.post(url, robotConfig, { auth }))
|
||||
return {
|
||||
name: response.data.name,
|
||||
secret: response.data.secret,
|
||||
}
|
||||
}
|
||||
|
||||
async deleteArtifact(
|
||||
baseUrl: string,
|
||||
auth: { username: string; password: string },
|
||||
params: { project: string; repository: string; tag: string },
|
||||
): Promise<void> {
|
||||
const url = `${baseUrl}/api/v2.0/projects/${params.project}/repositories/${params.repository}/artifacts/${params.tag}`
|
||||
|
||||
try {
|
||||
await firstValueFrom(this.httpService.delete(url, { auth }))
|
||||
} catch (error) {
|
||||
if (error.response?.status === 404) {
|
||||
return // Artifact not found, consider it a success
|
||||
}
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { IDockerRegistryProvider } from './docker-registry.provider.interface'
|
||||
|
||||
export class MockDockerRegistryProvider implements IDockerRegistryProvider {
|
||||
async createRobotAccount(): Promise<{ name: string; secret: string }> {
|
||||
return {
|
||||
name: 'mock-robot',
|
||||
secret: 'mock-secret',
|
||||
}
|
||||
}
|
||||
|
||||
async deleteArtifact(): Promise<void> {
|
||||
return Promise.resolve()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { ForbiddenException, Inject, Injectable, NotFoundException } from '@nestjs/common'
|
||||
import { InjectRepository } from '@nestjs/typeorm'
|
||||
import { IsNull, Repository } from 'typeorm'
|
||||
import { DockerRegistry } from '../entities/docker-registry.entity'
|
||||
import { CreateDockerRegistryDto } from '../dto/create-docker-registry.dto'
|
||||
import { UpdateDockerRegistryDto } from '../dto/update-docker-registry.dto'
|
||||
import { ApiOAuth2 } from '@nestjs/swagger'
|
||||
import { RegistryPushAccessDto } from '../../workspace/dto/registry-push-access-dto'
|
||||
import {
|
||||
DOCKER_REGISTRY_PROVIDER,
|
||||
IDockerRegistryProvider,
|
||||
} from './../../docker-registry/providers/docker-registry.provider.interface'
|
||||
import { RegistryType } from './../../docker-registry/enums/registry-type.enum'
|
||||
|
||||
@Injectable()
|
||||
@ApiOAuth2(['openid', 'profile', 'email'])
|
||||
export class DockerRegistryService {
|
||||
constructor(
|
||||
@InjectRepository(DockerRegistry)
|
||||
private readonly dockerRegistryRepository: Repository<DockerRegistry>,
|
||||
@Inject(DOCKER_REGISTRY_PROVIDER)
|
||||
private readonly dockerRegistryProvider: IDockerRegistryProvider,
|
||||
) {}
|
||||
|
||||
async create(createDto: CreateDockerRegistryDto, organizationId?: string): Promise<DockerRegistry> {
|
||||
// set some limit to the number of registries
|
||||
if (organizationId) {
|
||||
const registries = await this.dockerRegistryRepository.find({
|
||||
where: { organizationId },
|
||||
})
|
||||
if (registries.length >= 100) {
|
||||
throw new ForbiddenException('You have reached the maximum number of registries')
|
||||
}
|
||||
}
|
||||
|
||||
const registry = this.dockerRegistryRepository.create({
|
||||
...createDto,
|
||||
organizationId,
|
||||
})
|
||||
return this.dockerRegistryRepository.save(registry)
|
||||
}
|
||||
|
||||
async findAll(organizationId: string): Promise<DockerRegistry[]> {
|
||||
return this.dockerRegistryRepository.find({
|
||||
where: { organizationId },
|
||||
order: {
|
||||
createdAt: 'DESC',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async findOne(registryId: string): Promise<DockerRegistry | null> {
|
||||
return this.dockerRegistryRepository.findOne({
|
||||
where: { id: registryId },
|
||||
})
|
||||
}
|
||||
|
||||
async findOneOrFail(registryId: string): Promise<DockerRegistry> {
|
||||
return this.dockerRegistryRepository.findOneOrFail({
|
||||
where: { id: registryId },
|
||||
})
|
||||
}
|
||||
|
||||
async update(registryId: string, updateDto: UpdateDockerRegistryDto): Promise<DockerRegistry> {
|
||||
const registry = await this.dockerRegistryRepository.findOne({
|
||||
where: { id: registryId },
|
||||
})
|
||||
|
||||
if (!registry) {
|
||||
throw new NotFoundException(`Docker registry with ID ${registryId} not found`)
|
||||
}
|
||||
|
||||
registry.name = updateDto.name
|
||||
registry.username = updateDto.username
|
||||
if (updateDto.password) {
|
||||
registry.password = updateDto.password
|
||||
}
|
||||
|
||||
return this.dockerRegistryRepository.save(registry)
|
||||
}
|
||||
|
||||
async remove(registryId: string): Promise<void> {
|
||||
const registry = await this.dockerRegistryRepository.findOne({
|
||||
where: { id: registryId },
|
||||
})
|
||||
|
||||
if (!registry) {
|
||||
throw new NotFoundException(`Docker registry with ID ${registryId} not found`)
|
||||
}
|
||||
|
||||
await this.dockerRegistryRepository.remove(registry)
|
||||
}
|
||||
|
||||
async setDefault(registryId: string): Promise<DockerRegistry> {
|
||||
const registry = await this.dockerRegistryRepository.findOne({
|
||||
where: { id: registryId },
|
||||
})
|
||||
|
||||
if (!registry) {
|
||||
throw new NotFoundException(`Docker registry with ID ${registryId} not found`)
|
||||
}
|
||||
|
||||
await this.unsetDefaultRegistry()
|
||||
|
||||
registry.isDefault = true
|
||||
return this.dockerRegistryRepository.save(registry)
|
||||
}
|
||||
|
||||
private async unsetDefaultRegistry(): Promise<void> {
|
||||
await this.dockerRegistryRepository.update({ isDefault: true }, { isDefault: false })
|
||||
}
|
||||
|
||||
async getDefaultInternalRegistry(): Promise<DockerRegistry | null> {
|
||||
return this.dockerRegistryRepository.findOne({
|
||||
where: { isDefault: true, registryType: RegistryType.INTERNAL },
|
||||
})
|
||||
}
|
||||
|
||||
async getDefaultTransientRegistry(): Promise<DockerRegistry | null> {
|
||||
return this.dockerRegistryRepository.findOne({
|
||||
where: { isDefault: true, registryType: RegistryType.TRANSIENT },
|
||||
})
|
||||
}
|
||||
|
||||
async findOneByImageName(imageName: string, organizationId?: string): Promise<DockerRegistry | null> {
|
||||
const registries = await this.dockerRegistryRepository.find({
|
||||
where: [...(organizationId && [{ organizationId }]), { organizationId: IsNull() }],
|
||||
})
|
||||
|
||||
// Try to find a registry that matches the image name pattern
|
||||
for (const registry of registries) {
|
||||
const strippedUrl = registry.url.replace(/^(https?:\/\/)/, '')
|
||||
if (imageName.startsWith(strippedUrl)) {
|
||||
return registry
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
async getRegistryPushAccess(organizationId: string, userId: string): Promise<RegistryPushAccessDto> {
|
||||
const transientRegistry = await this.getDefaultTransientRegistry()
|
||||
if (!transientRegistry) {
|
||||
throw new Error('No default transient registry configured')
|
||||
}
|
||||
|
||||
const uniqueId = crypto.randomUUID().replace(/-/g, '').slice(0, 12)
|
||||
const robotName = `temp-push-robot-${uniqueId}`
|
||||
const expiresAt = new Date()
|
||||
expiresAt.setHours(expiresAt.getHours() + 1) // Token valid for 1 hour
|
||||
|
||||
const url = this.getRegistryUrl(transientRegistry) + '/api/v2.0/robots'
|
||||
|
||||
try {
|
||||
const response = await this.dockerRegistryProvider.createRobotAccount(
|
||||
url,
|
||||
{
|
||||
username: transientRegistry.username,
|
||||
password: transientRegistry.password,
|
||||
},
|
||||
{
|
||||
name: robotName,
|
||||
description: `Temporary push access for user ${userId} in organization ${organizationId}`,
|
||||
duration: 3600,
|
||||
level: 'project',
|
||||
permissions: [
|
||||
{
|
||||
kind: 'project',
|
||||
namespace: transientRegistry.project,
|
||||
access: [{ resource: 'repository', action: 'push' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
return {
|
||||
username: response.name,
|
||||
secret: response.secret,
|
||||
registryId: transientRegistry.id,
|
||||
registryUrl: new URL(url).host,
|
||||
project: transientRegistry.project,
|
||||
expiresAt: expiresAt.toISOString(),
|
||||
}
|
||||
} catch (error) {
|
||||
let errorMessage = `Failed to generate push token: ${error.message}`
|
||||
if (error.response) {
|
||||
errorMessage += ` - ${error.response.data.message || error.response.statusText}`
|
||||
}
|
||||
throw new Error(errorMessage)
|
||||
}
|
||||
}
|
||||
|
||||
async removeImage(imageName: string, registryId: string): Promise<void> {
|
||||
const registry = await this.findOne(registryId)
|
||||
if (!registry) {
|
||||
throw new Error('Registry not found')
|
||||
}
|
||||
|
||||
// Parse fully qualified image name
|
||||
// Example: harbor-test.internal.daytona.app/daytona/busybox:1.36.1
|
||||
const [nameWithTag, tag] = imageName.split(':')
|
||||
|
||||
// Remove registry hostname if present
|
||||
const parts = nameWithTag.split('/')
|
||||
let project: string
|
||||
let repository: string
|
||||
|
||||
if (parts.length >= 3 && parts[0].includes('.')) {
|
||||
// Format: hostname/project/repository
|
||||
project = parts[1]
|
||||
repository = parts.slice(2).join('/')
|
||||
} else if (parts.length === 2) {
|
||||
// Format: project/repository
|
||||
;[project, repository] = parts
|
||||
} else {
|
||||
throw new Error('Invalid image name format. Expected: [registry]/project/repository[:tag]')
|
||||
}
|
||||
|
||||
try {
|
||||
await this.dockerRegistryProvider.deleteArtifact(
|
||||
this.getRegistryUrl(registry),
|
||||
{
|
||||
username: registry.username,
|
||||
password: registry.password,
|
||||
},
|
||||
{ project, repository, tag },
|
||||
)
|
||||
} catch (error) {
|
||||
const message = error.response?.data?.message || error.message
|
||||
throw new Error(`Failed to remove image ${imageName}: ${message}`)
|
||||
}
|
||||
}
|
||||
|
||||
getRegistryUrl(registry: DockerRegistry): string {
|
||||
// Dev mode
|
||||
if (registry.url === 'registry:5000') {
|
||||
return 'http://registry:5000'
|
||||
}
|
||||
|
||||
return registry.url.startsWith('http') ? registry.url : `https://${registry.url}`
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
export const EMAIL_MODULE_OPTIONS = 'EMAIL_MODULE_OPTIONS'
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { DynamicModule, Module } from '@nestjs/common'
|
||||
import { EmailService } from './services/email.service'
|
||||
import { EMAIL_MODULE_OPTIONS } from './constants'
|
||||
|
||||
export interface EmailModuleOptions {
|
||||
host: string
|
||||
port: number
|
||||
user?: string
|
||||
password?: string
|
||||
secure?: boolean
|
||||
from: string
|
||||
dashboardUrl: string
|
||||
}
|
||||
|
||||
@Module({})
|
||||
export class EmailModule {
|
||||
static forRoot(options: EmailModuleOptions): DynamicModule {
|
||||
return {
|
||||
module: EmailModule,
|
||||
providers: [
|
||||
{
|
||||
provide: EMAIL_MODULE_OPTIONS,
|
||||
useValue: options,
|
||||
},
|
||||
EmailService,
|
||||
],
|
||||
exports: [EmailService],
|
||||
}
|
||||
}
|
||||
|
||||
static forRootAsync(options: {
|
||||
useFactory: (...args: any[]) => Promise<EmailModuleOptions> | EmailModuleOptions
|
||||
inject?: any[]
|
||||
}): DynamicModule {
|
||||
return {
|
||||
module: EmailModule,
|
||||
providers: [
|
||||
{
|
||||
provide: EMAIL_MODULE_OPTIONS,
|
||||
useFactory: options.useFactory,
|
||||
inject: options.inject || [],
|
||||
},
|
||||
EmailService,
|
||||
],
|
||||
exports: [EmailService],
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { renderFile } from 'ejs'
|
||||
import { createTransport, Transporter } from 'nodemailer'
|
||||
import path from 'path'
|
||||
import { OnAsyncEvent } from '../../common/decorators/on-async-event.decorator'
|
||||
import { OrganizationEvents } from '../../organization/constants/organization-events.constant'
|
||||
import { OrganizationInvitationCreatedEvent } from '../../organization/events/organization-invitation-created.event'
|
||||
import { EmailModuleOptions } from '../email.module'
|
||||
|
||||
@Injectable()
|
||||
export class EmailService {
|
||||
private readonly transporter: Transporter | null
|
||||
private readonly logger = new Logger(EmailService.name)
|
||||
|
||||
constructor(@Inject('EMAIL_MODULE_OPTIONS') private readonly options: EmailModuleOptions) {
|
||||
const { host, port, user, password, secure, from, dashboardUrl } = this.options
|
||||
|
||||
if (!host || !port || !from) {
|
||||
this.logger.warn('Email configuration not found, email functionality will be disabled')
|
||||
this.transporter = null
|
||||
return
|
||||
}
|
||||
|
||||
this.transporter = createTransport({
|
||||
host,
|
||||
port,
|
||||
auth: user && password ? { user, pass: password } : undefined,
|
||||
secure,
|
||||
from,
|
||||
})
|
||||
}
|
||||
|
||||
@OnAsyncEvent({
|
||||
event: OrganizationEvents.INVITATION_CREATED,
|
||||
})
|
||||
async handleOrganizationInvitationCreated(payload: OrganizationInvitationCreatedEvent): Promise<void> {
|
||||
if (!this.transporter) {
|
||||
this.logger.warn('Failed to send organization invitation email, email configuration not found')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await this.transporter.sendMail({
|
||||
to: payload.inviteeEmail,
|
||||
subject: 'Invitation to join a Daytona organization',
|
||||
html: await renderFile(path.join(__dirname, 'assets/templates/organization-invitation.template.ejs'), {
|
||||
organizationName: payload.organizationName,
|
||||
invitedBy: payload.invitedBy,
|
||||
invitationLink: `${this.options.dashboardUrl}/user/invitations?id=${payload.invitationId}`,
|
||||
expiresAt: new Date(payload.expiresAt).toLocaleDateString('en-US', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
}),
|
||||
}),
|
||||
})
|
||||
} catch (error) {
|
||||
// TODO: resilient email sending
|
||||
this.logger.error(`Failed to send organization invitation email to ${payload.inviteeEmail}`, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { HttpException, HttpStatus } from '@nestjs/common'
|
||||
|
||||
export class BadRequestError extends HttpException {
|
||||
constructor(message: string) {
|
||||
super(message, HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { HttpException, HttpStatus } from '@nestjs/common'
|
||||
|
||||
export class ForbiddenOperationError extends HttpException {
|
||||
constructor(message: string) {
|
||||
super(message, HttpStatus.FORBIDDEN)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { HttpException, HttpStatus } from '@nestjs/common'
|
||||
|
||||
export class ResourceNotFoundError extends HttpException {
|
||||
constructor(message: string) {
|
||||
super(message, HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { HttpException, HttpStatus } from '@nestjs/common'
|
||||
|
||||
export class WorkspaceError extends HttpException {
|
||||
constructor(message: string) {
|
||||
super(message, HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user