mirror of
https://github.com/ershisan99/coolify.git
synced 2025-12-25 20:49:28 +00:00
Compare commits
182 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73bd62c51e | ||
|
|
9acd5c94e8 | ||
|
|
6e85eac14b | ||
|
|
936baf676e | ||
|
|
867f06d813 | ||
|
|
7f9f440789 | ||
|
|
5a15e64471 | ||
|
|
c9aecd51f3 | ||
|
|
6ca1d978d4 | ||
|
|
a18c73bd7c | ||
|
|
26d86cbcb5 | ||
|
|
b24a5d9aca | ||
|
|
5305bc1ceb | ||
|
|
a672f0f56c | ||
|
|
9ab5e13e8f | ||
|
|
a49171f8cc | ||
|
|
65d8dc412a | ||
|
|
8600400632 | ||
|
|
11d10bee12 | ||
|
|
dbd16e8285 | ||
|
|
eb26787079 | ||
|
|
b0a7b1eb3d | ||
|
|
f994092d7f | ||
|
|
946d8e5be5 | ||
|
|
6d7c2ae74a | ||
|
|
1ba71b0b1b | ||
|
|
47c3af6a0e | ||
|
|
e5527a5aa5 | ||
|
|
9bb0dcd73f | ||
|
|
4159804052 | ||
|
|
adb27cf143 | ||
|
|
a4879d854f | ||
|
|
8b92dfb889 | ||
|
|
eb4868cb6e | ||
|
|
e06e6e05ae | ||
|
|
4fce4f81c7 | ||
|
|
ae11283574 | ||
|
|
15fc9aa483 | ||
|
|
2ebfb8e6a9 | ||
|
|
d098ea675f | ||
|
|
8ad152e5fc | ||
|
|
14077fcf51 | ||
|
|
b427573e19 | ||
|
|
46268f0dcf | ||
|
|
006c178eb1 | ||
|
|
d63b20dabb | ||
|
|
fcf0a391ed | ||
|
|
263b9c4b3e | ||
|
|
1dc7355952 | ||
|
|
67e4a72a28 | ||
|
|
e6ea07f9b7 | ||
|
|
44a691ae29 | ||
|
|
290dbc43cb | ||
|
|
219f1f9f3f | ||
|
|
582170f26e | ||
|
|
4e2dad7720 | ||
|
|
d002ec72ad | ||
|
|
f6bb14f7c4 | ||
|
|
e1697848a5 | ||
|
|
4d48bba350 | ||
|
|
a690cc5564 | ||
|
|
be16f76034 | ||
|
|
ae4cf44728 | ||
|
|
4ac0df71b1 | ||
|
|
dbd948867c | ||
|
|
a9b5cd6c31 | ||
|
|
92f513d514 | ||
|
|
b239d21961 | ||
|
|
40e8dd4a8d | ||
|
|
a667435ef2 | ||
|
|
042b4e7587 | ||
|
|
c46a1b4a59 | ||
|
|
e6035d5479 | ||
|
|
008d090093 | ||
|
|
6ff080c36b | ||
|
|
086ca30323 | ||
|
|
17f3ecbbcb | ||
|
|
1f2c8c4ad2 | ||
|
|
bc03331c66 | ||
|
|
ffd1711d4f | ||
|
|
1cdbda1b6b | ||
|
|
fd15e5182d | ||
|
|
b4cc0fb0f3 | ||
|
|
fb2d03f2e1 | ||
|
|
ab261aba49 | ||
|
|
615bc8c5b9 | ||
|
|
3fc98c8c1b | ||
|
|
a5cc14e885 | ||
|
|
fe4c0a4f28 | ||
|
|
a21678b5b8 | ||
|
|
2272ea1139 | ||
|
|
e9affabf39 | ||
|
|
5a412000e1 | ||
|
|
30312de4dd | ||
|
|
d9a775de16 | ||
|
|
3d7cd78d0e | ||
|
|
ccd550bbc4 | ||
|
|
a6ffb5c61c | ||
|
|
cb7659bb86 | ||
|
|
391f21f57e | ||
|
|
fdce70937f | ||
|
|
2060619e5b | ||
|
|
d7fd1fc65b | ||
|
|
6760d7e776 | ||
|
|
d61187c836 | ||
|
|
f9932f9fee | ||
|
|
c003e56c03 | ||
|
|
4d94106bff | ||
|
|
3bd2d4f868 | ||
|
|
75b37ea0dc | ||
|
|
c356d0455d | ||
|
|
278f75e70c | ||
|
|
2c7c5a3dc3 | ||
|
|
806ffacedd | ||
|
|
93246f80c4 | ||
|
|
e9723d3f22 | ||
|
|
6baec7277f | ||
|
|
d43554d290 | ||
|
|
1922e5e014 | ||
|
|
6c065a64fa | ||
|
|
3b6e5853d8 | ||
|
|
463fee429b | ||
|
|
570b286ef9 | ||
|
|
4c5e71f33c | ||
|
|
3884483bca | ||
|
|
fc1a89cc63 | ||
|
|
c471eed808 | ||
|
|
35450dfc8f | ||
|
|
5360c60f3d | ||
|
|
f60c640dc6 | ||
|
|
91bb323e84 | ||
|
|
cf9e122bd2 | ||
|
|
7528ca18d8 | ||
|
|
05ee35b6bc | ||
|
|
0e8b069781 | ||
|
|
3b95d7278d | ||
|
|
7691706295 | ||
|
|
2af65ee946 | ||
|
|
279e1fd9c5 | ||
|
|
0f8f33e9fe | ||
|
|
12e91f1c6b | ||
|
|
f4f605867b | ||
|
|
ac40abba2e | ||
|
|
224604f2e7 | ||
|
|
ee4360de3a | ||
|
|
0af59b9602 | ||
|
|
ff8fe68f14 | ||
|
|
71c15e0ff5 | ||
|
|
6be1fbacde | ||
|
|
be594dd49e | ||
|
|
6b65d435fb | ||
|
|
0dc5212066 | ||
|
|
7c8ffd510e | ||
|
|
8e6423e873 | ||
|
|
c99f74b351 | ||
|
|
57b462223c | ||
|
|
055db97273 | ||
|
|
c80ebf73ee | ||
|
|
9b613294ae | ||
|
|
8cb73e1680 | ||
|
|
27dfa24cfb | ||
|
|
c53f0dbb30 | ||
|
|
db16a357e8 | ||
|
|
01e71958b2 | ||
|
|
f379519d40 | ||
|
|
54a09958d5 | ||
|
|
3421de06d5 | ||
|
|
e44eb01396 | ||
|
|
313143586b | ||
|
|
c8ae72893a | ||
|
|
cbc3735ca0 | ||
|
|
31fdbdf8c9 | ||
|
|
2741d0ab2a | ||
|
|
79b0187b58 | ||
|
|
bf5659d0e2 | ||
|
|
f6314cab69 | ||
|
|
4f5fe3d383 | ||
|
|
1c720d587c | ||
|
|
c46dc99224 | ||
|
|
5e43d4f20d | ||
|
|
359434bfd3 | ||
|
|
e755a2d4ec |
@@ -8,7 +8,7 @@
|
|||||||
// Append -bullseye or -buster to pin to an OS version.
|
// Append -bullseye or -buster to pin to an OS version.
|
||||||
// Use -bullseye variants on local arm64/Apple Silicon.
|
// Use -bullseye variants on local arm64/Apple Silicon.
|
||||||
"args": {
|
"args": {
|
||||||
"VARIANT": "16-bullseye"
|
"VARIANT": "18-bullseye"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Set *default* container specific settings.json values on container create.
|
// Set *default* container specific settings.json values on container create.
|
||||||
@@ -23,9 +23,9 @@
|
|||||||
"bradlc.vscode-tailwindcss"
|
"bradlc.vscode-tailwindcss"
|
||||||
],
|
],
|
||||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
"forwardPorts": [3000],
|
"forwardPorts": [3000, 3001],
|
||||||
// Use 'postCreateCommand' to run commands after the container is created.
|
// Use 'postCreateCommand' to run commands after the container is created.
|
||||||
"postCreateCommand": "cp .env.template .env && pnpm install && pnpm db:push && pnpm db:seed",
|
"postCreateCommand": "cp apps/api/.env.example pps/api/.env && pnpm install && pnpm db:push && pnpm db:seed",
|
||||||
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
||||||
"remoteUser": "node",
|
"remoteUser": "node",
|
||||||
"features": {
|
"features": {
|
||||||
|
|||||||
4
.github/workflows/production-release.yml
vendored
4
.github/workflows/production-release.yml
vendored
@@ -2,7 +2,7 @@ name: production-release
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types: [released]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
making-something-cool:
|
making-something-cool:
|
||||||
@@ -34,4 +34,4 @@ jobs:
|
|||||||
- uses: sarisia/actions-status-discord@v1
|
- uses: sarisia/actions-status-discord@v1
|
||||||
if: always()
|
if: always()
|
||||||
with:
|
with:
|
||||||
webhook: ${{ secrets.DISCORD_WEBHOOK_DEV_CHANNEL }}
|
webhook: ${{ secrets.DISCORD_WEBHOOK_PROD_RELEASE_CHANNEL }}
|
||||||
|
|||||||
39
.github/workflows/release-candidate.yml
vendored
Normal file
39
.github/workflows/release-candidate.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
name: release-candidate
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [prereleased]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
making-something-cool:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: 'next'
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Get current package version
|
||||||
|
uses: martinbeentjes/npm-get-version-action@v1.2.3
|
||||||
|
id: package-version
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: coollabsio/coolify:${{github.event.release.name}}
|
||||||
|
cache-from: type=registry,ref=coollabsio/coolify:buildcache-rc
|
||||||
|
cache-to: type=registry,ref=coollabsio/coolify:buildcache-rc,mode=max
|
||||||
|
- uses: sarisia/actions-status-discord@v1
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
webhook: ${{ secrets.DISCORD_WEBHOOK_DEV_RELEASE_CHANNEL }}
|
||||||
2
.github/workflows/staging-release.yml
vendored
2
.github/workflows/staging-release.yml
vendored
@@ -32,4 +32,4 @@ jobs:
|
|||||||
- uses: sarisia/actions-status-discord@v1
|
- uses: sarisia/actions-status-discord@v1
|
||||||
if: always()
|
if: always()
|
||||||
with:
|
with:
|
||||||
webhook: ${{ secrets.DISCORD_WEBHOOK_DEV_CHANNEL }}
|
webhook: ${{ secrets.DISCORD_WEBHOOK_DEV_RELEASE_CHANNEL }}
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -11,4 +11,5 @@ dist
|
|||||||
client
|
client
|
||||||
apps/api/db/*.db
|
apps/api/db/*.db
|
||||||
local-serve
|
local-serve
|
||||||
apps/api/db/migration.db-journal
|
apps/api/db/migration.db-journal
|
||||||
|
apps/api/core*
|
||||||
94
CODE_OF_CONDUCT.md
Normal file
94
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
# Citizen Code of Conduct
|
||||||
|
|
||||||
|
## 1. Purpose
|
||||||
|
|
||||||
|
A primary goal of Coolify is to be inclusive to the largest number of contributors, with the most varied and diverse backgrounds possible. As such, we are committed to providing a friendly, safe and welcoming environment for all, regardless of gender, sexual orientation, ability, ethnicity, socioeconomic status, and religion (or lack thereof).
|
||||||
|
|
||||||
|
This code of conduct outlines our expectations for all those who participate in our community, as well as the consequences for unacceptable behavior.
|
||||||
|
|
||||||
|
We invite all those who participate in Coolify to help us create safe and positive experiences for everyone.
|
||||||
|
|
||||||
|
## 2. Open [Source/Culture/Tech] Citizenship
|
||||||
|
|
||||||
|
A supplemental goal of this Code of Conduct is to increase open [source/culture/tech] citizenship by encouraging participants to recognize and strengthen the relationships between our actions and their effects on our community.
|
||||||
|
|
||||||
|
Communities mirror the societies in which they exist and positive action is essential to counteract the many forms of inequality and abuses of power that exist in society.
|
||||||
|
|
||||||
|
If you see someone who is making an extra effort to ensure our community is welcoming, friendly, and encourages all participants to contribute to the fullest extent, we want to know.
|
||||||
|
|
||||||
|
## 3. Expected Behavior
|
||||||
|
|
||||||
|
The following behaviors are expected and requested of all community members:
|
||||||
|
|
||||||
|
* Participate in an authentic and active way. In doing so, you contribute to the health and longevity of this community.
|
||||||
|
* Exercise consideration and respect in your speech and actions.
|
||||||
|
* Attempt collaboration before conflict.
|
||||||
|
* Refrain from demeaning, discriminatory, or harassing behavior and speech.
|
||||||
|
* Be mindful of your surroundings and of your fellow participants. Alert community leaders if you notice a dangerous situation, someone in distress, or violations of this Code of Conduct, even if they seem inconsequential.
|
||||||
|
* Remember that community event venues may be shared with members of the public; please be respectful to all patrons of these locations.
|
||||||
|
|
||||||
|
## 4. Unacceptable Behavior
|
||||||
|
|
||||||
|
The following behaviors are considered harassment and are unacceptable within our community:
|
||||||
|
|
||||||
|
* Violence, threats of violence or violent language directed against another person.
|
||||||
|
* Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory jokes and language.
|
||||||
|
* Posting or displaying sexually explicit or violent material.
|
||||||
|
* Posting or threatening to post other people's personally identifying information ("doxing").
|
||||||
|
* Personal insults, particularly those related to gender, sexual orientation, race, religion, or disability.
|
||||||
|
* Inappropriate photography or recording.
|
||||||
|
* Inappropriate physical contact. You should have someone's consent before touching them.
|
||||||
|
* Unwelcome sexual attention. This includes, sexualized comments or jokes; inappropriate touching, groping, and unwelcomed sexual advances.
|
||||||
|
* Deliberate intimidation, stalking or following (online or in person).
|
||||||
|
* Advocating for, or encouraging, any of the above behavior.
|
||||||
|
* Sustained disruption of community events, including talks and presentations.
|
||||||
|
|
||||||
|
## 5. Weapons Policy
|
||||||
|
|
||||||
|
No weapons will be allowed at Coolify events, community spaces, or in other spaces covered by the scope of this Code of Conduct. Weapons include but are not limited to guns, explosives (including fireworks), and large knives such as those used for hunting or display, as well as any other item used for the purpose of causing injury or harm to others. Anyone seen in possession of one of these items will be asked to leave immediately, and will only be allowed to return without the weapon. Community members are further expected to comply with all state and local laws on this matter.
|
||||||
|
|
||||||
|
## 6. Consequences of Unacceptable Behavior
|
||||||
|
|
||||||
|
Unacceptable behavior from any community member, including sponsors and those with decision-making authority, will not be tolerated.
|
||||||
|
|
||||||
|
Anyone asked to stop unacceptable behavior is expected to comply immediately.
|
||||||
|
|
||||||
|
If a community member engages in unacceptable behavior, the community organizers may take any action they deem appropriate, up to and including a temporary ban or permanent expulsion from the community without warning (and without refund in the case of a paid event).
|
||||||
|
|
||||||
|
## 7. Reporting Guidelines
|
||||||
|
|
||||||
|
If you are subject to or witness unacceptable behavior, or have any other concerns, please notify a community organizer as soon as possible. hi@coollabs.io.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Additionally, community organizers are available to help community members engage with local law enforcement or to otherwise help those experiencing unacceptable behavior feel safe. In the context of in-person events, organizers will also provide escorts as desired by the person experiencing distress.
|
||||||
|
|
||||||
|
## 8. Addressing Grievances
|
||||||
|
|
||||||
|
If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify coollabsio with a concise description of your grievance. Your grievance will be handled in accordance with our existing governing policies.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 9. Scope
|
||||||
|
|
||||||
|
We expect all community participants (contributors, paid or otherwise; sponsors; and other guests) to abide by this Code of Conduct in all community venues--online and in-person--as well as in all one-on-one communications pertaining to community business.
|
||||||
|
|
||||||
|
This code of conduct and its related procedures also applies to unacceptable behavior occurring outside the scope of community activities when such behavior has the potential to adversely affect the safety and well-being of community members.
|
||||||
|
|
||||||
|
## 10. Contact info
|
||||||
|
|
||||||
|
hi@coollabs.io
|
||||||
|
|
||||||
|
## 11. License and attribution
|
||||||
|
|
||||||
|
The Citizen Code of Conduct is distributed by [Stumptown Syndicate](http://stumptownsyndicate.org) under a [Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/).
|
||||||
|
|
||||||
|
Portions of text derived from the [Django Code of Conduct](https://www.djangoproject.com/conduct/) and the [Geek Feminism Anti-Harassment Policy](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy).
|
||||||
|
|
||||||
|
_Revision 2.3. Posted 6 March 2017._
|
||||||
|
|
||||||
|
_Revision 2.2. Posted 4 February 2016._
|
||||||
|
|
||||||
|
_Revision 2.1. Posted 23 June 2014._
|
||||||
|
|
||||||
|
_Revision 2.0, adopted by the [Stumptown Syndicate](http://stumptownsyndicate.org) board on 10 January 2013. Posted 17 March 2013._
|
||||||
155
CONTRIBUTING.md
155
CONTRIBUTING.md
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
First of all, thank you for considering contributing to my project! It means a lot 💜.
|
First of all, thank you for considering contributing to my project! It means a lot 💜.
|
||||||
|
|
||||||
Contribution guide is for v2, not applicable for v3
|
|
||||||
|
|
||||||
## 🙋 Want to help?
|
## 🙋 Want to help?
|
||||||
|
|
||||||
@@ -17,13 +16,17 @@ This is a little list of what you can do to help the project:
|
|||||||
|
|
||||||
## 👋 Introduction
|
## 👋 Introduction
|
||||||
|
|
||||||
### Setup with github codespaces
|
### Setup with Github codespaces
|
||||||
|
|
||||||
If you have github codespaces enabled then you can just create a codespace and run `pnpm dev` to run your the dev environment. All the required dependencies and packages has been configured for you already.
|
If you have github codespaces enabled then you can just create a codespace and run `pnpm dev` to run your the dev environment. All the required dependencies and packages has been configured for you already.
|
||||||
|
|
||||||
|
### Setup with Gitpod
|
||||||
|
|
||||||
|
If you have a [Gitpod](https://gitpod.io), you can just create a workspace from this repository, run `pnpm install && pnpm db:push && pnpm db:seed` and then `pnpm dev`. All the required dependencies and packages has been configured for you already.
|
||||||
|
|
||||||
### Setup locally in your machine
|
### Setup locally in your machine
|
||||||
|
|
||||||
> 🔴 At the moment, Coolify **doesn't support Windows**. You must use Linux or MacOS. 💡 Although windows users can use github codespaces for development
|
> 🔴 At the moment, Coolify **doesn't support Windows**. You must use Linux or MacOS. Consider using Gitpod or Github Codespaces.
|
||||||
|
|
||||||
#### Recommended Pull Request Guideline
|
#### Recommended Pull Request Guideline
|
||||||
|
|
||||||
@@ -31,21 +34,38 @@ If you have github codespaces enabled then you can just create a codespace and r
|
|||||||
- Clone your fork repo to local
|
- Clone your fork repo to local
|
||||||
- Create a new branch
|
- Create a new branch
|
||||||
- Push to your fork repo
|
- Push to your fork repo
|
||||||
- Create a pull request: https://github.com/coollabsio/compare
|
- Create a pull request: https://github.com/coollabsio/coolify/compare
|
||||||
- Write a proper description
|
- Write a proper description
|
||||||
- Open the pull request to review against `next` branch
|
- Open the pull request to review against `next` branch
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# How to start after you set up your local fork?
|
# 🧑💻 Developer contribution
|
||||||
|
## Technical skills required
|
||||||
|
|
||||||
Due to the lock file, this repository is best with [pnpm](https://pnpm.io). I recommend you try and use `pnpm` because it is cool and efficient!
|
- **Languages**: Node.js / Javascript / Typescript
|
||||||
|
- **Framework JS/TS**: [SvelteKit](https://kit.svelte.dev/) & [Fastify](https://www.fastify.io/)
|
||||||
|
- **Database ORM**: [Prisma.io](https://www.prisma.io/)
|
||||||
|
- **Docker Engine API**
|
||||||
|
|
||||||
You need to have [Docker Engine](https://docs.docker.com/engine/install/) installed locally.
|
---
|
||||||
|
|
||||||
#### Steps for local setup
|
## How to start after you set up your local fork?
|
||||||
|
|
||||||
1. Copy `.env.template` to `.env` and set the `COOLIFY_APP_ID` environment variable to something cool.
|
### Prerequisites
|
||||||
|
1. Due to the lock file, this repository is best with [pnpm](https://pnpm.io). I recommend you try and use `pnpm` because it is cool and efficient!
|
||||||
|
|
||||||
|
2. You need to have [Docker Engine](https://docs.docker.com/engine/install/) installed locally.
|
||||||
|
3. You need to have [Docker Compose Plugin](https://docs.docker.com/compose/install/compose-plugin/) installed locally.
|
||||||
|
4. You need to have [GIT LFS Support](https://git-lfs.github.com/) installed locally.
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
4. To test Heroku buildpacks, you need [pack](https://github.com/buildpacks/pack) binary installed locally.
|
||||||
|
|
||||||
|
### Steps for local setup
|
||||||
|
|
||||||
|
1. Copy `apps/api/.env.template` to `apps/api/.env.template` and set the `COOLIFY_APP_ID` environment variable to something cool.
|
||||||
2. Install dependencies with `pnpm install`.
|
2. Install dependencies with `pnpm install`.
|
||||||
3. Need to create a local SQlite database with `pnpm db:push`.
|
3. Need to create a local SQlite database with `pnpm db:push`.
|
||||||
|
|
||||||
@@ -54,28 +74,17 @@ You need to have [Docker Engine](https://docs.docker.com/engine/install/) instal
|
|||||||
4. Seed the database with base entities with `pnpm db:seed`
|
4. Seed the database with base entities with `pnpm db:seed`
|
||||||
5. You can start coding after starting `pnpm dev`.
|
5. You can start coding after starting `pnpm dev`.
|
||||||
|
|
||||||
## 🧑💻 Developer contribution
|
---
|
||||||
|
|
||||||
### Technical skills required
|
## Database migrations
|
||||||
|
|
||||||
- **Languages**: Node.js / Javascript / Typescript
|
|
||||||
- **Framework JS/TS**: Svelte / SvelteKit
|
|
||||||
- **Database ORM**: Prisma.io
|
|
||||||
- **Docker Engine**
|
|
||||||
|
|
||||||
### Database migrations
|
|
||||||
|
|
||||||
During development, if you change the database layout, you need to run `pnpm db:push` to migrate the database and create types for Prisma. You also need to restart the development process.
|
During development, if you change the database layout, you need to run `pnpm db:push` to migrate the database and create types for Prisma. You also need to restart the development process.
|
||||||
|
|
||||||
If the schema is finalized, you need to create a migration file with `pnpm db:migrate <nameOfMigration>` where `nameOfMigration` is given by you. Make it sense. :)
|
If the schema is finalized, you need to create a migration file with `pnpm db:migrate <nameOfMigration>` where `nameOfMigration` is given by you. Make it sense. :)
|
||||||
|
|
||||||
### Tricky parts
|
|
||||||
|
|
||||||
- BullMQ, the queue system Coolify uses, cannot be hot reloaded. So if you change anything in the files related to it, you need to restart the development process. I'm actively looking for a different queue/scheduler library. I'm open to discussion!
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# How to add new services
|
## How to add new services
|
||||||
|
|
||||||
You can add any open-source and self-hostable software (service/application) to Coolify if the following statements are true:
|
You can add any open-source and self-hostable software (service/application) to Coolify if the following statements are true:
|
||||||
|
|
||||||
@@ -95,14 +104,14 @@ There are 5 steps you should make on the backend side.
|
|||||||
|
|
||||||
> I will use [Umami](https://umami.is/) as an example service.
|
> I will use [Umami](https://umami.is/) as an example service.
|
||||||
|
|
||||||
### Create Prisma / database schema for the new service.
|
### Create Prisma / Database schema for the new service.
|
||||||
|
|
||||||
You only need to do this if you store passwords or any persistent configuration. Mostly it is required by all services, but there are some exceptions, like NocoDB.
|
You only need to do this if you store passwords or any persistent configuration. Mostly it is required by all services, but there are some exceptions, like NocoDB.
|
||||||
|
|
||||||
Update Prisma schema in [prisma/schema.prisma](prisma/schema.prisma).
|
Update Prisma schema in [prisma/schema.prisma](prisma/schema.prisma).
|
||||||
|
|
||||||
- Add new model with the new service name.
|
- Add new model with the new service name.
|
||||||
- Make a relationshup with `Service` model.
|
- Make a relationship with `Service` model.
|
||||||
- In the `Service` model, the name of the new field should be with low-capital.
|
- In the `Service` model, the name of the new field should be with low-capital.
|
||||||
- If the service needs a database, define a `publicPort` field to be able to make it's database public, example field name in case of PostgreSQL: `postgresqlPublicPort`. It should be a optional field.
|
- If the service needs a database, define a `publicPort` field to be able to make it's database public, example field name in case of PostgreSQL: `postgresqlPublicPort`. It should be a optional field.
|
||||||
|
|
||||||
@@ -110,13 +119,13 @@ If you are finished with the Prisma schema, you should update the database schem
|
|||||||
|
|
||||||
> You must restart the running development environment to be able to use the new model
|
> You must restart the running development environment to be able to use the new model
|
||||||
|
|
||||||
> If you use VSCode, you probably need to restart the `Typescript Language Server` to get the new types loaded in the running VSCode.
|
> If you use VSCode/TLS, you probably need to restart the `Typescript Language Server` to get the new types loaded in the running environment.
|
||||||
|
|
||||||
### Add supported versions
|
### Add supported versions
|
||||||
|
|
||||||
Supported versions are hardcoded into Coolify (for now).
|
Supported versions are hardcoded into Coolify (for now).
|
||||||
|
|
||||||
You need to update `supportedServiceTypesAndVersions` function at [src/lib/components/common.ts](src/lib/components/common.ts). Example JSON:
|
You need to update `supportedServiceTypesAndVersions` function at [apps/api/src/lib/services/supportedVersions.ts](apps/api/src/lib/services/supportedVersions.ts). Example JSON:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
@@ -139,12 +148,12 @@ You need to update `supportedServiceTypesAndVersions` function at [src/lib/compo
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Update global functions
|
### Add required functions/properties
|
||||||
|
|
||||||
1. Add the new service to the `include` variable in [src/lib/database/services.ts](src/lib/database/services.ts), so it will be included in all places in the database queries where it is required.
|
1. Add the new service to the `includeServices` variable in [apps/api/src/lib/services/common.ts](apps/api/src/lib/services/common.ts), so it will be included in all places in the database queries where it is required.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const include: Prisma.ServiceInclude = {
|
const include: any = {
|
||||||
destinationDocker: true,
|
destinationDocker: true,
|
||||||
persistentStorage: true,
|
persistentStorage: true,
|
||||||
serviceSecret: true,
|
serviceSecret: true,
|
||||||
@@ -158,7 +167,7 @@ const include: Prisma.ServiceInclude = {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Update the database update query with the new service type to `configureServiceType` function in [src/lib/database/services.ts](src/lib/database/services.ts). This function defines the automatically generated variables (passwords, users, etc.) and it's encryption process (if applicable).
|
2. Update the database update query with the new service type to `configureServiceType` function in [apps/api/src/lib/services/common.ts](apps/api/src/lib/services/common.ts). This function defines the automatically generated variables (passwords, users, etc.) and it's encryption process (if applicable).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
[...]
|
[...]
|
||||||
@@ -184,80 +193,46 @@ else if (type === 'umami') {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Add decryption process for configurations and passwords to `getService` function in [src/lib/database/services.ts](src/lib/database/services.ts)
|
3. Add field details to [apps/api/src/lib/services/serviceFields.ts](apps/api/src/lib/services/serviceFields.ts), so every component will know what to do with the values (decrypt/show it by default/readonly)
|
||||||
|
|
||||||
```js
|
```js
|
||||||
if (body.umami?.postgresqlPassword)
|
export const umami = [{
|
||||||
body.umami.postgresqlPassword = decrypt(body.umami.postgresqlPassword);
|
name: 'postgresqlUser',
|
||||||
|
isEditable: false,
|
||||||
if (body.umami?.hashSalt) body.umami.hashSalt = decrypt(body.umami.hashSalt);
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: false
|
||||||
|
}]
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Add service deletion query to `removeService` function in [src/lib/database/services.ts](src/lib/database/services.ts)
|
4. Add service deletion query to `removeService` function in [apps/api/src/lib/services/common.ts](apps/api/src/lib/services/common.ts)
|
||||||
|
|
||||||
### Create API endpoints.
|
5. Add start process for the new service in [apps/api/src/lib/services/handlers.ts](apps/api/src/lib/services/handlers.ts)
|
||||||
|
|
||||||
You need to add a new folder under [src/routes/services/[id]](src/routes/services/[id]) with the low-capital name of the service. You need 3 default files in that folder.
|
> See startUmamiService() function as example.
|
||||||
|
|
||||||
#### `index.json.ts`:
|
6. Add the newly added start process to `startService` in [apps/api/src/routes/api/v1/services/handlers.ts](apps/api/src/routes/api/v1/services/handlers.ts)
|
||||||
|
|
||||||
It has a POST endpoint that updates the service details in Coolify's database, such as name, url, other configurations, like passwords. It should look something like this:
|
7. You need to add a custom logo at [apps/ui/src/lib/components/svg/services](apps/ui/src/lib/components/svg/services) as a svelte component and export it in [apps/ui/src/lib/components/svg/services/index.ts](apps/ui/src/lib/components/svg/services/index.ts)
|
||||||
|
|
||||||
```js
|
|
||||||
import { getUserDetails } from '$lib/common';
|
|
||||||
import * as db from '$lib/database';
|
|
||||||
import { ErrorHandler } from '$lib/database';
|
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
|
||||||
|
|
||||||
export const post: RequestHandler = async (event) => {
|
|
||||||
const { status, body } = await getUserDetails(event);
|
|
||||||
if (status === 401) return { status, body };
|
|
||||||
|
|
||||||
const { id } = event.params;
|
|
||||||
|
|
||||||
let { name, fqdn } = await event.request.json();
|
|
||||||
if (fqdn) fqdn = fqdn.toLowerCase();
|
|
||||||
|
|
||||||
try {
|
|
||||||
await db.updateService({ id, fqdn, name });
|
|
||||||
return { status: 201 };
|
|
||||||
} catch (error) {
|
|
||||||
return ErrorHandler(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
If it's necessary, you can create your own database update function, specifically for the new service.
|
|
||||||
|
|
||||||
#### `start.json.ts`
|
|
||||||
|
|
||||||
It has a POST endpoint that sets all the required secrets, persistent volumes, `docker-compose.yaml` file and sends a request to the specified docker engine.
|
|
||||||
|
|
||||||
You could also define an `HTTP` or `TCP` proxy for every other port that should be proxied to your server. (See `startHttpProxy` and `startTcpProxy` functions in [src/lib/haproxy/index.ts](src/lib/haproxy/index.ts))
|
|
||||||
|
|
||||||
#### `stop.json.ts`
|
|
||||||
|
|
||||||
It has a POST endpoint that stops the service and all dependent (TCP/HTTP proxies) containers. If publicPort is specified it also needs to cleanup it from the database.
|
|
||||||
|
|
||||||
## Frontend
|
|
||||||
|
|
||||||
1. You need to add a custom logo at [src/lib/components/svg/services/](src/lib/components/svg/services/) as a svelte component.
|
|
||||||
|
|
||||||
SVG is recommended, but you can use PNG as well. It should have the `isAbsolute` variable with the suitable CSS classes, primarily for sizing and positioning.
|
SVG is recommended, but you can use PNG as well. It should have the `isAbsolute` variable with the suitable CSS classes, primarily for sizing and positioning.
|
||||||
|
|
||||||
2. You need to include it the logo at
|
8. You need to include it the logo at:
|
||||||
|
|
||||||
- [src/routes/services/index.svelte](src/routes/services/index.svelte) with `isAbsolute` in two places,
|
- [apps/ui/src/lib/components/svg/services/ServiceIcons.svelte](apps/ui/src/lib/components/svg/services/ServiceIcons.svelte) with `isAbsolute`.
|
||||||
- [src/lib/components/ServiceLinks.svelte](src/lib/components/ServiceLinks.svelte) with `isAbsolute` and a link to the docs/main site of the service
|
- [apps/ui/src/routes/services/[id]/_ServiceLinks.svelte](apps/ui/src/routes/services/[id]/_ServiceLinks.svelte) with the link to the docs/main site of the service
|
||||||
- [src/routes/services/[id]/configuration/type.svelte](src/routes/services/[id]/configuration/type.svelte) with `isAbsolute`.
|
|
||||||
|
|
||||||
3. By default the URL and the name frontend forms are included in [src/routes/services/[id]/\_Services/\_Services.svelte](src/routes/services/[id]/_Services/_Services.svelte).
|
9. By default the URL and the name frontend forms are included in [apps/ui/src/routes/services/[id]/_Services/_Services.svelte](apps/ui/src/routes/services/[id]/_Services/_Services.svelte).
|
||||||
|
|
||||||
If you need to show more details on the frontend, such as users/passwords, you need to add Svelte component to [src/routes/services/[id]/\_Services](src/routes/services/[id]/_Services) with an underscore. For example, see other files in that folder.
|
If you need to show more details on the frontend, such as users/passwords, you need to add Svelte component to [apps/ui/src/routes/services/[id]/_Services](apps/ui/src/routes/services/[id]/_Services) with an underscore.
|
||||||
|
|
||||||
|
> For example, see other [here](apps/ui/src/routes/services/[id]/_Services/_Umami.svelte).
|
||||||
|
|
||||||
You also need to add the new inputs to the `index.json.ts` file of the specific service, like for MinIO here: [src/routes/services/[id]/minio/index.json.ts](src/routes/services/[id]/minio/index.json.ts)
|
|
||||||
|
|
||||||
## 🌐 Translate the project
|
Good job! 👏
|
||||||
|
|
||||||
|
<!-- # 🌐 Translate the project
|
||||||
|
|
||||||
The project use [sveltekit-i18n](https://github.com/sveltekit-i18n/lib) to translate the project.
|
The project use [sveltekit-i18n](https://github.com/sveltekit-i18n/lib) to translate the project.
|
||||||
It follows the [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) to name languages.
|
It follows the [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) to name languages.
|
||||||
@@ -278,4 +253,4 @@ If your language doesn't appear in the [locales folder list](src/lib/locales/),
|
|||||||
|
|
||||||
1. In `src/lib/locales/`, Copy paste `en.json` and rename it with your language (eg: `cz.json`).
|
1. In `src/lib/locales/`, Copy paste `en.json` and rename it with your language (eg: `cz.json`).
|
||||||
2. In the [lang.json](src/lib/lang.json) file, add a line after the first bracket (`{`) with `"ISO of your language": "Language",` (eg: `"cz": "Czech",`).
|
2. In the [lang.json](src/lib/lang.json) file, add a line after the first bracket (`{`) with `"ISO of your language": "Language",` (eg: `"cz": "Czech",`).
|
||||||
3. Have fun translating!
|
3. Have fun translating! -->
|
||||||
|
|||||||
108
CONTRIBUTION_NEW.md
Normal file
108
CONTRIBUTION_NEW.md
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
---
|
||||||
|
head:
|
||||||
|
- - meta
|
||||||
|
- name: description
|
||||||
|
content: Coolify - Databases
|
||||||
|
- - meta
|
||||||
|
- name: keywords
|
||||||
|
content: databases coollabs coolify
|
||||||
|
- - meta
|
||||||
|
- name: twitter:card
|
||||||
|
content: summary_large_image
|
||||||
|
- - meta
|
||||||
|
- name: twitter:site
|
||||||
|
content: '@andrasbacsai'
|
||||||
|
- - meta
|
||||||
|
- name: twitter:title
|
||||||
|
content: Coolify
|
||||||
|
- - meta
|
||||||
|
- name: twitter:description
|
||||||
|
content: An open-source & self-hostable Heroku / Netlify alternative.
|
||||||
|
- - meta
|
||||||
|
- name: twitter:image
|
||||||
|
content: https://cdn.coollabs.io/assets/coollabs/og-image-databases.png
|
||||||
|
- - meta
|
||||||
|
- property: og:type
|
||||||
|
content: website
|
||||||
|
- - meta
|
||||||
|
- property: og:url
|
||||||
|
content: https://coolify.io
|
||||||
|
- - meta
|
||||||
|
- property: og:title
|
||||||
|
content: Coolify
|
||||||
|
- - meta
|
||||||
|
- property: og:description
|
||||||
|
content: An open-source & self-hostable Heroku / Netlify alternative.
|
||||||
|
- - meta
|
||||||
|
- property: og:site_name
|
||||||
|
content: Coolify
|
||||||
|
- - meta
|
||||||
|
- property: og:image
|
||||||
|
content: https://cdn.coollabs.io/assets/coollabs/og-image-databases.png
|
||||||
|
---
|
||||||
|
# Contribution
|
||||||
|
|
||||||
|
First, thanks for considering to contribute to my project. It really means a lot! :)
|
||||||
|
|
||||||
|
You can ask for guidance anytime on our Discord server in the #contribution channel.
|
||||||
|
|
||||||
|
## Setup your development environment
|
||||||
|
### Github codespaces
|
||||||
|
|
||||||
|
If you have github codespaces enabled then you can just create a codespace and run `pnpm dev` to run your the dev environment. All the required dependencies and packages has been configured for you already.
|
||||||
|
|
||||||
|
### Gitpod
|
||||||
|
|
||||||
|
If you have a [Gitpod](https://gitpod.io), you can just create a workspace from this repository, run `pnpm install && pnpm db:push && pnpm db:seed` and then `pnpm dev`. All the required dependencies and packages has been configured for you already.
|
||||||
|
|
||||||
|
### Local Machine
|
||||||
|
> At the moment, Coolify `doesn't support Windows`. You must use `Linux` or `MacOS` or consider using Gitpod or Github Codespaces.
|
||||||
|
|
||||||
|
- Due to the lock file, this repository is best with [pnpm](https://pnpm.io). I recommend you try and use `pnpm` because it is cool and efficient!
|
||||||
|
|
||||||
|
- You need to have [Docker Engine](https://docs.docker.com/engine/install/) installed locally.
|
||||||
|
- You need to have [Docker Compose Plugin](https://docs.docker.com/compose/install/compose-plugin/) installed locally.
|
||||||
|
- You need to have [GIT LFS Support](https://git-lfs.github.com/) installed locally.
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
- To test Heroku buildpacks, you need [pack](https://github.com/buildpacks/pack) binary installed locally.
|
||||||
|
|
||||||
|
### Inside a Docker container
|
||||||
|
`WIP`
|
||||||
|
|
||||||
|
## Setup Coolify
|
||||||
|
- Copy `apps/api/.env.template` to `apps/api/.env.template` and set the `COOLIFY_APP_ID` environment variable to something cool.
|
||||||
|
- `pnpm install` to install dependencies.
|
||||||
|
- `pnpm db:push` to o create a local SQlite database.
|
||||||
|
|
||||||
|
This will apply all migrations at `db/dev.db`.
|
||||||
|
|
||||||
|
- `pnpm db:seed` seed the database.
|
||||||
|
- `pnpm dev` start coding.
|
||||||
|
|
||||||
|
## Technical skills required
|
||||||
|
|
||||||
|
- **Languages**: Node.js / Javascript / Typescript
|
||||||
|
- **Framework JS/TS**: [SvelteKit](https://kit.svelte.dev/) & [Fastify](https://www.fastify.io/)
|
||||||
|
- **Database ORM**: [Prisma.io](https://www.prisma.io/)
|
||||||
|
- **Docker Engine API**
|
||||||
|
|
||||||
|
## Add a new service
|
||||||
|
### Which service is eligable to add to Coolify?
|
||||||
|
The following statements needs to be true:
|
||||||
|
|
||||||
|
- Self-hostable
|
||||||
|
- Open-source
|
||||||
|
- Maintained (I do not want to add software full of bugs)
|
||||||
|
|
||||||
|
### Create Prisma / Database schema for the new service.
|
||||||
|
All data that needs to be persist for a service should be saved to the database in `cleartext` or `encrypted`.
|
||||||
|
|
||||||
|
very password/api key/passphrase needs to be encrypted. If you are not sure, whether it should be encrypted or not, just encrypt it.
|
||||||
|
|
||||||
|
Update Prisma schema in [src/api/prisma/schema.prisma](https://github.com/coollabsio/coolify/blob/main/apps/api/prisma/schema.prisma).
|
||||||
|
|
||||||
|
- Add new model with the new service name.
|
||||||
|
- Make a relationship with `Service` model.
|
||||||
|
- In the `Service` model, the name of the new field should be with low-capital.
|
||||||
|
- If the service needs a database, define a `publicPort` field to be able to make it's database public, example field name in case of PostgreSQL: `postgresqlPublicPort`. It should be a optional field.
|
||||||
18
Dockerfile
18
Dockerfile
@@ -1,7 +1,7 @@
|
|||||||
FROM node:18-alpine3.16 as build
|
FROM node:18-slim as build
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN apk add --no-cache curl
|
RUN apt update && apt -y install curl
|
||||||
RUN curl -sL https://unpkg.com/@pnpm/self-installer | node
|
RUN curl -sL https://unpkg.com/@pnpm/self-installer | node
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
@@ -9,21 +9,12 @@ RUN pnpm install
|
|||||||
RUN pnpm build
|
RUN pnpm build
|
||||||
|
|
||||||
# Production build
|
# Production build
|
||||||
FROM node:18-alpine3.16
|
FROM node:18-slim
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENV NODE_ENV production
|
ENV NODE_ENV production
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
|
|
||||||
ENV PRISMA_QUERY_ENGINE_BINARY=/app/prisma-engines/query-engine \
|
RUN apt update && apt -y install git git-lfs openssh-client curl jq cmake sqlite3 openssl psmisc python3 && apt-get clean autoclean && apt-get autoremove --yes && rm -rf /var/lib/{apt,dpkg,cache,log}/
|
||||||
PRISMA_MIGRATION_ENGINE_BINARY=/app/prisma-engines/migration-engine \
|
|
||||||
PRISMA_INTROSPECTION_ENGINE_BINARY=/app/prisma-engines/introspection-engine \
|
|
||||||
PRISMA_FMT_BINARY=/app/prisma-engines/prisma-fmt \
|
|
||||||
PRISMA_CLI_QUERY_ENGINE_TYPE=binary \
|
|
||||||
PRISMA_CLIENT_ENGINE_TYPE=binary
|
|
||||||
|
|
||||||
COPY --from=coollabsio/prisma-engine:3.15 /prisma-engines/query-engine /prisma-engines/migration-engine /prisma-engines/introspection-engine /prisma-engines/prisma-fmt /app/prisma-engines/
|
|
||||||
|
|
||||||
RUN apk add --no-cache git git-lfs openssh-client curl jq cmake sqlite openssl psmisc
|
|
||||||
RUN curl -sL https://unpkg.com/@pnpm/self-installer | node
|
RUN curl -sL https://unpkg.com/@pnpm/self-installer | node
|
||||||
|
|
||||||
RUN mkdir -p ~/.docker/cli-plugins/
|
RUN mkdir -p ~/.docker/cli-plugins/
|
||||||
@@ -45,4 +36,5 @@ COPY --from=build /app/docker-compose.yaml .
|
|||||||
RUN pnpm install -p
|
RUN pnpm install -p
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
ENV CHECKPOINT_DISABLE=1
|
||||||
CMD pnpm start
|
CMD pnpm start
|
||||||
@@ -16,7 +16,7 @@ If you have a new service / build pack you would like to add, raise an idea [her
|
|||||||
|
|
||||||
## How to install
|
## How to install
|
||||||
|
|
||||||
For more details goto the [docs](https://docs.coollabs.io/coolify/installation.html).
|
For more details goto the [docs](https://docs.coollabs.io/coolify/installation).
|
||||||
|
|
||||||
Installation is automated with the following command:
|
Installation is automated with the following command:
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ A fresh installation is necessary. v2 and v3 are not compatible with v1.
|
|||||||
- Twitter: [@andrasbacsai](https://twitter.com/andrasbacsai)
|
- Twitter: [@andrasbacsai](https://twitter.com/andrasbacsai)
|
||||||
- Telegram: [@andrasbacsai](https://t.me/andrasbacsai)
|
- Telegram: [@andrasbacsai](https://t.me/andrasbacsai)
|
||||||
- Email: [andras@coollabs.io](mailto:andras@coollabs.io)
|
- Email: [andras@coollabs.io](mailto:andras@coollabs.io)
|
||||||
- Discord: [Invitation](https://discord.gg/6rDM4fkymF)
|
- Discord: [Invitation](https://coollabs.io/discord)
|
||||||
|
|
||||||
## Financial Contributors
|
## Financial Contributors
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
COOLIFY_APP_ID=
|
COOLIFY_APP_ID=local-dev
|
||||||
COOLIFY_SECRET_KEY="12341234123412341234123412341234 - 32 long"
|
# 32 bits long secret key
|
||||||
COOLIFY_DATABASE_URL=
|
COOLIFY_SECRET_KEY=12341234123412341234123412341234
|
||||||
|
COOLIFY_DATABASE_URL=file:../db/dev.db
|
||||||
COOLIFY_SENTRY_DSN=
|
COOLIFY_SENTRY_DSN=
|
||||||
|
|
||||||
COOLIFY_IS_ON=docker
|
COOLIFY_IS_ON=docker
|
||||||
|
|||||||
@@ -15,55 +15,57 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@breejs/ts-worker": "2.0.0",
|
"@breejs/ts-worker": "2.0.0",
|
||||||
"@fastify/autoload": "5.2.0",
|
"@fastify/autoload": "5.3.1",
|
||||||
"@fastify/cookie": "7.3.1",
|
"@fastify/cookie": "8.1.0",
|
||||||
"@fastify/cors": "8.1.0",
|
"@fastify/cors": "8.1.0",
|
||||||
"@fastify/env": "4.1.0",
|
"@fastify/env": "4.1.0",
|
||||||
"@fastify/jwt": "6.3.2",
|
"@fastify/jwt": "6.3.2",
|
||||||
"@fastify/static": "6.5.0",
|
"@fastify/static": "6.5.0",
|
||||||
"@iarna/toml": "2.2.5",
|
"@iarna/toml": "2.2.5",
|
||||||
"@prisma/client": "3.15.2",
|
"@ladjs/graceful": "3.0.2",
|
||||||
|
"@prisma/client": "4.3.1",
|
||||||
"axios": "0.27.2",
|
"axios": "0.27.2",
|
||||||
"bcryptjs": "2.4.3",
|
"bcryptjs": "2.4.3",
|
||||||
"bree": "9.1.2",
|
"bree": "9.1.2",
|
||||||
"cabin": "9.1.2",
|
"cabin": "9.1.2",
|
||||||
"compare-versions": "4.1.3",
|
"compare-versions": "5.0.1",
|
||||||
"cuid": "2.1.8",
|
"cuid": "2.1.8",
|
||||||
"dayjs": "1.11.4",
|
"dayjs": "1.11.5",
|
||||||
"dockerode": "3.3.3",
|
"dockerode": "3.3.4",
|
||||||
"dotenv-extended": "2.9.0",
|
"dotenv-extended": "2.9.0",
|
||||||
"fastify": "4.4.0",
|
"execa": "6.1.0",
|
||||||
"fastify-plugin": "4.1.0",
|
"fastify": "4.5.3",
|
||||||
|
"fastify-plugin": "4.2.1",
|
||||||
"generate-password": "1.7.0",
|
"generate-password": "1.7.0",
|
||||||
"get-port": "6.1.2",
|
"got": "12.4.1",
|
||||||
"got": "12.3.1",
|
|
||||||
"is-ip": "5.0.0",
|
"is-ip": "5.0.0",
|
||||||
"is-port-reachable": "4.0.0",
|
"is-port-reachable": "4.0.0",
|
||||||
"js-yaml": "4.1.0",
|
"js-yaml": "4.1.0",
|
||||||
"jsonwebtoken": "8.5.1",
|
"jsonwebtoken": "8.5.1",
|
||||||
"node-forge": "1.3.1",
|
"node-forge": "1.3.1",
|
||||||
"node-os-utils": "1.3.7",
|
"node-os-utils": "1.3.7",
|
||||||
"p-queue": "7.3.0",
|
"p-all": "4.0.0",
|
||||||
|
"p-throttle": "5.0.0",
|
||||||
"public-ip": "6.0.1",
|
"public-ip": "6.0.1",
|
||||||
"ssh-config": "4.1.6",
|
"ssh-config": "4.1.6",
|
||||||
"strip-ansi": "7.0.1",
|
"strip-ansi": "7.0.1",
|
||||||
"unique-names-generator": "4.7.1"
|
"unique-names-generator": "4.7.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "18.6.5",
|
"@types/node": "18.7.15",
|
||||||
"@types/node-os-utils": "1.3.0",
|
"@types/node-os-utils": "1.3.0",
|
||||||
"@typescript-eslint/eslint-plugin": "5.33.0",
|
"@typescript-eslint/eslint-plugin": "5.36.2",
|
||||||
"@typescript-eslint/parser": "5.33.0",
|
"@typescript-eslint/parser": "5.36.2",
|
||||||
"esbuild": "0.15.0",
|
"esbuild": "0.15.7",
|
||||||
"eslint": "8.21.0",
|
"eslint": "8.23.0",
|
||||||
"eslint-config-prettier": "8.5.0",
|
"eslint-config-prettier": "8.5.0",
|
||||||
"eslint-plugin-prettier": "4.2.1",
|
"eslint-plugin-prettier": "4.2.1",
|
||||||
"nodemon": "2.0.19",
|
"nodemon": "2.0.19",
|
||||||
"prettier": "2.7.1",
|
"prettier": "2.7.1",
|
||||||
"prisma": "3.15.2",
|
"prisma": "4.3.1",
|
||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
"tsconfig-paths": "4.1.0",
|
"tsconfig-paths": "4.1.0",
|
||||||
"typescript": "4.7.4"
|
"typescript": "4.8.2"
|
||||||
},
|
},
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "node prisma/seed.js"
|
"seed": "node prisma/seed.js"
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Searxng" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"secretKey" TEXT NOT NULL,
|
||||||
|
"redisPassword" TEXT NOT NULL,
|
||||||
|
"serviceId" TEXT NOT NULL,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
CONSTRAINT "Searxng_serviceId_fkey" FOREIGN KEY ("serviceId") REFERENCES "Service" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "Searxng_serviceId_key" ON "Searxng"("serviceId");
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
-- RedefineTables
|
||||||
|
PRAGMA foreign_keys=OFF;
|
||||||
|
CREATE TABLE "new_Setting" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"fqdn" TEXT,
|
||||||
|
"isRegistrationEnabled" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"dualCerts" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"minPort" INTEGER NOT NULL DEFAULT 9000,
|
||||||
|
"maxPort" INTEGER NOT NULL DEFAULT 9100,
|
||||||
|
"proxyPassword" TEXT NOT NULL,
|
||||||
|
"proxyUser" TEXT NOT NULL,
|
||||||
|
"proxyHash" TEXT,
|
||||||
|
"isAutoUpdateEnabled" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"isDNSCheckEnabled" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"DNSServers" TEXT,
|
||||||
|
"isTraefikUsed" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
"ipv4" TEXT,
|
||||||
|
"ipv6" TEXT,
|
||||||
|
"arch" TEXT,
|
||||||
|
"concurrentBuilds" INTEGER NOT NULL DEFAULT 1
|
||||||
|
);
|
||||||
|
INSERT INTO "new_Setting" ("DNSServers", "arch", "createdAt", "dualCerts", "fqdn", "id", "ipv4", "ipv6", "isAutoUpdateEnabled", "isDNSCheckEnabled", "isRegistrationEnabled", "isTraefikUsed", "maxPort", "minPort", "proxyHash", "proxyPassword", "proxyUser", "updatedAt") SELECT "DNSServers", "arch", "createdAt", "dualCerts", "fqdn", "id", "ipv4", "ipv6", "isAutoUpdateEnabled", "isDNSCheckEnabled", "isRegistrationEnabled", "isTraefikUsed", "maxPort", "minPort", "proxyHash", "proxyPassword", "proxyUser", "updatedAt" FROM "Setting";
|
||||||
|
DROP TABLE "Setting";
|
||||||
|
ALTER TABLE "new_Setting" RENAME TO "Setting";
|
||||||
|
CREATE UNIQUE INDEX "Setting_fqdn_key" ON "Setting"("fqdn");
|
||||||
|
PRAGMA foreign_key_check;
|
||||||
|
PRAGMA foreign_keys=ON;
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
-- RedefineTables
|
||||||
|
PRAGMA foreign_keys=OFF;
|
||||||
|
CREATE TABLE "new_Build" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"type" TEXT NOT NULL,
|
||||||
|
"applicationId" TEXT,
|
||||||
|
"destinationDockerId" TEXT,
|
||||||
|
"gitSourceId" TEXT,
|
||||||
|
"githubAppId" TEXT,
|
||||||
|
"gitlabAppId" TEXT,
|
||||||
|
"commit" TEXT,
|
||||||
|
"pullmergeRequestId" TEXT,
|
||||||
|
"forceRebuild" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"sourceBranch" TEXT,
|
||||||
|
"branch" TEXT,
|
||||||
|
"status" TEXT DEFAULT 'queued',
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL
|
||||||
|
);
|
||||||
|
INSERT INTO "new_Build" ("applicationId", "branch", "commit", "createdAt", "destinationDockerId", "gitSourceId", "githubAppId", "gitlabAppId", "id", "status", "type", "updatedAt") SELECT "applicationId", "branch", "commit", "createdAt", "destinationDockerId", "gitSourceId", "githubAppId", "gitlabAppId", "id", "status", "type", "updatedAt" FROM "Build";
|
||||||
|
DROP TABLE "Build";
|
||||||
|
ALTER TABLE "new_Build" RENAME TO "Build";
|
||||||
|
PRAGMA foreign_key_check;
|
||||||
|
PRAGMA foreign_keys=ON;
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Weblate" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"adminPassword" TEXT NOT NULL,
|
||||||
|
"postgresqlHost" TEXT NOT NULL,
|
||||||
|
"postgresqlPort" INTEGER NOT NULL,
|
||||||
|
"postgresqlUser" TEXT NOT NULL,
|
||||||
|
"postgresqlPassword" TEXT NOT NULL,
|
||||||
|
"postgresqlDatabase" TEXT NOT NULL,
|
||||||
|
"postgresqlPublicPort" INTEGER,
|
||||||
|
"serviceId" TEXT NOT NULL,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
CONSTRAINT "Weblate_serviceId_fkey" FOREIGN KEY ("serviceId") REFERENCES "Service" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "Weblate_serviceId_key" ON "Weblate"("serviceId");
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Taiga" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"secretKey" TEXT NOT NULL,
|
||||||
|
"erlangSecret" TEXT NOT NULL,
|
||||||
|
"djangoAdminPassword" TEXT NOT NULL,
|
||||||
|
"djangoAdminUser" TEXT NOT NULL,
|
||||||
|
"rabbitMQUser" TEXT NOT NULL,
|
||||||
|
"rabbitMQPassword" TEXT NOT NULL,
|
||||||
|
"postgresqlHost" TEXT NOT NULL,
|
||||||
|
"postgresqlPort" INTEGER NOT NULL,
|
||||||
|
"postgresqlUser" TEXT NOT NULL,
|
||||||
|
"postgresqlPassword" TEXT NOT NULL,
|
||||||
|
"postgresqlDatabase" TEXT NOT NULL,
|
||||||
|
"postgresqlPublicPort" INTEGER,
|
||||||
|
"serviceId" TEXT NOT NULL,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
CONSTRAINT "Taiga_serviceId_fkey" FOREIGN KEY ("serviceId") REFERENCES "Service" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "Taiga_serviceId_key" ON "Taiga"("serviceId");
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
-- RedefineTables
|
||||||
|
PRAGMA foreign_keys=OFF;
|
||||||
|
CREATE TABLE "new_ApplicationSettings" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"applicationId" TEXT NOT NULL,
|
||||||
|
"dualCerts" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"debug" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"previews" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"autodeploy" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"isBot" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"isPublicRepository" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"isDBBranching" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
CONSTRAINT "ApplicationSettings_applicationId_fkey" FOREIGN KEY ("applicationId") REFERENCES "Application" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
INSERT INTO "new_ApplicationSettings" ("applicationId", "autodeploy", "createdAt", "debug", "dualCerts", "id", "isBot", "isPublicRepository", "previews", "updatedAt") SELECT "applicationId", "autodeploy", "createdAt", "debug", "dualCerts", "id", "isBot", "isPublicRepository", "previews", "updatedAt" FROM "ApplicationSettings";
|
||||||
|
DROP TABLE "ApplicationSettings";
|
||||||
|
ALTER TABLE "new_ApplicationSettings" RENAME TO "ApplicationSettings";
|
||||||
|
CREATE UNIQUE INDEX "ApplicationSettings_applicationId_key" ON "ApplicationSettings"("applicationId");
|
||||||
|
PRAGMA foreign_key_check;
|
||||||
|
PRAGMA foreign_keys=ON;
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- You are about to alter the column `time` on the `BuildLog` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- RedefineTables
|
||||||
|
PRAGMA foreign_keys=OFF;
|
||||||
|
CREATE TABLE "new_BuildLog" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"applicationId" TEXT,
|
||||||
|
"buildId" TEXT NOT NULL,
|
||||||
|
"line" TEXT NOT NULL,
|
||||||
|
"time" BIGINT NOT NULL
|
||||||
|
);
|
||||||
|
INSERT INTO "new_BuildLog" ("applicationId", "buildId", "id", "line", "time") SELECT "applicationId", "buildId", "id", "line", "time" FROM "BuildLog";
|
||||||
|
DROP TABLE "BuildLog";
|
||||||
|
ALTER TABLE "new_BuildLog" RENAME TO "BuildLog";
|
||||||
|
PRAGMA foreign_key_check;
|
||||||
|
PRAGMA foreign_keys=ON;
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "ApplicationConnectedDatabase" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"applicationId" TEXT NOT NULL,
|
||||||
|
"databaseId" TEXT,
|
||||||
|
"hostedDatabaseType" TEXT,
|
||||||
|
"hostedDatabaseHost" TEXT,
|
||||||
|
"hostedDatabasePort" INTEGER,
|
||||||
|
"hostedDatabaseName" TEXT,
|
||||||
|
"hostedDatabaseUser" TEXT,
|
||||||
|
"hostedDatabasePassword" TEXT,
|
||||||
|
"hostedDatabaseDBName" TEXT,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
CONSTRAINT "ApplicationConnectedDatabase_databaseId_fkey" FOREIGN KEY ("databaseId") REFERENCES "Database" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "ApplicationConnectedDatabase_applicationId_fkey" FOREIGN KEY ("applicationId") REFERENCES "Application" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "ApplicationConnectedDatabase_applicationId_key" ON "ApplicationConnectedDatabase"("applicationId");
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
generator client {
|
generator client {
|
||||||
provider = "prisma-client-js"
|
provider = "prisma-client-js"
|
||||||
binaryTargets = ["native", "linux-musl"]
|
binaryTargets = ["native"]
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
@@ -27,6 +27,7 @@ model Setting {
|
|||||||
ipv4 String?
|
ipv4 String?
|
||||||
ipv6 String?
|
ipv6 String?
|
||||||
arch String?
|
arch String?
|
||||||
|
concurrentBuilds Int @default(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
model User {
|
model User {
|
||||||
@@ -116,6 +117,24 @@ model Application {
|
|||||||
settings ApplicationSettings?
|
settings ApplicationSettings?
|
||||||
secrets Secret[]
|
secrets Secret[]
|
||||||
teams Team[]
|
teams Team[]
|
||||||
|
connectedDatabase ApplicationConnectedDatabase?
|
||||||
|
}
|
||||||
|
|
||||||
|
model ApplicationConnectedDatabase {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
applicationId String @unique
|
||||||
|
databaseId String?
|
||||||
|
hostedDatabaseType String?
|
||||||
|
hostedDatabaseHost String?
|
||||||
|
hostedDatabasePort Int?
|
||||||
|
hostedDatabaseName String?
|
||||||
|
hostedDatabaseUser String?
|
||||||
|
hostedDatabasePassword String?
|
||||||
|
hostedDatabaseDBName String?
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
database Database? @relation(fields: [databaseId], references: [id])
|
||||||
|
application Application @relation(fields: [applicationId], references: [id])
|
||||||
}
|
}
|
||||||
|
|
||||||
model ApplicationSettings {
|
model ApplicationSettings {
|
||||||
@@ -127,6 +146,7 @@ model ApplicationSettings {
|
|||||||
autodeploy Boolean @default(true)
|
autodeploy Boolean @default(true)
|
||||||
isBot Boolean @default(false)
|
isBot Boolean @default(false)
|
||||||
isPublicRepository Boolean @default(false)
|
isPublicRepository Boolean @default(false)
|
||||||
|
isDBBranching Boolean @default(false)
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
application Application @relation(fields: [applicationId], references: [id])
|
application Application @relation(fields: [applicationId], references: [id])
|
||||||
@@ -185,7 +205,7 @@ model BuildLog {
|
|||||||
applicationId String?
|
applicationId String?
|
||||||
buildId String
|
buildId String
|
||||||
line String
|
line String
|
||||||
time Int
|
time BigInt
|
||||||
}
|
}
|
||||||
|
|
||||||
model Build {
|
model Build {
|
||||||
@@ -197,6 +217,9 @@ model Build {
|
|||||||
githubAppId String?
|
githubAppId String?
|
||||||
gitlabAppId String?
|
gitlabAppId String?
|
||||||
commit String?
|
commit String?
|
||||||
|
pullmergeRequestId String?
|
||||||
|
forceRebuild Boolean @default(false)
|
||||||
|
sourceBranch String?
|
||||||
branch String?
|
branch String?
|
||||||
status String? @default("queued")
|
status String? @default("queued")
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
@@ -287,22 +310,23 @@ model GitlabApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model Database {
|
model Database {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
name String
|
name String
|
||||||
publicPort Int?
|
publicPort Int?
|
||||||
defaultDatabase String?
|
defaultDatabase String?
|
||||||
type String?
|
type String?
|
||||||
version String?
|
version String?
|
||||||
dbUser String?
|
dbUser String?
|
||||||
dbUserPassword String?
|
dbUserPassword String?
|
||||||
rootUser String?
|
rootUser String?
|
||||||
rootUserPassword String?
|
rootUserPassword String?
|
||||||
destinationDockerId String?
|
destinationDockerId String?
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
destinationDocker DestinationDocker? @relation(fields: [destinationDockerId], references: [id])
|
destinationDocker DestinationDocker? @relation(fields: [destinationDockerId], references: [id])
|
||||||
settings DatabaseSettings?
|
settings DatabaseSettings?
|
||||||
teams Team[]
|
teams Team[]
|
||||||
|
applicationConnectedDatabase ApplicationConnectedDatabase[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model DatabaseSettings {
|
model DatabaseSettings {
|
||||||
@@ -327,23 +351,25 @@ model Service {
|
|||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
destinationDocker DestinationDocker? @relation(fields: [destinationDockerId], references: [id])
|
destinationDocker DestinationDocker? @relation(fields: [destinationDockerId], references: [id])
|
||||||
|
|
||||||
fider Fider?
|
|
||||||
ghost Ghost?
|
|
||||||
glitchTip GlitchTip?
|
|
||||||
hasura Hasura?
|
|
||||||
meiliSearch MeiliSearch?
|
|
||||||
minio Minio?
|
|
||||||
moodle Moodle?
|
|
||||||
plausibleAnalytics PlausibleAnalytics?
|
|
||||||
persistentStorage ServicePersistentStorage[]
|
persistentStorage ServicePersistentStorage[]
|
||||||
serviceSecret ServiceSecret[]
|
serviceSecret ServiceSecret[]
|
||||||
umami Umami?
|
teams Team[]
|
||||||
vscodeserver Vscodeserver?
|
|
||||||
wordpress Wordpress?
|
|
||||||
appwrite Appwrite?
|
|
||||||
|
|
||||||
teams Team[]
|
fider Fider?
|
||||||
|
ghost Ghost?
|
||||||
|
glitchTip GlitchTip?
|
||||||
|
hasura Hasura?
|
||||||
|
meiliSearch MeiliSearch?
|
||||||
|
minio Minio?
|
||||||
|
moodle Moodle?
|
||||||
|
plausibleAnalytics PlausibleAnalytics?
|
||||||
|
umami Umami?
|
||||||
|
vscodeserver Vscodeserver?
|
||||||
|
wordpress Wordpress?
|
||||||
|
appwrite Appwrite?
|
||||||
|
searxng Searxng?
|
||||||
|
weblate Weblate?
|
||||||
|
taiga Taiga?
|
||||||
}
|
}
|
||||||
|
|
||||||
model PlausibleAnalytics {
|
model PlausibleAnalytics {
|
||||||
@@ -545,3 +571,48 @@ model GlitchTip {
|
|||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
service Service @relation(fields: [serviceId], references: [id])
|
service Service @relation(fields: [serviceId], references: [id])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model Searxng {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
secretKey String
|
||||||
|
redisPassword String
|
||||||
|
serviceId String @unique
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
service Service @relation(fields: [serviceId], references: [id])
|
||||||
|
}
|
||||||
|
|
||||||
|
model Weblate {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
adminPassword String
|
||||||
|
postgresqlHost String
|
||||||
|
postgresqlPort Int
|
||||||
|
postgresqlUser String
|
||||||
|
postgresqlPassword String
|
||||||
|
postgresqlDatabase String
|
||||||
|
postgresqlPublicPort Int?
|
||||||
|
serviceId String @unique
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
service Service @relation(fields: [serviceId], references: [id])
|
||||||
|
}
|
||||||
|
|
||||||
|
model Taiga {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
secretKey String
|
||||||
|
erlangSecret String
|
||||||
|
djangoAdminPassword String
|
||||||
|
djangoAdminUser String
|
||||||
|
rabbitMQUser String
|
||||||
|
rabbitMQPassword String
|
||||||
|
postgresqlHost String
|
||||||
|
postgresqlPort Int
|
||||||
|
postgresqlUser String
|
||||||
|
postgresqlPassword String
|
||||||
|
postgresqlDatabase String
|
||||||
|
postgresqlPublicPort Int?
|
||||||
|
serviceId String @unique
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
service Service @relation(fields: [serviceId], references: [id])
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,11 +5,10 @@ import env from '@fastify/env';
|
|||||||
import cookie from '@fastify/cookie';
|
import cookie from '@fastify/cookie';
|
||||||
import path, { join } from 'path';
|
import path, { join } from 'path';
|
||||||
import autoLoad from '@fastify/autoload';
|
import autoLoad from '@fastify/autoload';
|
||||||
import { asyncExecShell, isDev, listSettings, prisma, version } from './lib/common';
|
import { asyncExecShell, createRemoteEngineConfiguration, isDev, listSettings, prisma, version } from './lib/common';
|
||||||
import { scheduler } from './lib/scheduler';
|
import { scheduler } from './lib/scheduler';
|
||||||
import axios from 'axios';
|
import { compareVersions } from 'compare-versions';
|
||||||
import compareVersions from 'compare-versions';
|
import Graceful from '@ladjs/graceful'
|
||||||
|
|
||||||
declare module 'fastify' {
|
declare module 'fastify' {
|
||||||
interface FastifyInstance {
|
interface FastifyInstance {
|
||||||
config: {
|
config: {
|
||||||
@@ -104,51 +103,44 @@ fastify.listen({ port, host }, async (err: any, address: any) => {
|
|||||||
}
|
}
|
||||||
console.log(`Coolify's API is listening on ${host}:${port}`);
|
console.log(`Coolify's API is listening on ${host}:${port}`);
|
||||||
await initServer();
|
await initServer();
|
||||||
await scheduler.start('deployApplication');
|
|
||||||
await scheduler.start('cleanupStorage');
|
|
||||||
await scheduler.start('cleanupPrismaEngines');
|
|
||||||
await scheduler.start('checkProxies');
|
|
||||||
|
|
||||||
// Check if no build is running
|
const graceful = new Graceful({ brees: [scheduler] });
|
||||||
|
graceful.listen();
|
||||||
|
|
||||||
// Check for update
|
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
const { isAutoUpdateEnabled } = await prisma.setting.findFirst();
|
if (!scheduler.workers.has('deployApplication')) {
|
||||||
if (isAutoUpdateEnabled) {
|
scheduler.run('deployApplication');
|
||||||
const currentVersion = version;
|
|
||||||
const { data: versions } = await axios
|
|
||||||
.get(
|
|
||||||
`https://get.coollabs.io/versions.json`
|
|
||||||
, {
|
|
||||||
params: {
|
|
||||||
appId: process.env['COOLIFY_APP_ID'] || undefined,
|
|
||||||
version: currentVersion
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const latestVersion = versions['coolify'].main.version;
|
|
||||||
const isUpdateAvailable = compareVersions(latestVersion, currentVersion);
|
|
||||||
if (isUpdateAvailable === 1) {
|
|
||||||
if (scheduler.workers.has('deployApplication')) {
|
|
||||||
scheduler.workers.get('deployApplication').postMessage("status:autoUpdater");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!scheduler.workers.has('infrastructure')) {
|
||||||
|
scheduler.run('infrastructure');
|
||||||
|
}
|
||||||
|
}, 2000)
|
||||||
|
|
||||||
|
// autoUpdater
|
||||||
|
setInterval(async () => {
|
||||||
|
scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:autoUpdater")
|
||||||
}, isDev ? 5000 : 60000 * 15)
|
}, isDev ? 5000 : 60000 * 15)
|
||||||
|
|
||||||
// Cleanup storage
|
// cleanupStorage
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
if (scheduler.workers.has('deployApplication')) {
|
scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:cleanupStorage")
|
||||||
scheduler.workers.get('deployApplication').postMessage("status:cleanupStorage");
|
}, isDev ? 6000 : 60000 * 10)
|
||||||
}
|
|
||||||
}, isDev ? 5000 : 60000 * 10)
|
|
||||||
|
|
||||||
scheduler.on('worker deleted', async (name) => {
|
// checkProxies
|
||||||
if (name === 'autoUpdater' || name === 'cleanupStorage') {
|
setInterval(async () => {
|
||||||
if (!scheduler.workers.has('deployApplication')) await scheduler.start('deployApplication');
|
scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:checkProxies")
|
||||||
}
|
}, 10000)
|
||||||
});
|
|
||||||
await getArch();
|
// cleanupPrismaEngines
|
||||||
await getIPAddress();
|
// setInterval(async () => {
|
||||||
|
// scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:cleanupPrismaEngines")
|
||||||
|
// }, 60000)
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
getArch(),
|
||||||
|
getIPAddress(),
|
||||||
|
// configureRemoteDockers(),
|
||||||
|
])
|
||||||
});
|
});
|
||||||
async function getIPAddress() {
|
async function getIPAddress() {
|
||||||
const { publicIpv4, publicIpv6 } = await import('public-ip')
|
const { publicIpv4, publicIpv6 } = await import('public-ip')
|
||||||
@@ -170,6 +162,12 @@ async function initServer() {
|
|||||||
try {
|
try {
|
||||||
await asyncExecShell(`docker network create --attachable coolify`);
|
await asyncExecShell(`docker network create --attachable coolify`);
|
||||||
} catch (error) { }
|
} catch (error) { }
|
||||||
|
try {
|
||||||
|
const isOlder = compareVersions('3.8.1', version);
|
||||||
|
if (isOlder === 1) {
|
||||||
|
await prisma.build.updateMany({ where: { status: { in: ['running', 'queued'] } }, data: { status: 'failed' } });
|
||||||
|
}
|
||||||
|
} catch (error) { }
|
||||||
}
|
}
|
||||||
async function getArch() {
|
async function getArch() {
|
||||||
try {
|
try {
|
||||||
@@ -180,4 +178,15 @@ async function getArch() {
|
|||||||
} catch (error) { }
|
} catch (error) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function configureRemoteDockers() {
|
||||||
|
try {
|
||||||
|
const remoteDocker = await prisma.destinationDocker.findMany({
|
||||||
|
where: { remoteVerified: true, remoteEngine: true }
|
||||||
|
});
|
||||||
|
if (remoteDocker.length > 0) {
|
||||||
|
for (const docker of remoteDocker) {
|
||||||
|
await createRemoteEngineConfiguration(docker.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) { }
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
import axios from 'axios';
|
|
||||||
import compareVersions from 'compare-versions';
|
|
||||||
import { parentPort } from 'node:worker_threads';
|
|
||||||
import { asyncExecShell, asyncSleep, isDev, prisma, version } from '../lib/common';
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
if (parentPort) {
|
|
||||||
try {
|
|
||||||
const currentVersion = version;
|
|
||||||
const { data: versions } = await axios
|
|
||||||
.get(
|
|
||||||
`https://get.coollabs.io/versions.json`
|
|
||||||
, {
|
|
||||||
params: {
|
|
||||||
appId: process.env['COOLIFY_APP_ID'] || undefined,
|
|
||||||
version: currentVersion
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const latestVersion = versions['coolify'].main.version;
|
|
||||||
const isUpdateAvailable = compareVersions(latestVersion, currentVersion);
|
|
||||||
if (isUpdateAvailable === 1) {
|
|
||||||
const activeCount = 0
|
|
||||||
if (activeCount === 0) {
|
|
||||||
if (!isDev) {
|
|
||||||
console.log(`Updating Coolify to ${latestVersion}.`);
|
|
||||||
await asyncExecShell(`docker pull coollabsio/coolify:${latestVersion}`);
|
|
||||||
await asyncExecShell(`env | grep COOLIFY > .env`);
|
|
||||||
await asyncExecShell(
|
|
||||||
`docker run --rm -tid --env-file .env -v /var/run/docker.sock:/var/run/docker.sock -v coolify-db coollabsio/coolify:${latestVersion} /bin/sh -c "env | grep COOLIFY > .env && echo 'TAG=${latestVersion}' >> .env && docker stop -t 0 coolify && docker rm coolify && docker compose up -d --force-recreate"`
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
console.log('Updating (not really in dev mode).');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
} else process.exit(0);
|
|
||||||
})();
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
import { parentPort } from 'node:worker_threads';
|
|
||||||
import { prisma, startTraefikTCPProxy, generateDatabaseConfiguration, startTraefikProxy, executeDockerCmd, listSettings } from '../lib/common';
|
|
||||||
import { checkContainer } from '../lib/docker';
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
if (parentPort) {
|
|
||||||
try {
|
|
||||||
const { arch } = await listSettings();
|
|
||||||
// Coolify Proxy local
|
|
||||||
const engine = '/var/run/docker.sock';
|
|
||||||
const localDocker = await prisma.destinationDocker.findFirst({
|
|
||||||
where: { engine, network: 'coolify' }
|
|
||||||
});
|
|
||||||
if (localDocker && localDocker.isCoolifyProxyUsed) {
|
|
||||||
// Remove HAProxy
|
|
||||||
const found = await checkContainer({ dockerId: localDocker.id, container: 'coolify-haproxy' });
|
|
||||||
if (found) {
|
|
||||||
await executeDockerCmd({
|
|
||||||
dockerId: localDocker.id,
|
|
||||||
command: `docker stop -t 0 coolify-haproxy && docker rm coolify-haproxy`
|
|
||||||
})
|
|
||||||
}
|
|
||||||
await startTraefikProxy(localDocker.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TCP Proxies
|
|
||||||
const databasesWithPublicPort = await prisma.database.findMany({
|
|
||||||
where: { publicPort: { not: null } },
|
|
||||||
include: { settings: true, destinationDocker: true }
|
|
||||||
});
|
|
||||||
for (const database of databasesWithPublicPort) {
|
|
||||||
const { destinationDockerId, destinationDocker, publicPort, id } = database;
|
|
||||||
if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) {
|
|
||||||
const { privatePort } = generateDatabaseConfiguration(database, arch);
|
|
||||||
// Remove HAProxy
|
|
||||||
const found = await checkContainer({
|
|
||||||
dockerId: localDocker.id, container: `haproxy-for-${publicPort}`
|
|
||||||
});
|
|
||||||
if (found) {
|
|
||||||
await executeDockerCmd({
|
|
||||||
dockerId: localDocker.id,
|
|
||||||
command: `docker stop -t 0 haproxy-for-${publicPort} && docker rm haproxy-for-${publicPort}`
|
|
||||||
})
|
|
||||||
}
|
|
||||||
await startTraefikTCPProxy(destinationDocker, id, publicPort, privatePort);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const wordpressWithFtp = await prisma.wordpress.findMany({
|
|
||||||
where: { ftpPublicPort: { not: null } },
|
|
||||||
include: { service: { include: { destinationDocker: true } } }
|
|
||||||
});
|
|
||||||
for (const ftp of wordpressWithFtp) {
|
|
||||||
const { service, ftpPublicPort } = ftp;
|
|
||||||
const { destinationDockerId, destinationDocker, id } = service;
|
|
||||||
if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) {
|
|
||||||
// Remove HAProxy
|
|
||||||
const found = await checkContainer({ dockerId: localDocker.id, container: `haproxy-for-${ftpPublicPort}` });
|
|
||||||
if (found) {
|
|
||||||
await executeDockerCmd({
|
|
||||||
dockerId: localDocker.id,
|
|
||||||
command: `docker stop -t 0 haproxy -for-${ftpPublicPort} && docker rm haproxy-for-${ftpPublicPort}`
|
|
||||||
})
|
|
||||||
}
|
|
||||||
await startTraefikTCPProxy(destinationDocker, id, ftpPublicPort, 22, 'wordpressftp');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTTP Proxies
|
|
||||||
const minioInstances = await prisma.minio.findMany({
|
|
||||||
where: { publicPort: { not: null } },
|
|
||||||
include: { service: { include: { destinationDocker: true } } }
|
|
||||||
});
|
|
||||||
for (const minio of minioInstances) {
|
|
||||||
const { service, publicPort } = minio;
|
|
||||||
const { destinationDockerId, destinationDocker, id } = service;
|
|
||||||
if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) {
|
|
||||||
// Remove HAProxy
|
|
||||||
const found = await checkContainer({ dockerId: localDocker.id, container: `${id}-${publicPort}` });
|
|
||||||
if (found) {
|
|
||||||
await executeDockerCmd({
|
|
||||||
dockerId: localDocker.id,
|
|
||||||
command: `docker stop -t 0 ${id}-${publicPort} && docker rm ${id}-${publicPort} `
|
|
||||||
})
|
|
||||||
}
|
|
||||||
await startTraefikTCPProxy(destinationDocker, id, publicPort, 9000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
} else process.exit(0);
|
|
||||||
})();
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import { parentPort } from 'node:worker_threads';
|
|
||||||
import { asyncExecShell, isDev, prisma } from '../lib/common';
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
if (parentPort) {
|
|
||||||
if (!isDev) {
|
|
||||||
try {
|
|
||||||
const { stdout } = await asyncExecShell(`ps -ef | grep /app/prisma-engines/query-engine | grep -v grep | wc -l | xargs`)
|
|
||||||
if (stdout.trim() != null && stdout.trim() != '' && Number(stdout.trim()) > 1) {
|
|
||||||
await asyncExecShell(`killall -q -e /app/prisma-engines/query-engine -o 10m`)
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else process.exit(0);
|
|
||||||
})();
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
import { parentPort } from 'node:worker_threads';
|
|
||||||
import { asyncExecShell, cleanupDockerStorage, executeDockerCmd, isDev, prisma, version } from '../lib/common';
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
if (parentPort) {
|
|
||||||
const destinationDockers = await prisma.destinationDocker.findMany();
|
|
||||||
let enginesDone = new Set()
|
|
||||||
for (const destination of destinationDockers) {
|
|
||||||
if (enginesDone.has(destination.engine) || enginesDone.has(destination.remoteIpAddress)) return
|
|
||||||
if (destination.engine) enginesDone.add(destination.engine)
|
|
||||||
if (destination.remoteIpAddress) enginesDone.add(destination.remoteIpAddress)
|
|
||||||
|
|
||||||
let lowDiskSpace = false;
|
|
||||||
try {
|
|
||||||
let stdout = null
|
|
||||||
if (!isDev) {
|
|
||||||
const output = await executeDockerCmd({ dockerId: destination.id, command: `CONTAINER=$(docker ps -lq | head -1) && docker exec $CONTAINER sh -c 'df -kPT /'` })
|
|
||||||
stdout = output.stdout;
|
|
||||||
} else {
|
|
||||||
const output = await asyncExecShell(
|
|
||||||
`df -kPT /`
|
|
||||||
);
|
|
||||||
stdout = output.stdout;
|
|
||||||
}
|
|
||||||
let lines = stdout.trim().split('\n');
|
|
||||||
let header = lines[0];
|
|
||||||
let regex =
|
|
||||||
/^Filesystem\s+|Type\s+|1024-blocks|\s+Used|\s+Available|\s+Capacity|\s+Mounted on\s*$/g;
|
|
||||||
const boundaries = [];
|
|
||||||
let match;
|
|
||||||
|
|
||||||
while ((match = regex.exec(header))) {
|
|
||||||
boundaries.push(match[0].length);
|
|
||||||
}
|
|
||||||
|
|
||||||
boundaries[boundaries.length - 1] = -1;
|
|
||||||
const data = lines.slice(1).map((line) => {
|
|
||||||
const cl = boundaries.map((boundary) => {
|
|
||||||
const column = boundary > 0 ? line.slice(0, boundary) : line;
|
|
||||||
line = line.slice(boundary);
|
|
||||||
return column.trim();
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
capacity: Number.parseInt(cl[5], 10) / 100
|
|
||||||
};
|
|
||||||
});
|
|
||||||
if (data.length > 0) {
|
|
||||||
const { capacity } = data[0];
|
|
||||||
if (capacity > 0.8) {
|
|
||||||
lowDiskSpace = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
await cleanupDockerStorage(destination.id, lowDiskSpace, false)
|
|
||||||
}
|
|
||||||
await prisma.$disconnect();
|
|
||||||
} else process.exit(0);
|
|
||||||
})();
|
|
||||||
@@ -4,210 +4,277 @@ import fs from 'fs/promises';
|
|||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
|
|
||||||
import { copyBaseConfigurationFiles, makeLabelForStandaloneApplication, saveBuildLog, setDefaultConfiguration } from '../lib/buildPacks/common';
|
import { copyBaseConfigurationFiles, makeLabelForStandaloneApplication, saveBuildLog, setDefaultConfiguration } from '../lib/buildPacks/common';
|
||||||
import { createDirectories, decrypt, defaultComposeConfiguration, executeDockerCmd, getDomain, prisma } from '../lib/common';
|
import { createDirectories, decrypt, defaultComposeConfiguration, executeDockerCmd, getDomain, prisma, decryptApplication } from '../lib/common';
|
||||||
import * as importers from '../lib/importers';
|
import * as importers from '../lib/importers';
|
||||||
import * as buildpacks from '../lib/buildPacks';
|
import * as buildpacks from '../lib/buildPacks';
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
if (parentPort) {
|
if (parentPort) {
|
||||||
const concurrency = 1
|
|
||||||
const PQueue = await import('p-queue');
|
|
||||||
const queue = new PQueue.default({ concurrency });
|
|
||||||
parentPort.on('message', async (message) => {
|
parentPort.on('message', async (message) => {
|
||||||
if (parentPort) {
|
if (message === 'error') throw new Error('oops');
|
||||||
if (message === 'error') throw new Error('oops');
|
if (message === 'cancel') {
|
||||||
if (message === 'cancel') {
|
parentPort.postMessage('cancelled');
|
||||||
parentPort.postMessage('cancelled');
|
await prisma.$disconnect()
|
||||||
return;
|
process.exit(0);
|
||||||
}
|
}
|
||||||
if (message === 'status:autoUpdater') {
|
});
|
||||||
parentPort.postMessage({ size: queue.size, pending: queue.pending, caller: 'autoUpdater' });
|
const pThrottle = await import('p-throttle')
|
||||||
return;
|
const throttle = pThrottle.default({
|
||||||
}
|
limit: 1,
|
||||||
if (message === 'status:cleanupStorage') {
|
interval: 2000
|
||||||
parentPort.postMessage({ size: queue.size, pending: queue.pending, caller: 'cleanupStorage' });
|
});
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await queue.add(async () => {
|
|
||||||
const {
|
|
||||||
id: applicationId,
|
|
||||||
repository,
|
|
||||||
name,
|
|
||||||
destinationDocker,
|
|
||||||
destinationDockerId,
|
|
||||||
gitSource,
|
|
||||||
build_id: buildId,
|
|
||||||
configHash,
|
|
||||||
fqdn,
|
|
||||||
projectId,
|
|
||||||
secrets,
|
|
||||||
phpModules,
|
|
||||||
type,
|
|
||||||
pullmergeRequestId = null,
|
|
||||||
sourceBranch = null,
|
|
||||||
settings,
|
|
||||||
persistentStorage,
|
|
||||||
pythonWSGI,
|
|
||||||
pythonModule,
|
|
||||||
pythonVariable,
|
|
||||||
denoOptions,
|
|
||||||
exposePort,
|
|
||||||
baseImage,
|
|
||||||
baseBuildImage,
|
|
||||||
deploymentType,
|
|
||||||
forceRebuild
|
|
||||||
} = message
|
|
||||||
let {
|
|
||||||
branch,
|
|
||||||
buildPack,
|
|
||||||
port,
|
|
||||||
installCommand,
|
|
||||||
buildCommand,
|
|
||||||
startCommand,
|
|
||||||
baseDirectory,
|
|
||||||
publishDirectory,
|
|
||||||
dockerFileLocation,
|
|
||||||
denoMainFile
|
|
||||||
} = message
|
|
||||||
const currentHash = crypto
|
|
||||||
.createHash('sha256')
|
|
||||||
.update(
|
|
||||||
JSON.stringify({
|
|
||||||
pythonWSGI,
|
|
||||||
pythonModule,
|
|
||||||
pythonVariable,
|
|
||||||
deploymentType,
|
|
||||||
denoOptions,
|
|
||||||
baseImage,
|
|
||||||
baseBuildImage,
|
|
||||||
buildPack,
|
|
||||||
port,
|
|
||||||
exposePort,
|
|
||||||
installCommand,
|
|
||||||
buildCommand,
|
|
||||||
startCommand,
|
|
||||||
secrets,
|
|
||||||
branch,
|
|
||||||
repository,
|
|
||||||
fqdn
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.digest('hex');
|
|
||||||
try {
|
|
||||||
const { debug } = settings;
|
|
||||||
if (concurrency === 1) {
|
|
||||||
await prisma.build.updateMany({
|
|
||||||
where: {
|
|
||||||
status: { in: ['queued', 'running'] },
|
|
||||||
id: { not: buildId },
|
|
||||||
applicationId,
|
|
||||||
createdAt: { lt: new Date(new Date().getTime() - 10 * 1000) }
|
|
||||||
},
|
|
||||||
data: { status: 'failed' }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
let imageId = applicationId;
|
|
||||||
let domain = getDomain(fqdn);
|
|
||||||
const volumes =
|
|
||||||
persistentStorage?.map((storage) => {
|
|
||||||
return `${applicationId}${storage.path.replace(/\//gi, '-')}:${buildPack !== 'docker' ? '/app' : ''
|
|
||||||
}${storage.path}`;
|
|
||||||
}) || [];
|
|
||||||
// Previews, we need to get the source branch and set subdomain
|
|
||||||
if (pullmergeRequestId) {
|
|
||||||
branch = sourceBranch;
|
|
||||||
domain = `${pullmergeRequestId}.${domain}`;
|
|
||||||
imageId = `${applicationId}-${pullmergeRequestId}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
let deployNeeded = true;
|
const th = throttle(async () => {
|
||||||
let destinationType;
|
try {
|
||||||
|
const queuedBuilds = await prisma.build.findMany({ where: { status: { in: ['queued', 'running'] } }, orderBy: { createdAt: 'asc' } });
|
||||||
if (destinationDockerId) {
|
const { concurrentBuilds } = await prisma.setting.findFirst({})
|
||||||
destinationType = 'docker';
|
if (queuedBuilds.length > 0) {
|
||||||
}
|
parentPort.postMessage({ deploying: true });
|
||||||
if (destinationType === 'docker') {
|
const concurrency = concurrentBuilds;
|
||||||
await prisma.build.update({ where: { id: buildId }, data: { status: 'running' } });
|
const pAll = await import('p-all');
|
||||||
const { workdir, repodir } = await createDirectories({ repository, buildId });
|
const actions = []
|
||||||
const configuration = await setDefaultConfiguration(message);
|
|
||||||
|
|
||||||
buildPack = configuration.buildPack;
|
|
||||||
port = configuration.port;
|
|
||||||
installCommand = configuration.installCommand;
|
|
||||||
startCommand = configuration.startCommand;
|
|
||||||
buildCommand = configuration.buildCommand;
|
|
||||||
publishDirectory = configuration.publishDirectory;
|
|
||||||
baseDirectory = configuration.baseDirectory;
|
|
||||||
dockerFileLocation = configuration.dockerFileLocation;
|
|
||||||
denoMainFile = configuration.denoMainFile;
|
|
||||||
const commit = await importers[gitSource.type]({
|
|
||||||
applicationId,
|
|
||||||
debug,
|
|
||||||
workdir,
|
|
||||||
repodir,
|
|
||||||
githubAppId: gitSource.githubApp?.id,
|
|
||||||
gitlabAppId: gitSource.gitlabApp?.id,
|
|
||||||
customPort: gitSource.customPort,
|
|
||||||
repository,
|
|
||||||
branch,
|
|
||||||
buildId,
|
|
||||||
apiUrl: gitSource.apiUrl,
|
|
||||||
htmlUrl: gitSource.htmlUrl,
|
|
||||||
projectId,
|
|
||||||
deployKeyId: gitSource.gitlabApp?.deployKeyId || null,
|
|
||||||
privateSshKey: decrypt(gitSource.gitlabApp?.privateSshKey) || null,
|
|
||||||
forPublic: gitSource.forPublic
|
|
||||||
});
|
|
||||||
if (!commit) {
|
|
||||||
throw new Error('No commit found?');
|
|
||||||
}
|
|
||||||
let tag = commit.slice(0, 7);
|
|
||||||
if (pullmergeRequestId) {
|
|
||||||
tag = `${commit.slice(0, 7)}-${pullmergeRequestId}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for (const queueBuild of queuedBuilds) {
|
||||||
|
actions.push(async () => {
|
||||||
|
let application = await prisma.application.findUnique({ where: { id: queueBuild.applicationId }, include: { destinationDocker: true, gitSource: { include: { githubApp: true, gitlabApp: true } }, persistentStorage: true, secrets: true, settings: true, teams: true } })
|
||||||
|
let { id: buildId, type, sourceBranch = null, pullmergeRequestId = null, forceRebuild } = queueBuild
|
||||||
|
application = decryptApplication(application)
|
||||||
try {
|
try {
|
||||||
await prisma.build.update({ where: { id: buildId }, data: { commit } });
|
if (queueBuild.status === 'running') {
|
||||||
} catch (err) {
|
await saveBuildLog({ line: 'Building halted, restarting...', buildId, applicationId: application.id });
|
||||||
console.log(err);
|
}
|
||||||
}
|
const {
|
||||||
|
id: applicationId,
|
||||||
if (!pullmergeRequestId) {
|
repository,
|
||||||
|
name,
|
||||||
if (configHash !== currentHash) {
|
destinationDocker,
|
||||||
deployNeeded = true;
|
destinationDockerId,
|
||||||
if (configHash) {
|
gitSource,
|
||||||
await saveBuildLog({ line: 'Configuration changed.', buildId, applicationId });
|
configHash,
|
||||||
}
|
fqdn,
|
||||||
} else {
|
projectId,
|
||||||
deployNeeded = false;
|
secrets,
|
||||||
|
phpModules,
|
||||||
|
settings,
|
||||||
|
persistentStorage,
|
||||||
|
pythonWSGI,
|
||||||
|
pythonModule,
|
||||||
|
pythonVariable,
|
||||||
|
denoOptions,
|
||||||
|
exposePort,
|
||||||
|
baseImage,
|
||||||
|
baseBuildImage,
|
||||||
|
deploymentType,
|
||||||
|
} = application
|
||||||
|
let {
|
||||||
|
branch,
|
||||||
|
buildPack,
|
||||||
|
port,
|
||||||
|
installCommand,
|
||||||
|
buildCommand,
|
||||||
|
startCommand,
|
||||||
|
baseDirectory,
|
||||||
|
publishDirectory,
|
||||||
|
dockerFileLocation,
|
||||||
|
denoMainFile
|
||||||
|
} = application
|
||||||
|
const currentHash = crypto
|
||||||
|
.createHash('sha256')
|
||||||
|
.update(
|
||||||
|
JSON.stringify({
|
||||||
|
pythonWSGI,
|
||||||
|
pythonModule,
|
||||||
|
pythonVariable,
|
||||||
|
deploymentType,
|
||||||
|
denoOptions,
|
||||||
|
baseImage,
|
||||||
|
baseBuildImage,
|
||||||
|
buildPack,
|
||||||
|
port,
|
||||||
|
exposePort,
|
||||||
|
installCommand,
|
||||||
|
buildCommand,
|
||||||
|
startCommand,
|
||||||
|
secrets,
|
||||||
|
branch,
|
||||||
|
repository,
|
||||||
|
fqdn
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.digest('hex');
|
||||||
|
const { debug } = settings;
|
||||||
|
if (concurrency === 1) {
|
||||||
|
await prisma.build.updateMany({
|
||||||
|
where: {
|
||||||
|
status: { in: ['queued', 'running'] },
|
||||||
|
id: { not: buildId },
|
||||||
|
applicationId,
|
||||||
|
createdAt: { lt: new Date(new Date().getTime() - 10 * 1000) }
|
||||||
|
},
|
||||||
|
data: { status: 'failed' }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
let imageId = applicationId;
|
||||||
|
let domain = getDomain(fqdn);
|
||||||
|
const volumes =
|
||||||
|
persistentStorage?.map((storage) => {
|
||||||
|
return `${applicationId}${storage.path.replace(/\//gi, '-')}:${buildPack !== 'docker' ? '/app' : ''
|
||||||
|
}${storage.path}`;
|
||||||
|
}) || [];
|
||||||
|
// Previews, we need to get the source branch and set subdomain
|
||||||
|
if (pullmergeRequestId) {
|
||||||
|
branch = sourceBranch;
|
||||||
|
domain = `${pullmergeRequestId}.${domain}`;
|
||||||
|
imageId = `${applicationId}-${pullmergeRequestId}`;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
deployNeeded = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
let imageFound = false;
|
let deployNeeded = true;
|
||||||
try {
|
let destinationType;
|
||||||
await executeDockerCmd({
|
|
||||||
dockerId: destinationDocker.id,
|
|
||||||
command: `docker image inspect ${applicationId}:${tag}`
|
|
||||||
})
|
|
||||||
imageFound = true;
|
|
||||||
} catch (error) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
await copyBaseConfigurationFiles(buildPack, workdir, buildId, applicationId, baseImage);
|
|
||||||
|
|
||||||
if (forceRebuild) deployNeeded = true
|
if (destinationDockerId) {
|
||||||
if (!imageFound || deployNeeded) {
|
destinationType = 'docker';
|
||||||
// if (true) {
|
}
|
||||||
if (buildpacks[buildPack])
|
if (destinationType === 'docker') {
|
||||||
await buildpacks[buildPack]({
|
await prisma.build.update({ where: { id: buildId }, data: { status: 'running' } });
|
||||||
dockerId: destinationDocker.id,
|
const { workdir, repodir } = await createDirectories({ repository, buildId });
|
||||||
buildId,
|
const configuration = await setDefaultConfiguration(application);
|
||||||
|
|
||||||
|
buildPack = configuration.buildPack;
|
||||||
|
port = configuration.port;
|
||||||
|
installCommand = configuration.installCommand;
|
||||||
|
startCommand = configuration.startCommand;
|
||||||
|
buildCommand = configuration.buildCommand;
|
||||||
|
publishDirectory = configuration.publishDirectory;
|
||||||
|
baseDirectory = configuration.baseDirectory;
|
||||||
|
dockerFileLocation = configuration.dockerFileLocation;
|
||||||
|
denoMainFile = configuration.denoMainFile;
|
||||||
|
const commit = await importers[gitSource.type]({
|
||||||
applicationId,
|
applicationId,
|
||||||
domain,
|
debug,
|
||||||
|
workdir,
|
||||||
|
repodir,
|
||||||
|
githubAppId: gitSource.githubApp?.id,
|
||||||
|
gitlabAppId: gitSource.gitlabApp?.id,
|
||||||
|
customPort: gitSource.customPort,
|
||||||
|
repository,
|
||||||
|
branch,
|
||||||
|
buildId,
|
||||||
|
apiUrl: gitSource.apiUrl,
|
||||||
|
htmlUrl: gitSource.htmlUrl,
|
||||||
|
projectId,
|
||||||
|
deployKeyId: gitSource.gitlabApp?.deployKeyId || null,
|
||||||
|
privateSshKey: decrypt(gitSource.gitlabApp?.privateSshKey) || null,
|
||||||
|
forPublic: gitSource.forPublic
|
||||||
|
});
|
||||||
|
if (!commit) {
|
||||||
|
throw new Error('No commit found?');
|
||||||
|
}
|
||||||
|
let tag = commit.slice(0, 7);
|
||||||
|
if (pullmergeRequestId) {
|
||||||
|
tag = `${commit.slice(0, 7)}-${pullmergeRequestId}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await prisma.build.update({ where: { id: buildId }, data: { commit } });
|
||||||
|
} catch (err) { }
|
||||||
|
|
||||||
|
if (!pullmergeRequestId) {
|
||||||
|
if (configHash !== currentHash) {
|
||||||
|
deployNeeded = true;
|
||||||
|
if (configHash) {
|
||||||
|
await saveBuildLog({ line: 'Configuration changed.', buildId, applicationId });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
deployNeeded = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
deployNeeded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
let imageFound = false;
|
||||||
|
try {
|
||||||
|
await executeDockerCmd({
|
||||||
|
dockerId: destinationDocker.id,
|
||||||
|
command: `docker image inspect ${applicationId}:${tag}`
|
||||||
|
})
|
||||||
|
imageFound = true;
|
||||||
|
} catch (error) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
await copyBaseConfigurationFiles(buildPack, workdir, buildId, applicationId, baseImage);
|
||||||
|
|
||||||
|
if (forceRebuild) deployNeeded = true
|
||||||
|
if (!imageFound || deployNeeded) {
|
||||||
|
// if (true) {
|
||||||
|
if (buildpacks[buildPack])
|
||||||
|
await buildpacks[buildPack]({
|
||||||
|
dockerId: destinationDocker.id,
|
||||||
|
buildId,
|
||||||
|
applicationId,
|
||||||
|
domain,
|
||||||
|
name,
|
||||||
|
type,
|
||||||
|
pullmergeRequestId,
|
||||||
|
buildPack,
|
||||||
|
repository,
|
||||||
|
branch,
|
||||||
|
projectId,
|
||||||
|
publishDirectory,
|
||||||
|
debug,
|
||||||
|
commit,
|
||||||
|
tag,
|
||||||
|
workdir,
|
||||||
|
port: exposePort ? `${exposePort}:${port}` : port,
|
||||||
|
installCommand,
|
||||||
|
buildCommand,
|
||||||
|
startCommand,
|
||||||
|
baseDirectory,
|
||||||
|
secrets,
|
||||||
|
phpModules,
|
||||||
|
pythonWSGI,
|
||||||
|
pythonModule,
|
||||||
|
pythonVariable,
|
||||||
|
dockerFileLocation,
|
||||||
|
denoMainFile,
|
||||||
|
denoOptions,
|
||||||
|
baseImage,
|
||||||
|
baseBuildImage,
|
||||||
|
deploymentType
|
||||||
|
});
|
||||||
|
else {
|
||||||
|
await saveBuildLog({ line: `Build pack ${buildPack} not found`, buildId, applicationId });
|
||||||
|
throw new Error(`Build pack ${buildPack} not found.`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await saveBuildLog({ line: 'Build image already available - no rebuild required.', buildId, applicationId });
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker stop -t 0 ${imageId}` })
|
||||||
|
await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker rm ${imageId}` })
|
||||||
|
} catch (error) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
const envs = [
|
||||||
|
`PORT=${port}`
|
||||||
|
];
|
||||||
|
if (secrets.length > 0) {
|
||||||
|
secrets.forEach((secret) => {
|
||||||
|
if (pullmergeRequestId) {
|
||||||
|
if (secret.isPRMRSecret) {
|
||||||
|
envs.push(`${secret.name}=${secret.value}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!secret.isPRMRSecret) {
|
||||||
|
envs.push(`${secret.name}=${secret.value}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await fs.writeFile(`${workdir}/.env`, envs.join('\n'));
|
||||||
|
const labels = makeLabelForStandaloneApplication({
|
||||||
|
applicationId,
|
||||||
|
fqdn,
|
||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
pullmergeRequestId,
|
pullmergeRequestId,
|
||||||
@@ -215,148 +282,96 @@ import * as buildpacks from '../lib/buildPacks';
|
|||||||
repository,
|
repository,
|
||||||
branch,
|
branch,
|
||||||
projectId,
|
projectId,
|
||||||
publishDirectory,
|
|
||||||
debug,
|
|
||||||
commit,
|
|
||||||
tag,
|
|
||||||
workdir,
|
|
||||||
port: exposePort ? `${exposePort}:${port}` : port,
|
port: exposePort ? `${exposePort}:${port}` : port,
|
||||||
|
commit,
|
||||||
installCommand,
|
installCommand,
|
||||||
buildCommand,
|
buildCommand,
|
||||||
startCommand,
|
startCommand,
|
||||||
baseDirectory,
|
baseDirectory,
|
||||||
secrets,
|
publishDirectory
|
||||||
phpModules,
|
|
||||||
pythonWSGI,
|
|
||||||
pythonModule,
|
|
||||||
pythonVariable,
|
|
||||||
dockerFileLocation,
|
|
||||||
denoMainFile,
|
|
||||||
denoOptions,
|
|
||||||
baseImage,
|
|
||||||
baseBuildImage,
|
|
||||||
deploymentType
|
|
||||||
});
|
});
|
||||||
else {
|
let envFound = false;
|
||||||
await saveBuildLog({ line: `Build pack ${buildPack} not found`, buildId, applicationId });
|
try {
|
||||||
throw new Error(`Build pack ${buildPack} not found.`);
|
envFound = !!(await fs.stat(`${workdir}/.env`));
|
||||||
}
|
} catch (error) {
|
||||||
} else {
|
//
|
||||||
await saveBuildLog({ line: 'Build image already available - no rebuild required.', buildId, applicationId });
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker stop -t 0 ${imageId}` })
|
|
||||||
await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker rm ${imageId}` })
|
|
||||||
} catch (error) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
const envs = [
|
|
||||||
`PORT=${port}`
|
|
||||||
];
|
|
||||||
if (secrets.length > 0) {
|
|
||||||
secrets.forEach((secret) => {
|
|
||||||
if (pullmergeRequestId) {
|
|
||||||
if (secret.isPRMRSecret) {
|
|
||||||
envs.push(`${secret.name}=${secret.value}`);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!secret.isPRMRSecret) {
|
|
||||||
envs.push(`${secret.name}=${secret.value}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
try {
|
||||||
|
await saveBuildLog({ line: 'Deployment started.', buildId, applicationId });
|
||||||
|
const composeVolumes = volumes.map((volume) => {
|
||||||
|
return {
|
||||||
|
[`${volume.split(':')[0]}`]: {
|
||||||
|
name: volume.split(':')[0]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const composeFile = {
|
||||||
|
version: '3.8',
|
||||||
|
services: {
|
||||||
|
[imageId]: {
|
||||||
|
image: `${applicationId}:${tag}`,
|
||||||
|
container_name: imageId,
|
||||||
|
volumes,
|
||||||
|
env_file: envFound ? [`${workdir}/.env`] : [],
|
||||||
|
labels,
|
||||||
|
depends_on: [],
|
||||||
|
expose: [port],
|
||||||
|
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
|
||||||
|
// logging: {
|
||||||
|
// driver: 'fluentd',
|
||||||
|
// },
|
||||||
|
...defaultComposeConfiguration(destinationDocker.network),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
networks: {
|
||||||
|
[destinationDocker.network]: {
|
||||||
|
external: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
volumes: Object.assign({}, ...composeVolumes)
|
||||||
|
};
|
||||||
|
await fs.writeFile(`${workdir}/docker-compose.yml`, yaml.dump(composeFile));
|
||||||
|
await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker compose --project-directory ${workdir} up -d` })
|
||||||
|
await saveBuildLog({ line: 'Deployment successful!', buildId, applicationId });
|
||||||
|
} catch (error) {
|
||||||
|
await saveBuildLog({ line: error, buildId, applicationId });
|
||||||
|
await prisma.build.updateMany({
|
||||||
|
where: { id: buildId, status: { in: ['queued', 'running'] } },
|
||||||
|
data: { status: 'failed' }
|
||||||
|
});
|
||||||
|
throw new Error(error);
|
||||||
|
}
|
||||||
|
await saveBuildLog({ line: 'Proxy will be updated shortly.', buildId, applicationId });
|
||||||
|
await prisma.build.update({ where: { id: buildId }, data: { status: 'success' } });
|
||||||
|
if (!pullmergeRequestId) await prisma.application.update({
|
||||||
|
where: { id: applicationId },
|
||||||
|
data: { configHash: currentHash }
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await fs.writeFile(`${workdir}/.env`, envs.join('\n'));
|
catch (error) {
|
||||||
const labels = makeLabelForStandaloneApplication({
|
await prisma.build.updateMany({
|
||||||
applicationId,
|
where: { id: buildId, status: { in: ['queued', 'running'] } },
|
||||||
fqdn,
|
|
||||||
name,
|
|
||||||
type,
|
|
||||||
pullmergeRequestId,
|
|
||||||
buildPack,
|
|
||||||
repository,
|
|
||||||
branch,
|
|
||||||
projectId,
|
|
||||||
port: exposePort ? `${exposePort}:${port}` : port,
|
|
||||||
commit,
|
|
||||||
installCommand,
|
|
||||||
buildCommand,
|
|
||||||
startCommand,
|
|
||||||
baseDirectory,
|
|
||||||
publishDirectory
|
|
||||||
});
|
|
||||||
let envFound = false;
|
|
||||||
try {
|
|
||||||
envFound = !!(await fs.stat(`${workdir}/.env`));
|
|
||||||
} catch (error) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
await saveBuildLog({ line: 'Deployment started.', buildId, applicationId });
|
|
||||||
const composeVolumes = volumes.map((volume) => {
|
|
||||||
return {
|
|
||||||
[`${volume.split(':')[0]}`]: {
|
|
||||||
name: volume.split(':')[0]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
const composeFile = {
|
|
||||||
version: '3.8',
|
|
||||||
services: {
|
|
||||||
[imageId]: {
|
|
||||||
image: `${applicationId}:${tag}`,
|
|
||||||
container_name: imageId,
|
|
||||||
volumes,
|
|
||||||
env_file: envFound ? [`${workdir}/.env`] : [],
|
|
||||||
labels,
|
|
||||||
depends_on: [],
|
|
||||||
expose: [port],
|
|
||||||
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
|
|
||||||
// logging: {
|
|
||||||
// driver: 'fluentd',
|
|
||||||
// },
|
|
||||||
...defaultComposeConfiguration(destinationDocker.network),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
networks: {
|
|
||||||
[destinationDocker.network]: {
|
|
||||||
external: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
volumes: Object.assign({}, ...composeVolumes)
|
|
||||||
};
|
|
||||||
await fs.writeFile(`${workdir}/docker-compose.yml`, yaml.dump(composeFile));
|
|
||||||
await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker compose --project-directory ${workdir} up -d` })
|
|
||||||
await saveBuildLog({ line: 'Deployment successful!', buildId, applicationId });
|
|
||||||
} catch (error) {
|
|
||||||
await saveBuildLog({ line: error, buildId, applicationId });
|
|
||||||
await prisma.build.update({
|
|
||||||
where: { id: message.build_id },
|
|
||||||
data: { status: 'failed' }
|
data: { status: 'failed' }
|
||||||
});
|
});
|
||||||
throw new Error(error);
|
await saveBuildLog({ line: error, buildId, applicationId: application.id });
|
||||||
}
|
}
|
||||||
await saveBuildLog({ line: 'Proxy will be updated shortly.', buildId, applicationId });
|
});
|
||||||
await prisma.build.update({ where: { id: message.build_id }, data: { status: 'success' } });
|
|
||||||
if (!pullmergeRequestId) await prisma.application.update({
|
|
||||||
where: { id: applicationId },
|
|
||||||
data: { configHash: currentHash }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
|
||||||
await prisma.build.update({
|
await pAll.default(actions, { concurrency })
|
||||||
where: { id: message.build_id },
|
}
|
||||||
data: { status: 'failed' }
|
} catch (error) {
|
||||||
});
|
console.log(error)
|
||||||
await saveBuildLog({ line: error, buildId, applicationId });
|
} finally {
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
await th()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} else process.exit(0);
|
} else process.exit(0);
|
||||||
})();
|
})();
|
||||||
|
|||||||
226
apps/api/src/jobs/infrastructure.ts
Normal file
226
apps/api/src/jobs/infrastructure.ts
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
import { parentPort } from 'node:worker_threads';
|
||||||
|
import axios from 'axios';
|
||||||
|
import { compareVersions } from 'compare-versions';
|
||||||
|
import { asyncExecShell, cleanupDockerStorage, executeDockerCmd, isDev, prisma, startTraefikTCPProxy, generateDatabaseConfiguration, startTraefikProxy, listSettings, version, createRemoteEngineConfiguration } from '../lib/common';
|
||||||
|
|
||||||
|
async function autoUpdater() {
|
||||||
|
try {
|
||||||
|
const currentVersion = version;
|
||||||
|
const { data: versions } = await axios
|
||||||
|
.get(
|
||||||
|
`https://get.coollabs.io/versions.json`
|
||||||
|
, {
|
||||||
|
params: {
|
||||||
|
appId: process.env['COOLIFY_APP_ID'] || undefined,
|
||||||
|
version: currentVersion
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const latestVersion = versions['coolify'].main.version;
|
||||||
|
const isUpdateAvailable = compareVersions(latestVersion, currentVersion);
|
||||||
|
if (isUpdateAvailable === 1) {
|
||||||
|
const activeCount = 0
|
||||||
|
if (activeCount === 0) {
|
||||||
|
if (!isDev) {
|
||||||
|
await asyncExecShell(`docker pull coollabsio/coolify:${latestVersion}`);
|
||||||
|
await asyncExecShell(`env | grep COOLIFY > .env`);
|
||||||
|
await asyncExecShell(
|
||||||
|
`sed -i '/COOLIFY_AUTO_UPDATE=/cCOOLIFY_AUTO_UPDATE=true' .env`
|
||||||
|
);
|
||||||
|
await asyncExecShell(
|
||||||
|
`docker run --rm -tid --env-file .env -v /var/run/docker.sock:/var/run/docker.sock -v coolify-db coollabsio/coolify:${latestVersion} /bin/sh -c "env | grep COOLIFY > .env && echo 'TAG=${latestVersion}' >> .env && docker stop -t 0 coolify && docker rm coolify && docker compose up -d --force-recreate"`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log('Updating (not really in dev mode).');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) { }
|
||||||
|
}
|
||||||
|
async function checkProxies() {
|
||||||
|
try {
|
||||||
|
const { default: isReachable } = await import('is-port-reachable');
|
||||||
|
let portReachable;
|
||||||
|
|
||||||
|
const { arch, ipv4, ipv6 } = await listSettings();
|
||||||
|
|
||||||
|
// Coolify Proxy local
|
||||||
|
const engine = '/var/run/docker.sock';
|
||||||
|
const localDocker = await prisma.destinationDocker.findFirst({
|
||||||
|
where: { engine, network: 'coolify', isCoolifyProxyUsed: true }
|
||||||
|
});
|
||||||
|
if (localDocker) {
|
||||||
|
portReachable = await isReachable(80, { host: ipv4 || ipv6 })
|
||||||
|
if (!portReachable) {
|
||||||
|
await startTraefikProxy(localDocker.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Coolify Proxy remote
|
||||||
|
const remoteDocker = await prisma.destinationDocker.findMany({
|
||||||
|
where: { remoteEngine: true, remoteVerified: true }
|
||||||
|
});
|
||||||
|
if (remoteDocker.length > 0) {
|
||||||
|
for (const docker of remoteDocker) {
|
||||||
|
if (docker.isCoolifyProxyUsed) {
|
||||||
|
portReachable = await isReachable(80, { host: docker.remoteIpAddress })
|
||||||
|
if (!portReachable) {
|
||||||
|
await startTraefikProxy(docker.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await createRemoteEngineConfiguration(docker.id)
|
||||||
|
} catch (error) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TCP Proxies
|
||||||
|
const databasesWithPublicPort = await prisma.database.findMany({
|
||||||
|
where: { publicPort: { not: null } },
|
||||||
|
include: { settings: true, destinationDocker: true }
|
||||||
|
});
|
||||||
|
for (const database of databasesWithPublicPort) {
|
||||||
|
const { destinationDockerId, destinationDocker, publicPort, id } = database;
|
||||||
|
if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) {
|
||||||
|
const { privatePort } = generateDatabaseConfiguration(database, arch);
|
||||||
|
portReachable = await isReachable(publicPort, { host: destinationDocker.remoteIpAddress || ipv4 || ipv6 })
|
||||||
|
if (!portReachable) {
|
||||||
|
await startTraefikTCPProxy(destinationDocker, id, publicPort, privatePort);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const wordpressWithFtp = await prisma.wordpress.findMany({
|
||||||
|
where: { ftpPublicPort: { not: null } },
|
||||||
|
include: { service: { include: { destinationDocker: true } } }
|
||||||
|
});
|
||||||
|
for (const ftp of wordpressWithFtp) {
|
||||||
|
const { service, ftpPublicPort } = ftp;
|
||||||
|
const { destinationDockerId, destinationDocker, id } = service;
|
||||||
|
if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) {
|
||||||
|
portReachable = await isReachable(ftpPublicPort, { host: destinationDocker.remoteIpAddress || ipv4 || ipv6 })
|
||||||
|
if (!portReachable) {
|
||||||
|
await startTraefikTCPProxy(destinationDocker, id, ftpPublicPort, 22, 'wordpressftp');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTP Proxies
|
||||||
|
const minioInstances = await prisma.minio.findMany({
|
||||||
|
where: { publicPort: { not: null } },
|
||||||
|
include: { service: { include: { destinationDocker: true } } }
|
||||||
|
});
|
||||||
|
for (const minio of minioInstances) {
|
||||||
|
const { service, publicPort } = minio;
|
||||||
|
const { destinationDockerId, destinationDocker, id } = service;
|
||||||
|
if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) {
|
||||||
|
portReachable = await isReachable(publicPort, { host: destinationDocker.remoteIpAddress || ipv4 || ipv6 })
|
||||||
|
if (!portReachable) {
|
||||||
|
await startTraefikTCPProxy(destinationDocker, id, publicPort, 9000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function cleanupPrismaEngines() {
|
||||||
|
if (!isDev) {
|
||||||
|
try {
|
||||||
|
const { stdout } = await asyncExecShell(`ps -ef | grep /app/prisma-engines/query-engine | grep -v grep | wc -l | xargs`)
|
||||||
|
if (stdout.trim() != null && stdout.trim() != '' && Number(stdout.trim()) > 1) {
|
||||||
|
await asyncExecShell(`killall -q -e /app/prisma-engines/query-engine -o 1m`)
|
||||||
|
}
|
||||||
|
} catch (error) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function cleanupStorage() {
|
||||||
|
const destinationDockers = await prisma.destinationDocker.findMany();
|
||||||
|
let enginesDone = new Set()
|
||||||
|
for (const destination of destinationDockers) {
|
||||||
|
if (enginesDone.has(destination.engine) || enginesDone.has(destination.remoteIpAddress)) return
|
||||||
|
if (destination.engine) enginesDone.add(destination.engine)
|
||||||
|
if (destination.remoteIpAddress) enginesDone.add(destination.remoteIpAddress)
|
||||||
|
|
||||||
|
let lowDiskSpace = false;
|
||||||
|
try {
|
||||||
|
let stdout = null
|
||||||
|
if (!isDev) {
|
||||||
|
const output = await executeDockerCmd({ dockerId: destination.id, command: `CONTAINER=$(docker ps -lq | head -1) && docker exec $CONTAINER sh -c 'df -kPT /'` })
|
||||||
|
stdout = output.stdout;
|
||||||
|
} else {
|
||||||
|
const output = await asyncExecShell(
|
||||||
|
`df -kPT /`
|
||||||
|
);
|
||||||
|
stdout = output.stdout;
|
||||||
|
}
|
||||||
|
let lines = stdout.trim().split('\n');
|
||||||
|
let header = lines[0];
|
||||||
|
let regex =
|
||||||
|
/^Filesystem\s+|Type\s+|1024-blocks|\s+Used|\s+Available|\s+Capacity|\s+Mounted on\s*$/g;
|
||||||
|
const boundaries = [];
|
||||||
|
let match;
|
||||||
|
|
||||||
|
while ((match = regex.exec(header))) {
|
||||||
|
boundaries.push(match[0].length);
|
||||||
|
}
|
||||||
|
|
||||||
|
boundaries[boundaries.length - 1] = -1;
|
||||||
|
const data = lines.slice(1).map((line) => {
|
||||||
|
const cl = boundaries.map((boundary) => {
|
||||||
|
const column = boundary > 0 ? line.slice(0, boundary) : line;
|
||||||
|
line = line.slice(boundary);
|
||||||
|
return column.trim();
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
capacity: Number.parseInt(cl[5], 10) / 100
|
||||||
|
};
|
||||||
|
});
|
||||||
|
if (data.length > 0) {
|
||||||
|
const { capacity } = data[0];
|
||||||
|
if (capacity > 0.8) {
|
||||||
|
lowDiskSpace = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) { }
|
||||||
|
await cleanupDockerStorage(destination.id, lowDiskSpace, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
let status = {
|
||||||
|
cleanupStorage: false,
|
||||||
|
autoUpdater: false
|
||||||
|
}
|
||||||
|
if (parentPort) {
|
||||||
|
parentPort.on('message', async (message) => {
|
||||||
|
if (parentPort) {
|
||||||
|
if (message === 'error') throw new Error('oops');
|
||||||
|
if (message === 'cancel') {
|
||||||
|
parentPort.postMessage('cancelled');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
if (message === 'action:cleanupStorage') {
|
||||||
|
if (!status.autoUpdater) {
|
||||||
|
status.cleanupStorage = true
|
||||||
|
await cleanupStorage();
|
||||||
|
status.cleanupStorage = false
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (message === 'action:cleanupPrismaEngines') {
|
||||||
|
await cleanupPrismaEngines();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (message === 'action:checkProxies') {
|
||||||
|
await checkProxies();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (message === 'action:autoUpdater') {
|
||||||
|
if (!status.cleanupStorage) {
|
||||||
|
status.autoUpdater = true
|
||||||
|
await autoUpdater();
|
||||||
|
status.autoUpdater = false
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else process.exit(0);
|
||||||
|
})();
|
||||||
@@ -512,7 +512,6 @@ export async function copyBaseConfigurationFiles(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -541,9 +540,6 @@ export async function buildImage({
|
|||||||
} else {
|
} else {
|
||||||
await saveBuildLog({ line: `Building image started.`, buildId, applicationId });
|
await saveBuildLog({ line: `Building image started.`, buildId, applicationId });
|
||||||
}
|
}
|
||||||
if (debug) {
|
|
||||||
await saveBuildLog({ line: `\n###############\nIMPORTANT: Due to some issues during implementing Remote Docker Engine, the builds logs are not streamed at the moment - but will be soon! You will see the full build log when the build is finished!\n###############`, buildId, applicationId });
|
|
||||||
}
|
|
||||||
if (!debug && isCache) {
|
if (!debug && isCache) {
|
||||||
await saveBuildLog({
|
await saveBuildLog({
|
||||||
line: `Debug turned off. To see more details, allow it in the configuration.`,
|
line: `Debug turned off. To see more details, allow it in the configuration.`,
|
||||||
@@ -553,54 +549,11 @@ export async function buildImage({
|
|||||||
}
|
}
|
||||||
const dockerFile = isCache ? `${dockerFileLocation}-cache` : `${dockerFileLocation}`
|
const dockerFile = isCache ? `${dockerFileLocation}-cache` : `${dockerFileLocation}`
|
||||||
const cache = `${applicationId}:${tag}${isCache ? '-cache' : ''}`
|
const cache = `${applicationId}:${tag}${isCache ? '-cache' : ''}`
|
||||||
const { stderr } = await executeDockerCmd({ dockerId, command: `docker build --progress plain -f ${workdir}/${dockerFile} -t ${cache} ${workdir}` })
|
await executeDockerCmd({ debug, buildId, applicationId, dockerId, command: `docker build --progress plain -f ${workdir}/${dockerFile} -t ${cache} ${workdir}` })
|
||||||
if (debug) {
|
const { status } = await prisma.build.findUnique({ where: { id: buildId } })
|
||||||
const array = stderr.split('\n')
|
if (status === 'canceled') {
|
||||||
for (const line of array) {
|
throw new Error('Deployment canceled.')
|
||||||
if (line !== '\n') {
|
|
||||||
await saveBuildLog({
|
|
||||||
line: `${line.replace('\n', '')}`,
|
|
||||||
buildId,
|
|
||||||
applicationId
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// await new Promise((resolve, reject) => {
|
|
||||||
// const command = spawn(`docker`, ['build', '-f', `${workdir}${dockerFile}`, '-t', `${cache}`,`${workdir}`], {
|
|
||||||
// env: {
|
|
||||||
// DOCKER_HOST: 'ssh://root@95.217.178.202',
|
|
||||||
// DOCKER_BUILDKIT: '1'
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// command.stdout.on('data', function (data) {
|
|
||||||
// console.log('stdout: ' + data);
|
|
||||||
// });
|
|
||||||
// command.stderr.on('data', function (data) {
|
|
||||||
// console.log('stderr: ' + data);
|
|
||||||
// });
|
|
||||||
// command.on('error', function (error) {
|
|
||||||
// console.log(error)
|
|
||||||
// reject(error)
|
|
||||||
// })
|
|
||||||
// command.on('exit', function (code) {
|
|
||||||
// console.log('exit code: ' + code);
|
|
||||||
// resolve(code)
|
|
||||||
// });
|
|
||||||
// })
|
|
||||||
|
|
||||||
|
|
||||||
// console.log({ stdout, stderr })
|
|
||||||
// const stream = await docker.engine.buildImage(
|
|
||||||
// { src: ['.'], context: workdir },
|
|
||||||
// {
|
|
||||||
// dockerfile: isCache ? `${dockerFileLocation}-cache` : dockerFileLocation,
|
|
||||||
// t: `${applicationId}:${tag}${isCache ? '-cache' : ''}`
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
// await streamEvents({ stream, docker, buildId, applicationId, debug });
|
|
||||||
if (isCache) {
|
if (isCache) {
|
||||||
await saveBuildLog({ line: `Building cache image successful.`, buildId, applicationId });
|
await saveBuildLog({ line: `Building cache image successful.`, buildId, applicationId });
|
||||||
} else {
|
} else {
|
||||||
@@ -717,11 +670,10 @@ export async function buildCacheImageWithNode(data, imageForBuild) {
|
|||||||
if (isPnpm) {
|
if (isPnpm) {
|
||||||
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@7');
|
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@7');
|
||||||
}
|
}
|
||||||
|
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
||||||
if (installCommand) {
|
if (installCommand) {
|
||||||
Dockerfile.push(`COPY .${baseDirectory || ''}/package.json ./`);
|
|
||||||
Dockerfile.push(`RUN ${installCommand}`);
|
Dockerfile.push(`RUN ${installCommand}`);
|
||||||
}
|
}
|
||||||
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
|
||||||
Dockerfile.push(`RUN ${buildCommand}`);
|
Dockerfile.push(`RUN ${buildCommand}`);
|
||||||
await fs.writeFile(`${workdir}/Dockerfile-cache`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}/Dockerfile-cache`, Dockerfile.join('\n'));
|
||||||
await buildImage({ ...data, isCache: true });
|
await buildImage({ ...data, isCache: true });
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -76,7 +76,6 @@ export async function removeContainer({
|
|||||||
await executeDockerCmd({ dockerId, command: `docker rm ${id}` })
|
await executeDockerCmd({ dockerId, command: `docker rm ${id}` })
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,54 +2,29 @@ import Bree from 'bree';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import Cabin from 'cabin';
|
import Cabin from 'cabin';
|
||||||
import TSBree from '@breejs/ts-worker';
|
import TSBree from '@breejs/ts-worker';
|
||||||
import { isDev } from './common';
|
|
||||||
|
export const isDev = process.env.NODE_ENV === 'development';
|
||||||
|
|
||||||
Bree.extend(TSBree);
|
Bree.extend(TSBree);
|
||||||
|
|
||||||
const options: any = {
|
const options: any = {
|
||||||
defaultExtension: 'js',
|
defaultExtension: 'js',
|
||||||
|
// logger: new Cabin(),
|
||||||
logger: false,
|
logger: false,
|
||||||
workerMessageHandler: async ({ name, message }) => {
|
workerMessageHandler: async ({ name, message }) => {
|
||||||
if (name === 'deployApplication') {
|
if (name === 'deployApplication' && message?.deploying) {
|
||||||
if (message.pending === 0 && message.size === 0) {
|
if (scheduler.workers.has('autoUpdater') || scheduler.workers.has('cleanupStorage')) {
|
||||||
if (message.caller === 'autoUpdater') {
|
scheduler.workers.get('deployApplication').postMessage('cancel')
|
||||||
if (!scheduler.workers.has('autoUpdater')) {
|
|
||||||
await scheduler.stop('deployApplication');
|
|
||||||
await scheduler.run('autoUpdater')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (message.caller === 'cleanupStorage') {
|
|
||||||
if (!scheduler.workers.has('cleanupStorage')) {
|
|
||||||
await scheduler.run('cleanupStorage')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
jobs: [
|
jobs: [
|
||||||
{
|
{ name: 'infrastructure' },
|
||||||
name: 'deployApplication'
|
{ name: 'deployApplication' },
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'cleanupStorage',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'cleanupPrismaEngines',
|
|
||||||
interval: '1m'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'checkProxies',
|
|
||||||
interval: '10s'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'autoUpdater',
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
if (isDev) options.root = path.join(__dirname, '../jobs');
|
if (isDev) options.root = path.join(__dirname, '../jobs');
|
||||||
|
|
||||||
|
|
||||||
export const scheduler = new Bree(options);
|
export const scheduler = new Bree(options);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
383
apps/api/src/lib/services/common.ts
Normal file
383
apps/api/src/lib/services/common.ts
Normal file
@@ -0,0 +1,383 @@
|
|||||||
|
|
||||||
|
import cuid from 'cuid';
|
||||||
|
import { encrypt, generatePassword, prisma } from '../common';
|
||||||
|
|
||||||
|
export const includeServices: any = {
|
||||||
|
destinationDocker: true,
|
||||||
|
persistentStorage: true,
|
||||||
|
serviceSecret: true,
|
||||||
|
minio: true,
|
||||||
|
plausibleAnalytics: true,
|
||||||
|
vscodeserver: true,
|
||||||
|
wordpress: true,
|
||||||
|
ghost: true,
|
||||||
|
meiliSearch: true,
|
||||||
|
umami: true,
|
||||||
|
hasura: true,
|
||||||
|
fider: true,
|
||||||
|
moodle: true,
|
||||||
|
appwrite: true,
|
||||||
|
glitchTip: true,
|
||||||
|
searxng: true,
|
||||||
|
weblate: true,
|
||||||
|
taiga: true
|
||||||
|
};
|
||||||
|
export async function configureServiceType({
|
||||||
|
id,
|
||||||
|
type
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
type: string;
|
||||||
|
}): Promise<void> {
|
||||||
|
if (type === 'plausibleanalytics') {
|
||||||
|
const password = encrypt(generatePassword({}));
|
||||||
|
const postgresqlUser = cuid();
|
||||||
|
const postgresqlPassword = encrypt(generatePassword({}));
|
||||||
|
const postgresqlDatabase = 'plausibleanalytics';
|
||||||
|
const secretKeyBase = encrypt(generatePassword({ length: 64 }));
|
||||||
|
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type,
|
||||||
|
plausibleAnalytics: {
|
||||||
|
create: {
|
||||||
|
postgresqlDatabase,
|
||||||
|
postgresqlUser,
|
||||||
|
postgresqlPassword,
|
||||||
|
password,
|
||||||
|
secretKeyBase
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (type === 'nocodb') {
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: { type }
|
||||||
|
});
|
||||||
|
} else if (type === 'minio') {
|
||||||
|
const rootUser = cuid();
|
||||||
|
const rootUserPassword = encrypt(generatePassword({}));
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: { type, minio: { create: { rootUser, rootUserPassword } } }
|
||||||
|
});
|
||||||
|
} else if (type === 'vscodeserver') {
|
||||||
|
const password = encrypt(generatePassword({}));
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: { type, vscodeserver: { create: { password } } }
|
||||||
|
});
|
||||||
|
} else if (type === 'wordpress') {
|
||||||
|
const mysqlUser = cuid();
|
||||||
|
const mysqlPassword = encrypt(generatePassword({}));
|
||||||
|
const mysqlRootUser = cuid();
|
||||||
|
const mysqlRootUserPassword = encrypt(generatePassword({}));
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type,
|
||||||
|
wordpress: { create: { mysqlPassword, mysqlRootUserPassword, mysqlRootUser, mysqlUser } }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (type === 'vaultwarden') {
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (type === 'languagetool') {
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (type === 'n8n') {
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (type === 'uptimekuma') {
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (type === 'ghost') {
|
||||||
|
const defaultEmail = `${cuid()}@example.com`;
|
||||||
|
const defaultPassword = encrypt(generatePassword({}));
|
||||||
|
const mariadbUser = cuid();
|
||||||
|
const mariadbPassword = encrypt(generatePassword({}));
|
||||||
|
const mariadbRootUser = cuid();
|
||||||
|
const mariadbRootUserPassword = encrypt(generatePassword({}));
|
||||||
|
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type,
|
||||||
|
ghost: {
|
||||||
|
create: {
|
||||||
|
defaultEmail,
|
||||||
|
defaultPassword,
|
||||||
|
mariadbUser,
|
||||||
|
mariadbPassword,
|
||||||
|
mariadbRootUser,
|
||||||
|
mariadbRootUserPassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (type === 'meilisearch') {
|
||||||
|
const masterKey = encrypt(generatePassword({ length: 32 }));
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type,
|
||||||
|
meiliSearch: { create: { masterKey } }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (type === 'umami') {
|
||||||
|
const umamiAdminPassword = encrypt(generatePassword({}));
|
||||||
|
const postgresqlUser = cuid();
|
||||||
|
const postgresqlPassword = encrypt(generatePassword({}));
|
||||||
|
const postgresqlDatabase = 'umami';
|
||||||
|
const hashSalt = encrypt(generatePassword({ length: 64 }));
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type,
|
||||||
|
umami: {
|
||||||
|
create: {
|
||||||
|
umamiAdminPassword,
|
||||||
|
postgresqlDatabase,
|
||||||
|
postgresqlPassword,
|
||||||
|
postgresqlUser,
|
||||||
|
hashSalt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (type === 'hasura') {
|
||||||
|
const postgresqlUser = cuid();
|
||||||
|
const postgresqlPassword = encrypt(generatePassword({}));
|
||||||
|
const postgresqlDatabase = 'hasura';
|
||||||
|
const graphQLAdminPassword = encrypt(generatePassword({}));
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type,
|
||||||
|
hasura: {
|
||||||
|
create: {
|
||||||
|
postgresqlDatabase,
|
||||||
|
postgresqlPassword,
|
||||||
|
postgresqlUser,
|
||||||
|
graphQLAdminPassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (type === 'fider') {
|
||||||
|
const postgresqlUser = cuid();
|
||||||
|
const postgresqlPassword = encrypt(generatePassword({}));
|
||||||
|
const postgresqlDatabase = 'fider';
|
||||||
|
const jwtSecret = encrypt(generatePassword({ length: 64, symbols: true }));
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type,
|
||||||
|
fider: {
|
||||||
|
create: {
|
||||||
|
postgresqlDatabase,
|
||||||
|
postgresqlPassword,
|
||||||
|
postgresqlUser,
|
||||||
|
jwtSecret
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (type === 'moodle') {
|
||||||
|
const defaultUsername = cuid();
|
||||||
|
const defaultPassword = encrypt(generatePassword({}));
|
||||||
|
const defaultEmail = `${cuid()} @example.com`;
|
||||||
|
const mariadbUser = cuid();
|
||||||
|
const mariadbPassword = encrypt(generatePassword({}));
|
||||||
|
const mariadbDatabase = 'moodle_db';
|
||||||
|
const mariadbRootUser = cuid();
|
||||||
|
const mariadbRootUserPassword = encrypt(generatePassword({}));
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type,
|
||||||
|
moodle: {
|
||||||
|
create: {
|
||||||
|
defaultUsername,
|
||||||
|
defaultPassword,
|
||||||
|
defaultEmail,
|
||||||
|
mariadbUser,
|
||||||
|
mariadbPassword,
|
||||||
|
mariadbDatabase,
|
||||||
|
mariadbRootUser,
|
||||||
|
mariadbRootUserPassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (type === 'appwrite') {
|
||||||
|
const opensslKeyV1 = encrypt(generatePassword({}));
|
||||||
|
const executorSecret = encrypt(generatePassword({}));
|
||||||
|
const redisPassword = encrypt(generatePassword({}));
|
||||||
|
const mariadbHost = `${id}-mariadb`
|
||||||
|
const mariadbUser = cuid();
|
||||||
|
const mariadbPassword = encrypt(generatePassword({}));
|
||||||
|
const mariadbDatabase = 'appwrite';
|
||||||
|
const mariadbRootUser = cuid();
|
||||||
|
const mariadbRootUserPassword = encrypt(generatePassword({}));
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type,
|
||||||
|
appwrite: {
|
||||||
|
create: {
|
||||||
|
opensslKeyV1,
|
||||||
|
executorSecret,
|
||||||
|
redisPassword,
|
||||||
|
mariadbHost,
|
||||||
|
mariadbUser,
|
||||||
|
mariadbPassword,
|
||||||
|
mariadbDatabase,
|
||||||
|
mariadbRootUser,
|
||||||
|
mariadbRootUserPassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (type === 'glitchTip') {
|
||||||
|
const defaultUsername = cuid();
|
||||||
|
const defaultEmail = `${defaultUsername}@example.com`;
|
||||||
|
const defaultPassword = encrypt(generatePassword({}));
|
||||||
|
const postgresqlUser = cuid();
|
||||||
|
const postgresqlPassword = encrypt(generatePassword({}));
|
||||||
|
const postgresqlDatabase = 'glitchTip';
|
||||||
|
const secretKeyBase = encrypt(generatePassword({ length: 64 }));
|
||||||
|
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type,
|
||||||
|
glitchTip: {
|
||||||
|
create: {
|
||||||
|
postgresqlDatabase,
|
||||||
|
postgresqlUser,
|
||||||
|
postgresqlPassword,
|
||||||
|
secretKeyBase,
|
||||||
|
defaultEmail,
|
||||||
|
defaultUsername,
|
||||||
|
defaultPassword,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (type === 'searxng') {
|
||||||
|
const secretKey = encrypt(generatePassword({ length: 32, isHex: true }))
|
||||||
|
const redisPassword = encrypt(generatePassword({}));
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type,
|
||||||
|
searxng: {
|
||||||
|
create: {
|
||||||
|
secretKey,
|
||||||
|
redisPassword,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (type === 'weblate') {
|
||||||
|
const adminPassword = encrypt(generatePassword({}))
|
||||||
|
const postgresqlUser = cuid();
|
||||||
|
const postgresqlPassword = encrypt(generatePassword({}));
|
||||||
|
const postgresqlDatabase = 'weblate';
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type,
|
||||||
|
weblate: {
|
||||||
|
create: {
|
||||||
|
adminPassword,
|
||||||
|
postgresqlHost: `${id}-postgresql`,
|
||||||
|
postgresqlPort: 5432,
|
||||||
|
postgresqlUser,
|
||||||
|
postgresqlPassword,
|
||||||
|
postgresqlDatabase,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (type === 'taiga') {
|
||||||
|
const secretKey = encrypt(generatePassword({}))
|
||||||
|
const erlangSecret = encrypt(generatePassword({}))
|
||||||
|
const rabbitMQUser = cuid();
|
||||||
|
const djangoAdminUser = cuid();
|
||||||
|
const djangoAdminPassword = encrypt(generatePassword({}))
|
||||||
|
const rabbitMQPassword = encrypt(generatePassword({}))
|
||||||
|
const postgresqlUser = cuid();
|
||||||
|
const postgresqlPassword = encrypt(generatePassword({}));
|
||||||
|
const postgresqlDatabase = 'taiga';
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type,
|
||||||
|
taiga: {
|
||||||
|
create: {
|
||||||
|
secretKey,
|
||||||
|
erlangSecret,
|
||||||
|
djangoAdminUser,
|
||||||
|
djangoAdminPassword,
|
||||||
|
rabbitMQUser,
|
||||||
|
rabbitMQPassword,
|
||||||
|
postgresqlHost: `${id}-postgresql`,
|
||||||
|
postgresqlPort: 5432,
|
||||||
|
postgresqlUser,
|
||||||
|
postgresqlPassword,
|
||||||
|
postgresqlDatabase,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function removeService({ id }: { id: string }): Promise<void> {
|
||||||
|
await prisma.serviceSecret.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.servicePersistentStorage.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.meiliSearch.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.fider.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.ghost.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.umami.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.hasura.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.plausibleAnalytics.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.minio.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.vscodeserver.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.wordpress.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.glitchTip.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.moodle.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.appwrite.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.searxng.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.weblate.deleteMany({ where: { serviceId: id } });
|
||||||
|
await prisma.taiga.deleteMany({ where: { serviceId: id } });
|
||||||
|
|
||||||
|
await prisma.service.delete({ where: { id } });
|
||||||
|
}
|
||||||
2589
apps/api/src/lib/services/handlers.ts
Normal file
2589
apps/api/src/lib/services/handlers.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -599,6 +599,54 @@ export const glitchTip = [{
|
|||||||
isBoolean: false,
|
isBoolean: false,
|
||||||
isEncrypted: true
|
isEncrypted: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'emailSmtpHost',
|
||||||
|
isEditable: true,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'emailSmtpPassword',
|
||||||
|
isEditable: true,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'emailSmtpUseSsl',
|
||||||
|
isEditable: true,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: true,
|
||||||
|
isEncrypted: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'emailSmtpUseSsl',
|
||||||
|
isEditable: true,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: true,
|
||||||
|
isEncrypted: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'emailSmtpPort',
|
||||||
|
isEditable: true,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: true,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'emailSmtpUser',
|
||||||
|
isEditable: true,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'defaultEmail',
|
name: 'defaultEmail',
|
||||||
isEditable: false,
|
isEditable: false,
|
||||||
@@ -624,7 +672,7 @@ export const glitchTip = [{
|
|||||||
isEncrypted: true
|
isEncrypted: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'defaultFromEmail',
|
name: 'defaultEmailFrom',
|
||||||
isEditable: true,
|
isEditable: true,
|
||||||
isLowerCase: false,
|
isLowerCase: false,
|
||||||
isNumber: false,
|
isNumber: false,
|
||||||
@@ -671,3 +719,149 @@ export const glitchTip = [{
|
|||||||
isBoolean: true,
|
isBoolean: true,
|
||||||
isEncrypted: false
|
isEncrypted: false
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
export const searxng = [{
|
||||||
|
name: 'secretKey',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'redisPassword',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: true
|
||||||
|
}]
|
||||||
|
|
||||||
|
export const weblate = [{
|
||||||
|
name: 'adminPassword',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'postgresqlHost',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'postgresqlPort',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'postgresqlUser',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'postgresqlPassword',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'postgresqlDatabase',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: false
|
||||||
|
}]
|
||||||
|
export const taiga = [{
|
||||||
|
name: 'secretKey',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'djangoAdminUser',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'djangoAdminPassword',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'rabbitMQUser',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'rabbitMQPassword',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'postgresqlHost',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'postgresqlPort',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'postgresqlUser',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'postgresqlPassword',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'postgresqlDatabase',
|
||||||
|
isEditable: false,
|
||||||
|
isLowerCase: false,
|
||||||
|
isNumber: false,
|
||||||
|
isBoolean: false,
|
||||||
|
isEncrypted: false
|
||||||
|
}]
|
||||||
215
apps/api/src/lib/services/supportedVersions.ts
Normal file
215
apps/api/src/lib/services/supportedVersions.ts
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
export const supportedServiceTypesAndVersions = [
|
||||||
|
{
|
||||||
|
name: 'plausibleanalytics',
|
||||||
|
fancyName: 'Plausible Analytics',
|
||||||
|
baseImage: 'plausible/analytics',
|
||||||
|
images: ['bitnami/postgresql:13.2.0', 'yandex/clickhouse-server:21.3.2.5'],
|
||||||
|
versions: ['latest', 'stable'],
|
||||||
|
recommendedVersion: 'stable',
|
||||||
|
ports: {
|
||||||
|
main: 8000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'nocodb',
|
||||||
|
fancyName: 'NocoDB',
|
||||||
|
baseImage: 'nocodb/nocodb',
|
||||||
|
versions: ['latest'],
|
||||||
|
recommendedVersion: 'latest',
|
||||||
|
ports: {
|
||||||
|
main: 8080
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'minio',
|
||||||
|
fancyName: 'MinIO',
|
||||||
|
baseImage: 'minio/minio',
|
||||||
|
versions: ['latest'],
|
||||||
|
recommendedVersion: 'latest',
|
||||||
|
ports: {
|
||||||
|
main: 9001
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'vscodeserver',
|
||||||
|
fancyName: 'VSCode Server',
|
||||||
|
baseImage: 'codercom/code-server',
|
||||||
|
versions: ['latest'],
|
||||||
|
recommendedVersion: 'latest',
|
||||||
|
ports: {
|
||||||
|
main: 8080
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'wordpress',
|
||||||
|
fancyName: 'Wordpress',
|
||||||
|
baseImage: 'wordpress',
|
||||||
|
images: ['bitnami/mysql:5.7'],
|
||||||
|
versions: ['latest', 'php8.1', 'php8.0', 'php7.4', 'php7.3'],
|
||||||
|
recommendedVersion: 'latest',
|
||||||
|
ports: {
|
||||||
|
main: 80
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'vaultwarden',
|
||||||
|
fancyName: 'Vaultwarden',
|
||||||
|
baseImage: 'vaultwarden/server',
|
||||||
|
versions: ['latest'],
|
||||||
|
recommendedVersion: 'latest',
|
||||||
|
ports: {
|
||||||
|
main: 80
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'languagetool',
|
||||||
|
fancyName: 'LanguageTool',
|
||||||
|
baseImage: 'silviof/docker-languagetool',
|
||||||
|
versions: ['latest'],
|
||||||
|
recommendedVersion: 'latest',
|
||||||
|
ports: {
|
||||||
|
main: 8010
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'n8n',
|
||||||
|
fancyName: 'n8n',
|
||||||
|
baseImage: 'n8nio/n8n',
|
||||||
|
versions: ['latest'],
|
||||||
|
recommendedVersion: 'latest',
|
||||||
|
ports: {
|
||||||
|
main: 5678
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'uptimekuma',
|
||||||
|
fancyName: 'Uptime Kuma',
|
||||||
|
baseImage: 'louislam/uptime-kuma',
|
||||||
|
versions: ['latest'],
|
||||||
|
recommendedVersion: 'latest',
|
||||||
|
ports: {
|
||||||
|
main: 3001
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ghost',
|
||||||
|
fancyName: 'Ghost',
|
||||||
|
baseImage: 'bitnami/ghost',
|
||||||
|
images: ['bitnami/mariadb'],
|
||||||
|
versions: ['latest'],
|
||||||
|
recommendedVersion: 'latest',
|
||||||
|
ports: {
|
||||||
|
main: 2368
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'meilisearch',
|
||||||
|
fancyName: 'Meilisearch',
|
||||||
|
baseImage: 'getmeili/meilisearch',
|
||||||
|
images: [],
|
||||||
|
versions: ['latest'],
|
||||||
|
recommendedVersion: 'latest',
|
||||||
|
ports: {
|
||||||
|
main: 7700
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'umami',
|
||||||
|
fancyName: 'Umami',
|
||||||
|
baseImage: 'ghcr.io/mikecao/umami',
|
||||||
|
images: ['postgres:12-alpine'],
|
||||||
|
versions: ['postgresql-latest'],
|
||||||
|
recommendedVersion: 'postgresql-latest',
|
||||||
|
ports: {
|
||||||
|
main: 3000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'hasura',
|
||||||
|
fancyName: 'Hasura',
|
||||||
|
baseImage: 'hasura/graphql-engine',
|
||||||
|
images: ['postgres:12-alpine'],
|
||||||
|
versions: ['latest', 'v2.10.0', 'v2.5.1'],
|
||||||
|
recommendedVersion: 'v2.10.0',
|
||||||
|
ports: {
|
||||||
|
main: 8080
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'fider',
|
||||||
|
fancyName: 'Fider',
|
||||||
|
baseImage: 'getfider/fider',
|
||||||
|
images: ['postgres:12-alpine'],
|
||||||
|
versions: ['stable'],
|
||||||
|
recommendedVersion: 'stable',
|
||||||
|
ports: {
|
||||||
|
main: 3000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'appwrite',
|
||||||
|
fancyName: 'Appwrite',
|
||||||
|
baseImage: 'appwrite/appwrite',
|
||||||
|
images: ['mariadb:10.7', 'redis:6.2-alpine', 'appwrite/telegraf:1.4.0'],
|
||||||
|
versions: ['latest', '0.15.3'],
|
||||||
|
recommendedVersion: '0.15.3',
|
||||||
|
ports: {
|
||||||
|
main: 80
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// name: 'moodle',
|
||||||
|
// fancyName: 'Moodle',
|
||||||
|
// baseImage: 'bitnami/moodle',
|
||||||
|
// images: [],
|
||||||
|
// versions: ['latest', 'v4.0.2'],
|
||||||
|
// recommendedVersion: 'latest',
|
||||||
|
// ports: {
|
||||||
|
// main: 8080
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
{
|
||||||
|
name: 'glitchTip',
|
||||||
|
fancyName: 'GlitchTip',
|
||||||
|
baseImage: 'glitchtip/glitchtip',
|
||||||
|
images: ['postgres:14-alpine', 'redis:7-alpine'],
|
||||||
|
versions: ['latest'],
|
||||||
|
recommendedVersion: 'latest',
|
||||||
|
ports: {
|
||||||
|
main: 8000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'searxng',
|
||||||
|
fancyName: 'SearXNG',
|
||||||
|
baseImage: 'searxng/searxng',
|
||||||
|
images: [],
|
||||||
|
versions: ['latest'],
|
||||||
|
recommendedVersion: 'latest',
|
||||||
|
ports: {
|
||||||
|
main: 8080
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'weblate',
|
||||||
|
fancyName: 'Weblate',
|
||||||
|
baseImage: 'weblate/weblate',
|
||||||
|
images: ['postgres:14-alpine', 'redis:6-alpine'],
|
||||||
|
versions: ['latest'],
|
||||||
|
recommendedVersion: 'latest',
|
||||||
|
ports: {
|
||||||
|
main: 8080
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// name: 'taiga',
|
||||||
|
// fancyName: 'Taiga',
|
||||||
|
// baseImage: 'taigaio/taiga-front',
|
||||||
|
// images: ['postgres:12.3', 'rabbitmq:3.8-management-alpine', 'taigaio/taiga-back', 'taigaio/taiga-events', 'taigaio/taiga-protected'],
|
||||||
|
// versions: ['latest'],
|
||||||
|
// recommendedVersion: 'latest',
|
||||||
|
// ports: {
|
||||||
|
// main: 80
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
];
|
||||||
@@ -21,7 +21,6 @@ export default fp<FastifyJWTOptions>(async (fastify, opts) => {
|
|||||||
try {
|
try {
|
||||||
await request.jwtVerify()
|
await request.jwtVerify()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
|
||||||
reply.send(err)
|
reply.send(err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,16 +3,23 @@ import crypto from 'node:crypto'
|
|||||||
import jsonwebtoken from 'jsonwebtoken';
|
import jsonwebtoken from 'jsonwebtoken';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { FastifyReply } from 'fastify';
|
import { FastifyReply } from 'fastify';
|
||||||
|
import fs from 'fs/promises';
|
||||||
|
import yaml from 'js-yaml';
|
||||||
|
|
||||||
import { day } from '../../../../lib/dayjs';
|
import { day } from '../../../../lib/dayjs';
|
||||||
import { setDefaultBaseImage, setDefaultConfiguration } from '../../../../lib/buildPacks/common';
|
import { makeLabelForStandaloneApplication, setDefaultBaseImage, setDefaultConfiguration } from '../../../../lib/buildPacks/common';
|
||||||
import { checkDomainsIsValidInDNS, checkDoubleBranch, checkExposedPort, decrypt, encrypt, errorHandler, executeDockerCmd, generateSshKeyPair, getContainerUsage, getDomain, getFreeExposedPort, isDev, isDomainConfigured, listSettings, prisma, stopBuild, uniqueName } from '../../../../lib/common';
|
import { checkDomainsIsValidInDNS, checkDoubleBranch, checkExposedPort, createDirectories, decrypt, defaultComposeConfiguration, encrypt, errorHandler, executeDockerCmd, generateSshKeyPair, getContainerUsage, getDomain, isDev, isDomainConfigured, listSettings, prisma, stopBuild, uniqueName } from '../../../../lib/common';
|
||||||
import { checkContainer, formatLabelsOnDocker, isContainerExited, removeContainer } from '../../../../lib/docker';
|
import { checkContainer, formatLabelsOnDocker, isContainerExited, removeContainer } from '../../../../lib/docker';
|
||||||
import { scheduler } from '../../../../lib/scheduler';
|
|
||||||
|
|
||||||
import type { FastifyRequest } from 'fastify';
|
import type { FastifyRequest } from 'fastify';
|
||||||
import type { GetImages, CancelDeployment, CheckDNS, CheckRepository, DeleteApplication, DeleteSecret, DeleteStorage, GetApplicationLogs, GetBuildIdLogs, GetBuildLogs, SaveApplication, SaveApplicationSettings, SaveApplicationSource, SaveDeployKey, SaveDestination, SaveSecret, SaveStorage, DeployApplication, CheckDomain, StopPreviewApplication } from './types';
|
import type { GetImages, CancelDeployment, CheckDNS, CheckRepository, DeleteApplication, DeleteSecret, DeleteStorage, GetApplicationLogs, GetBuildIdLogs, GetBuildLogs, SaveApplication, SaveApplicationSettings, SaveApplicationSource, SaveDeployKey, SaveDestination, SaveSecret, SaveStorage, DeployApplication, CheckDomain, StopPreviewApplication } from './types';
|
||||||
import { OnlyId } from '../../../../types';
|
import { OnlyId } from '../../../../types';
|
||||||
|
|
||||||
|
function filterObject(obj, callback) {
|
||||||
|
return Object.fromEntries(Object.entries(obj).
|
||||||
|
filter(([key, val]) => callback(val, key)));
|
||||||
|
}
|
||||||
|
|
||||||
export async function listApplications(request: FastifyRequest) {
|
export async function listApplications(request: FastifyRequest) {
|
||||||
try {
|
try {
|
||||||
const { teamId } = request.user
|
const { teamId } = request.user
|
||||||
@@ -34,7 +41,7 @@ export async function getImages(request: FastifyRequest<GetImages>) {
|
|||||||
const { buildPack, deploymentType } = request.body
|
const { buildPack, deploymentType } = request.body
|
||||||
let publishDirectory = undefined;
|
let publishDirectory = undefined;
|
||||||
let port = undefined
|
let port = undefined
|
||||||
const { baseImage, baseBuildImage, baseBuildImages, baseImages, } = setDefaultBaseImage(
|
const { baseImage, baseBuildImage, baseBuildImages, baseImages } = setDefaultBaseImage(
|
||||||
buildPack, deploymentType
|
buildPack, deploymentType
|
||||||
);
|
);
|
||||||
if (buildPack === 'nextjs') {
|
if (buildPack === 'nextjs') {
|
||||||
@@ -56,8 +63,7 @@ export async function getImages(request: FastifyRequest<GetImages>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return { baseImage, baseImages, baseBuildImage, baseBuildImages, publishDirectory, port }
|
||||||
return { baseBuildImage, baseBuildImages, publishDirectory, port }
|
|
||||||
} catch ({ status, message }) {
|
} catch ({ status, message }) {
|
||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
}
|
}
|
||||||
@@ -75,7 +81,6 @@ export async function getApplicationStatus(request: FastifyRequest<OnlyId>) {
|
|||||||
isExited = await isContainerExited(application.destinationDocker.id, id);
|
isExited = await isContainerExited(application.destinationDocker.id, id);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
isQueueActive: scheduler.workers.has('deployApplication'),
|
|
||||||
isRunning,
|
isRunning,
|
||||||
isExited,
|
isExited,
|
||||||
};
|
};
|
||||||
@@ -151,7 +156,8 @@ export async function getApplicationFromDB(id: string, teamId: string) {
|
|||||||
settings: true,
|
settings: true,
|
||||||
gitSource: { include: { githubApp: true, gitlabApp: true } },
|
gitSource: { include: { githubApp: true, gitlabApp: true } },
|
||||||
secrets: true,
|
secrets: true,
|
||||||
persistentStorage: true
|
persistentStorage: true,
|
||||||
|
connectedDatabase: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!application) {
|
if (!application) {
|
||||||
@@ -178,32 +184,39 @@ export async function getApplicationFromDB(id: string, teamId: string) {
|
|||||||
}
|
}
|
||||||
export async function getApplicationFromDBWebhook(projectId: number, branch: string) {
|
export async function getApplicationFromDBWebhook(projectId: number, branch: string) {
|
||||||
try {
|
try {
|
||||||
let application = await prisma.application.findFirst({
|
let applications = await prisma.application.findMany({
|
||||||
where: { projectId, branch, settings: { autodeploy: true } },
|
where: { projectId, branch, settings: { autodeploy: true } },
|
||||||
include: {
|
include: {
|
||||||
destinationDocker: true,
|
destinationDocker: true,
|
||||||
settings: true,
|
settings: true,
|
||||||
gitSource: { include: { githubApp: true, gitlabApp: true } },
|
gitSource: { include: { githubApp: true, gitlabApp: true } },
|
||||||
secrets: true,
|
secrets: true,
|
||||||
persistentStorage: true
|
persistentStorage: true,
|
||||||
|
connectedDatabase: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!application) {
|
if (applications.length === 0) {
|
||||||
throw { status: 500, message: 'Application not configured.' }
|
throw { status: 500, message: 'Application not configured.' }
|
||||||
}
|
}
|
||||||
application = decryptApplication(application);
|
applications = applications.map((application: any) => {
|
||||||
const { baseImage, baseBuildImage, baseBuildImages, baseImages } = setDefaultBaseImage(
|
application = decryptApplication(application);
|
||||||
application.buildPack
|
const { baseImage, baseBuildImage, baseBuildImages, baseImages } = setDefaultBaseImage(
|
||||||
);
|
application.buildPack
|
||||||
|
);
|
||||||
|
|
||||||
// Set default build images
|
// Set default build images
|
||||||
if (!application.baseImage) {
|
if (!application.baseImage) {
|
||||||
application.baseImage = baseImage;
|
application.baseImage = baseImage;
|
||||||
}
|
}
|
||||||
if (!application.baseBuildImage) {
|
if (!application.baseBuildImage) {
|
||||||
application.baseBuildImage = baseBuildImage;
|
application.baseBuildImage = baseBuildImage;
|
||||||
}
|
}
|
||||||
return { ...application, baseBuildImages, baseImages };
|
application.baseBuildImages = baseBuildImages;
|
||||||
|
application.baseImages = baseImages;
|
||||||
|
return application
|
||||||
|
})
|
||||||
|
|
||||||
|
return applications;
|
||||||
|
|
||||||
} catch ({ status, message }) {
|
} catch ({ status, message }) {
|
||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
@@ -231,16 +244,16 @@ export async function saveApplication(request: FastifyRequest<SaveApplication>,
|
|||||||
denoOptions,
|
denoOptions,
|
||||||
baseImage,
|
baseImage,
|
||||||
baseBuildImage,
|
baseBuildImage,
|
||||||
deploymentType
|
deploymentType,
|
||||||
|
baseDatabaseBranch
|
||||||
} = request.body
|
} = request.body
|
||||||
|
|
||||||
if (port) port = Number(port);
|
if (port) port = Number(port);
|
||||||
if (exposePort) {
|
if (exposePort) {
|
||||||
exposePort = Number(exposePort);
|
exposePort = Number(exposePort);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { destinationDockerId } = await prisma.application.findUnique({ where: { id } })
|
const { destinationDocker: { id: dockerId, remoteIpAddress }, exposePort: configuredPort } = await prisma.application.findUnique({ where: { id }, include: { destinationDocker: true } })
|
||||||
if (exposePort) await checkExposedPort({ id, exposePort, dockerId: destinationDockerId })
|
if (exposePort) await checkExposedPort({ id, configuredPort, exposePort, dockerId, remoteIpAddress })
|
||||||
if (denoOptions) denoOptions = denoOptions.trim();
|
if (denoOptions) denoOptions = denoOptions.trim();
|
||||||
const defaultConfiguration = await setDefaultConfiguration({
|
const defaultConfiguration = await setDefaultConfiguration({
|
||||||
buildPack,
|
buildPack,
|
||||||
@@ -253,22 +266,43 @@ export async function saveApplication(request: FastifyRequest<SaveApplication>,
|
|||||||
dockerFileLocation,
|
dockerFileLocation,
|
||||||
denoMainFile
|
denoMainFile
|
||||||
});
|
});
|
||||||
await prisma.application.update({
|
if (baseDatabaseBranch) {
|
||||||
where: { id },
|
await prisma.application.update({
|
||||||
data: {
|
where: { id },
|
||||||
name,
|
data: {
|
||||||
fqdn,
|
name,
|
||||||
exposePort,
|
fqdn,
|
||||||
pythonWSGI,
|
exposePort,
|
||||||
pythonModule,
|
pythonWSGI,
|
||||||
pythonVariable,
|
pythonModule,
|
||||||
denoOptions,
|
pythonVariable,
|
||||||
baseImage,
|
denoOptions,
|
||||||
baseBuildImage,
|
baseImage,
|
||||||
deploymentType,
|
baseBuildImage,
|
||||||
...defaultConfiguration
|
deploymentType,
|
||||||
}
|
...defaultConfiguration,
|
||||||
});
|
connectedDatabase: { update: { hostedDatabaseDBName: baseDatabaseBranch } }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await prisma.application.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
name,
|
||||||
|
fqdn,
|
||||||
|
exposePort,
|
||||||
|
pythonWSGI,
|
||||||
|
pythonModule,
|
||||||
|
pythonVariable,
|
||||||
|
denoOptions,
|
||||||
|
baseImage,
|
||||||
|
baseBuildImage,
|
||||||
|
deploymentType,
|
||||||
|
...defaultConfiguration
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return reply.code(201).send();
|
return reply.code(201).send();
|
||||||
} catch ({ status, message }) {
|
} catch ({ status, message }) {
|
||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
@@ -279,15 +313,15 @@ export async function saveApplication(request: FastifyRequest<SaveApplication>,
|
|||||||
export async function saveApplicationSettings(request: FastifyRequest<SaveApplicationSettings>, reply: FastifyReply) {
|
export async function saveApplicationSettings(request: FastifyRequest<SaveApplicationSettings>, reply: FastifyReply) {
|
||||||
try {
|
try {
|
||||||
const { id } = request.params
|
const { id } = request.params
|
||||||
const { debug, previews, dualCerts, autodeploy, branch, projectId, isBot } = request.body
|
const { debug, previews, dualCerts, autodeploy, branch, projectId, isBot, isDBBranching } = request.body
|
||||||
const isDouble = await checkDoubleBranch(branch, projectId);
|
// const isDouble = await checkDoubleBranch(branch, projectId);
|
||||||
if (isDouble && autodeploy) {
|
// if (isDouble && autodeploy) {
|
||||||
await prisma.applicationSettings.updateMany({ where: { application: { branch, projectId } }, data: { autodeploy: false } })
|
// await prisma.applicationSettings.updateMany({ where: { application: { branch, projectId } }, data: { autodeploy: false } })
|
||||||
throw { status: 500, message: 'Cannot activate automatic deployments until only one application is defined for this repository / branch.' }
|
// throw { status: 500, message: 'Cannot activate automatic deployments until only one application is defined for this repository / branch.' }
|
||||||
}
|
// }
|
||||||
await prisma.application.update({
|
await prisma.application.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
data: { fqdn: isBot ? null : undefined, settings: { update: { debug, previews, dualCerts, autodeploy, isBot } } },
|
data: { fqdn: isBot ? null : undefined, settings: { update: { debug, previews, dualCerts, autodeploy, isBot, isDBBranching } } },
|
||||||
include: { destinationDocker: true }
|
include: { destinationDocker: true }
|
||||||
});
|
});
|
||||||
return reply.code(201).send();
|
return reply.code(201).send();
|
||||||
@@ -315,6 +349,113 @@ export async function stopPreviewApplication(request: FastifyRequest<StopPreview
|
|||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function restartApplication(request: FastifyRequest<OnlyId>, reply: FastifyReply) {
|
||||||
|
try {
|
||||||
|
const { id } = request.params
|
||||||
|
const { teamId } = request.user
|
||||||
|
let application: any = await getApplicationFromDB(id, teamId);
|
||||||
|
if (application?.destinationDockerId) {
|
||||||
|
const buildId = cuid();
|
||||||
|
const { id: dockerId, network } = application.destinationDocker;
|
||||||
|
const { secrets, pullmergeRequestId, port, repository, persistentStorage, id: applicationId, buildPack, exposePort } = application;
|
||||||
|
|
||||||
|
const envs = [
|
||||||
|
`PORT=${port}`
|
||||||
|
];
|
||||||
|
if (secrets.length > 0) {
|
||||||
|
secrets.forEach((secret) => {
|
||||||
|
if (pullmergeRequestId) {
|
||||||
|
if (secret.isPRMRSecret) {
|
||||||
|
envs.push(`${secret.name}=${secret.value}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!secret.isPRMRSecret) {
|
||||||
|
envs.push(`${secret.name}=${secret.value}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const { workdir } = await createDirectories({ repository, buildId });
|
||||||
|
const labels = []
|
||||||
|
let image = null
|
||||||
|
const { stdout: container } = await executeDockerCmd({ dockerId, command: `docker container ls --filter 'label=com.docker.compose.service=${id}' --format '{{json .}}'` })
|
||||||
|
const containersArray = container.trim().split('\n');
|
||||||
|
for (const container of containersArray) {
|
||||||
|
const containerObj = formatLabelsOnDocker(container);
|
||||||
|
image = containerObj[0].Image
|
||||||
|
Object.keys(containerObj[0].Labels).forEach(function (key) {
|
||||||
|
if (key.startsWith('coolify')) {
|
||||||
|
labels.push(`${key}=${containerObj[0].Labels[key]}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
let imageFound = false;
|
||||||
|
try {
|
||||||
|
await executeDockerCmd({
|
||||||
|
dockerId,
|
||||||
|
command: `docker image inspect ${image}`
|
||||||
|
})
|
||||||
|
imageFound = true;
|
||||||
|
} catch (error) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
if (!imageFound) {
|
||||||
|
throw { status: 500, message: 'Image not found, cannot restart application.' }
|
||||||
|
}
|
||||||
|
await fs.writeFile(`${workdir}/.env`, envs.join('\n'));
|
||||||
|
|
||||||
|
let envFound = false;
|
||||||
|
try {
|
||||||
|
envFound = !!(await fs.stat(`${workdir}/.env`));
|
||||||
|
} catch (error) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
const volumes =
|
||||||
|
persistentStorage?.map((storage) => {
|
||||||
|
return `${applicationId}${storage.path.replace(/\//gi, '-')}:${buildPack !== 'docker' ? '/app' : ''
|
||||||
|
}${storage.path}`;
|
||||||
|
}) || [];
|
||||||
|
const composeVolumes = volumes.map((volume) => {
|
||||||
|
return {
|
||||||
|
[`${volume.split(':')[0]}`]: {
|
||||||
|
name: volume.split(':')[0]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const composeFile = {
|
||||||
|
version: '3.8',
|
||||||
|
services: {
|
||||||
|
[applicationId]: {
|
||||||
|
image,
|
||||||
|
container_name: applicationId,
|
||||||
|
volumes,
|
||||||
|
env_file: envFound ? [`${workdir}/.env`] : [],
|
||||||
|
labels,
|
||||||
|
depends_on: [],
|
||||||
|
expose: [port],
|
||||||
|
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
|
||||||
|
...defaultComposeConfiguration(network),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
networks: {
|
||||||
|
[network]: {
|
||||||
|
external: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
volumes: Object.assign({}, ...composeVolumes)
|
||||||
|
};
|
||||||
|
await fs.writeFile(`${workdir}/docker-compose.yml`, yaml.dump(composeFile));
|
||||||
|
await executeDockerCmd({ dockerId, command: `docker stop -t 0 ${id}` })
|
||||||
|
await executeDockerCmd({ dockerId, command: `docker rm ${id}` })
|
||||||
|
await executeDockerCmd({ dockerId, command: `docker compose --project-directory ${workdir} up -d` })
|
||||||
|
return reply.code(201).send();
|
||||||
|
}
|
||||||
|
throw { status: 500, message: 'Application cannot be restarted.' }
|
||||||
|
} catch ({ status, message }) {
|
||||||
|
return errorHandler({ status, message })
|
||||||
|
}
|
||||||
|
}
|
||||||
export async function stopApplication(request: FastifyRequest<OnlyId>, reply: FastifyReply) {
|
export async function stopApplication(request: FastifyRequest<OnlyId>, reply: FastifyReply) {
|
||||||
try {
|
try {
|
||||||
const { id } = request.params
|
const { id } = request.params
|
||||||
@@ -335,12 +476,14 @@ export async function stopApplication(request: FastifyRequest<OnlyId>, reply: Fa
|
|||||||
export async function deleteApplication(request: FastifyRequest<DeleteApplication>, reply: FastifyReply) {
|
export async function deleteApplication(request: FastifyRequest<DeleteApplication>, reply: FastifyReply) {
|
||||||
try {
|
try {
|
||||||
const { id } = request.params
|
const { id } = request.params
|
||||||
|
const { force } = request.body
|
||||||
|
|
||||||
const { teamId } = request.user
|
const { teamId } = request.user
|
||||||
const application = await prisma.application.findUnique({
|
const application = await prisma.application.findUnique({
|
||||||
where: { id },
|
where: { id },
|
||||||
include: { destinationDocker: true }
|
include: { destinationDocker: true }
|
||||||
});
|
});
|
||||||
if (application?.destinationDockerId && application.destinationDocker?.network) {
|
if (!force && application?.destinationDockerId && application.destinationDocker?.network) {
|
||||||
const { stdout: containers } = await executeDockerCmd({
|
const { stdout: containers } = await executeDockerCmd({
|
||||||
dockerId: application.destinationDocker.id,
|
dockerId: application.destinationDocker.id,
|
||||||
command: `docker ps -a --filter network=${application.destinationDocker.network} --filter name=${id} --format '{{json .}}'`
|
command: `docker ps -a --filter network=${application.destinationDocker.network} --filter name=${id} --format '{{json .}}'`
|
||||||
@@ -359,6 +502,7 @@ export async function deleteApplication(request: FastifyRequest<DeleteApplicatio
|
|||||||
await prisma.build.deleteMany({ where: { applicationId: id } });
|
await prisma.build.deleteMany({ where: { applicationId: id } });
|
||||||
await prisma.secret.deleteMany({ where: { applicationId: id } });
|
await prisma.secret.deleteMany({ where: { applicationId: id } });
|
||||||
await prisma.applicationPersistentStorage.deleteMany({ where: { applicationId: id } });
|
await prisma.applicationPersistentStorage.deleteMany({ where: { applicationId: id } });
|
||||||
|
await prisma.applicationConnectedDatabase.deleteMany({ where: { applicationId: id } });
|
||||||
if (teamId === '0') {
|
if (teamId === '0') {
|
||||||
await prisma.application.deleteMany({ where: { id } });
|
await prisma.application.deleteMany({ where: { id } });
|
||||||
} else {
|
} else {
|
||||||
@@ -381,11 +525,15 @@ export async function checkDomain(request: FastifyRequest<CheckDomain>) {
|
|||||||
}
|
}
|
||||||
export async function checkDNS(request: FastifyRequest<CheckDNS>) {
|
export async function checkDNS(request: FastifyRequest<CheckDNS>) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const { id } = request.params
|
const { id } = request.params
|
||||||
|
|
||||||
let { exposePort, fqdn, forceSave, dualCerts } = request.body
|
let { exposePort, fqdn, forceSave, dualCerts } = request.body
|
||||||
|
if (!fqdn) {
|
||||||
if (fqdn) fqdn = fqdn.toLowerCase();
|
return {}
|
||||||
|
} else {
|
||||||
|
fqdn = fqdn.toLowerCase();
|
||||||
|
}
|
||||||
if (exposePort) exposePort = Number(exposePort);
|
if (exposePort) exposePort = Number(exposePort);
|
||||||
|
|
||||||
const { destinationDocker: { id: dockerId, remoteIpAddress, remoteEngine }, exposePort: configuredPort } = await prisma.application.findUnique({ where: { id }, include: { destinationDocker: true } })
|
const { destinationDocker: { id: dockerId, remoteIpAddress, remoteEngine }, exposePort: configuredPort } = await prisma.application.findUnique({ where: { id }, include: { destinationDocker: true } })
|
||||||
@@ -452,7 +600,10 @@ export async function deployApplication(request: FastifyRequest<DeployApplicatio
|
|||||||
data: {
|
data: {
|
||||||
id: buildId,
|
id: buildId,
|
||||||
applicationId: id,
|
applicationId: id,
|
||||||
|
sourceBranch: branch,
|
||||||
branch: application.branch,
|
branch: application.branch,
|
||||||
|
pullmergeRequestId: pullmergeRequestId?.toString(),
|
||||||
|
forceRebuild,
|
||||||
destinationDockerId: application.destinationDocker?.id,
|
destinationDockerId: application.destinationDocker?.id,
|
||||||
gitSourceId: application.gitSource?.id,
|
gitSourceId: application.gitSource?.id,
|
||||||
githubAppId: application.gitSource?.githubApp?.id,
|
githubAppId: application.gitSource?.githubApp?.id,
|
||||||
@@ -461,24 +612,6 @@ export async function deployApplication(request: FastifyRequest<DeployApplicatio
|
|||||||
type: 'manual'
|
type: 'manual'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (pullmergeRequestId) {
|
|
||||||
scheduler.workers.get('deployApplication').postMessage({
|
|
||||||
build_id: buildId,
|
|
||||||
type: 'manual',
|
|
||||||
...application,
|
|
||||||
sourceBranch: branch,
|
|
||||||
pullmergeRequestId,
|
|
||||||
forceRebuild
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
scheduler.workers.get('deployApplication').postMessage({
|
|
||||||
build_id: buildId,
|
|
||||||
type: 'manual',
|
|
||||||
...application,
|
|
||||||
forceRebuild
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
buildId
|
buildId
|
||||||
};
|
};
|
||||||
@@ -576,12 +709,12 @@ export async function saveRepository(request, reply) {
|
|||||||
data: { repository, branch, projectId, settings: { update: { autodeploy, isPublicRepository } } }
|
data: { repository, branch, projectId, settings: { update: { autodeploy, isPublicRepository } } }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!isPublicRepository) {
|
// if (!isPublicRepository) {
|
||||||
const isDouble = await checkDoubleBranch(branch, projectId);
|
// const isDouble = await checkDoubleBranch(branch, projectId);
|
||||||
if (isDouble) {
|
// if (isDouble) {
|
||||||
await prisma.applicationSettings.updateMany({ where: { application: { branch, projectId } }, data: { autodeploy: false, isPublicRepository } })
|
// await prisma.applicationSettings.updateMany({ where: { application: { branch, projectId } }, data: { autodeploy: false, isPublicRepository } })
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return reply.code(201).send()
|
return reply.code(201).send()
|
||||||
} catch ({ status, message }) {
|
} catch ({ status, message }) {
|
||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
@@ -630,6 +763,16 @@ export async function saveBuildPack(request, reply) {
|
|||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export async function saveConnectedDatabase(request, reply) {
|
||||||
|
try {
|
||||||
|
const { id } = request.params
|
||||||
|
const { databaseId, type } = request.body
|
||||||
|
await prisma.application.update({ where: { id }, data: { connectedDatabase: { upsert: { create: { database: { connect: { id: databaseId } }, hostedDatabaseType: type }, update: { database: { connect: { id: databaseId } }, hostedDatabaseType: type } } } } })
|
||||||
|
return reply.code(201).send()
|
||||||
|
} catch ({ status, message }) {
|
||||||
|
return errorHandler({ status, message })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function getSecrets(request: FastifyRequest<OnlyId>) {
|
export async function getSecrets(request: FastifyRequest<OnlyId>) {
|
||||||
try {
|
try {
|
||||||
@@ -786,7 +929,6 @@ export async function getPreviews(request: FastifyRequest<OnlyId>) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch ({ status, message }) {
|
} catch ({ status, message }) {
|
||||||
console.log({ status, message })
|
|
||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -879,8 +1021,13 @@ export async function getBuildIdLogs(request: FastifyRequest<GetBuildIdLogs>) {
|
|||||||
orderBy: { time: 'asc' }
|
orderBy: { time: 'asc' }
|
||||||
});
|
});
|
||||||
const data = await prisma.build.findFirst({ where: { id: buildId } });
|
const data = await prisma.build.findFirst({ where: { id: buildId } });
|
||||||
|
const createdAt = day(data.createdAt).utc();
|
||||||
return {
|
return {
|
||||||
logs,
|
logs: logs.map(log => {
|
||||||
|
log.time = Number(log.time)
|
||||||
|
return log
|
||||||
|
}),
|
||||||
|
took: day().diff(createdAt) / 1000,
|
||||||
status: data?.status || 'queued'
|
status: data?.status || 'queued'
|
||||||
}
|
}
|
||||||
} catch ({ status, message }) {
|
} catch ({ status, message }) {
|
||||||
@@ -955,4 +1102,59 @@ export async function cancelDeployment(request: FastifyRequest<CancelDeployment>
|
|||||||
} catch ({ status, message }) {
|
} catch ({ status, message }) {
|
||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export async function createdBranchDatabase(database: any, baseDatabaseBranch: string, pullmergeRequestId: string) {
|
||||||
|
try {
|
||||||
|
if (!baseDatabaseBranch) return
|
||||||
|
const { id, type, destinationDockerId, rootUser, rootUserPassword, dbUser } = database;
|
||||||
|
if (destinationDockerId) {
|
||||||
|
if (type === 'postgresql') {
|
||||||
|
const decryptedRootUserPassword = decrypt(rootUserPassword);
|
||||||
|
await executeDockerCmd({
|
||||||
|
dockerId: destinationDockerId,
|
||||||
|
command: `docker exec ${id} pg_dump -d "postgresql://postgres:${decryptedRootUserPassword}@${id}:5432/${baseDatabaseBranch}" --encoding=UTF8 --schema-only -f /tmp/${baseDatabaseBranch}.dump`
|
||||||
|
})
|
||||||
|
await executeDockerCmd({
|
||||||
|
dockerId: destinationDockerId,
|
||||||
|
command: `docker exec ${id} psql postgresql://postgres:${decryptedRootUserPassword}@${id}:5432 -c "CREATE DATABASE branch_${pullmergeRequestId}"`
|
||||||
|
})
|
||||||
|
await executeDockerCmd({
|
||||||
|
dockerId: destinationDockerId,
|
||||||
|
command: `docker exec ${id} psql -d "postgresql://postgres:${decryptedRootUserPassword}@${id}:5432/branch_${pullmergeRequestId}" -f /tmp/${baseDatabaseBranch}.dump`
|
||||||
|
})
|
||||||
|
await executeDockerCmd({
|
||||||
|
dockerId: destinationDockerId,
|
||||||
|
command: `docker exec ${id} psql postgresql://postgres:${decryptedRootUserPassword}@${id}:5432 -c "ALTER DATABASE branch_${pullmergeRequestId} OWNER TO ${dbUser}"`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch ({ status, message }) {
|
||||||
|
return errorHandler({ status, message })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export async function removeBranchDatabase(database: any, pullmergeRequestId: string) {
|
||||||
|
try {
|
||||||
|
const { id, type, destinationDockerId, rootUser, rootUserPassword } = database;
|
||||||
|
if (destinationDockerId) {
|
||||||
|
if (type === 'postgresql') {
|
||||||
|
const decryptedRootUserPassword = decrypt(rootUserPassword);
|
||||||
|
// Terminate all connections to the database
|
||||||
|
await executeDockerCmd({
|
||||||
|
dockerId: destinationDockerId,
|
||||||
|
command: `docker exec ${id} psql postgresql://postgres:${decryptedRootUserPassword}@${id}:5432 -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'branch_${pullmergeRequestId}' AND pid <> pg_backend_pid();"`
|
||||||
|
})
|
||||||
|
|
||||||
|
await executeDockerCmd({
|
||||||
|
dockerId: destinationDockerId,
|
||||||
|
command: `docker exec ${id} psql postgresql://postgres:${decryptedRootUserPassword}@${id}:5432 -c "DROP DATABASE branch_${pullmergeRequestId}"`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch ({ status, message }) {
|
||||||
|
return errorHandler({ status, message })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { FastifyPluginAsync } from 'fastify';
|
import { FastifyPluginAsync } from 'fastify';
|
||||||
import { OnlyId } from '../../../../types';
|
import { OnlyId } from '../../../../types';
|
||||||
import { cancelDeployment, checkDNS, checkDomain, checkRepository, deleteApplication, deleteSecret, deleteStorage, deployApplication, getApplication, getApplicationLogs, getApplicationStatus, getBuildIdLogs, getBuildLogs, getBuildPack, getGitHubToken, getGitLabSSHKey, getImages, getPreviews, getSecrets, getStorages, getUsage, listApplications, newApplication, saveApplication, saveApplicationSettings, saveApplicationSource, saveBuildPack, saveDeployKey, saveDestination, saveGitLabSSHKey, saveRepository, saveSecret, saveStorage, stopApplication, stopPreviewApplication } from './handlers';
|
import { cancelDeployment, checkDNS, checkDomain, checkRepository, deleteApplication, deleteSecret, deleteStorage, deployApplication, getApplication, getApplicationLogs, getApplicationStatus, getBuildIdLogs, getBuildLogs, getBuildPack, getGitHubToken, getGitLabSSHKey, getImages, getPreviews, getSecrets, getStorages, getUsage, listApplications, newApplication, restartApplication, saveApplication, saveApplicationSettings, saveApplicationSource, saveBuildPack, saveConnectedDatabase, saveDeployKey, saveDestination, saveGitLabSSHKey, saveRepository, saveSecret, saveStorage, stopApplication, stopPreviewApplication } from './handlers';
|
||||||
|
|
||||||
import type { CancelDeployment, CheckDNS, CheckDomain, CheckRepository, DeleteApplication, DeleteSecret, DeleteStorage, DeployApplication, GetApplicationLogs, GetBuildIdLogs, GetBuildLogs, GetImages, SaveApplication, SaveApplicationSettings, SaveApplicationSource, SaveDeployKey, SaveDestination, SaveSecret, SaveStorage, StopPreviewApplication } from './types';
|
import type { CancelDeployment, CheckDNS, CheckDomain, CheckRepository, DeleteApplication, DeleteSecret, DeleteStorage, DeployApplication, GetApplicationLogs, GetBuildIdLogs, GetBuildLogs, GetImages, SaveApplication, SaveApplicationSettings, SaveApplicationSource, SaveDeployKey, SaveDestination, SaveSecret, SaveStorage, StopPreviewApplication } from './types';
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@ const root: FastifyPluginAsync = async (fastify): Promise<void> => {
|
|||||||
|
|
||||||
fastify.get<OnlyId>('/:id/status', async (request) => await getApplicationStatus(request));
|
fastify.get<OnlyId>('/:id/status', async (request) => await getApplicationStatus(request));
|
||||||
|
|
||||||
|
fastify.post<OnlyId>('/:id/restart', async (request, reply) => await restartApplication(request, reply));
|
||||||
fastify.post<OnlyId>('/:id/stop', async (request, reply) => await stopApplication(request, reply));
|
fastify.post<OnlyId>('/:id/stop', async (request, reply) => await stopApplication(request, reply));
|
||||||
fastify.post<StopPreviewApplication>('/:id/stop/preview', async (request, reply) => await stopPreviewApplication(request, reply));
|
fastify.post<StopPreviewApplication>('/:id/stop/preview', async (request, reply) => await stopPreviewApplication(request, reply));
|
||||||
|
|
||||||
@@ -54,6 +55,8 @@ const root: FastifyPluginAsync = async (fastify): Promise<void> => {
|
|||||||
fastify.get('/:id/configuration/buildpack', async (request) => await getBuildPack(request));
|
fastify.get('/:id/configuration/buildpack', async (request) => await getBuildPack(request));
|
||||||
fastify.post('/:id/configuration/buildpack', async (request, reply) => await saveBuildPack(request, reply));
|
fastify.post('/:id/configuration/buildpack', async (request, reply) => await saveBuildPack(request, reply));
|
||||||
|
|
||||||
|
fastify.post('/:id/configuration/database', async (request, reply) => await saveConnectedDatabase(request, reply));
|
||||||
|
|
||||||
fastify.get<OnlyId>('/:id/configuration/sshkey', async (request) => await getGitLabSSHKey(request));
|
fastify.get<OnlyId>('/:id/configuration/sshkey', async (request) => await getGitLabSSHKey(request));
|
||||||
fastify.post<OnlyId>('/:id/configuration/sshkey', async (request, reply) => await saveGitLabSSHKey(request, reply));
|
fastify.post<OnlyId>('/:id/configuration/sshkey', async (request, reply) => await saveGitLabSSHKey(request, reply));
|
||||||
|
|
||||||
|
|||||||
@@ -20,15 +20,17 @@ export interface SaveApplication extends OnlyId {
|
|||||||
denoOptions: string,
|
denoOptions: string,
|
||||||
baseImage: string,
|
baseImage: string,
|
||||||
baseBuildImage: string,
|
baseBuildImage: string,
|
||||||
deploymentType: string
|
deploymentType: string,
|
||||||
|
baseDatabaseBranch: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export interface SaveApplicationSettings extends OnlyId {
|
export interface SaveApplicationSettings extends OnlyId {
|
||||||
Querystring: { domain: string; };
|
Querystring: { domain: string; };
|
||||||
Body: { debug: boolean; previews: boolean; dualCerts: boolean; autodeploy: boolean; branch: string; projectId: number; isBot: boolean; };
|
Body: { debug: boolean; previews: boolean; dualCerts: boolean; autodeploy: boolean; branch: string; projectId: number; isBot: boolean; isDBBranching: boolean };
|
||||||
}
|
}
|
||||||
export interface DeleteApplication extends OnlyId {
|
export interface DeleteApplication extends OnlyId {
|
||||||
Querystring: { domain: string; };
|
Querystring: { domain: string; };
|
||||||
|
Body: { force: boolean }
|
||||||
}
|
}
|
||||||
export interface CheckDomain extends OnlyId {
|
export interface CheckDomain extends OnlyId {
|
||||||
Querystring: { domain: string; };
|
Querystring: { domain: string; };
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { ComposeFile, createDirectories, decrypt, encrypt, errorHandler, execute
|
|||||||
import { day } from '../../../../lib/dayjs';
|
import { day } from '../../../../lib/dayjs';
|
||||||
|
|
||||||
import { GetDatabaseLogs, OnlyId, SaveDatabase, SaveDatabaseDestination, SaveDatabaseSettings, SaveVersion } from '../../../../types';
|
import { GetDatabaseLogs, OnlyId, SaveDatabase, SaveDatabaseDestination, SaveDatabaseSettings, SaveVersion } from '../../../../types';
|
||||||
import { SaveDatabaseType } from './types';
|
import { DeleteDatabase, SaveDatabaseType } from './types';
|
||||||
|
|
||||||
export async function listDatabases(request: FastifyRequest) {
|
export async function listDatabases(request: FastifyRequest) {
|
||||||
try {
|
try {
|
||||||
@@ -29,9 +29,9 @@ export async function newDatabase(request: FastifyRequest, reply: FastifyReply)
|
|||||||
|
|
||||||
const name = uniqueName();
|
const name = uniqueName();
|
||||||
const dbUser = cuid();
|
const dbUser = cuid();
|
||||||
const dbUserPassword = encrypt(generatePassword());
|
const dbUserPassword = encrypt(generatePassword({}));
|
||||||
const rootUser = cuid();
|
const rootUser = cuid();
|
||||||
const rootUserPassword = encrypt(generatePassword());
|
const rootUserPassword = encrypt(generatePassword({}));
|
||||||
const defaultDatabase = cuid();
|
const defaultDatabase = cuid();
|
||||||
|
|
||||||
const { id } = await prisma.database.create({
|
const { id } = await prisma.database.create({
|
||||||
@@ -167,6 +167,7 @@ export async function saveDatabaseDestination(request: FastifyRequest<SaveDataba
|
|||||||
const { id } = request.params;
|
const { id } = request.params;
|
||||||
const { destinationId } = request.body;
|
const { destinationId } = request.body;
|
||||||
|
|
||||||
|
const { arch } = await listSettings();
|
||||||
await prisma.database.update({
|
await prisma.database.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
data: { destinationDocker: { connect: { id: destinationId } } }
|
data: { destinationDocker: { connect: { id: destinationId } } }
|
||||||
@@ -181,7 +182,7 @@ export async function saveDatabaseDestination(request: FastifyRequest<SaveDataba
|
|||||||
|
|
||||||
if (destinationDockerId) {
|
if (destinationDockerId) {
|
||||||
if (type && version) {
|
if (type && version) {
|
||||||
const baseImage = getDatabaseImage(type);
|
const baseImage = getDatabaseImage(type, arch);
|
||||||
executeDockerCmd({ dockerId, command: `docker pull ${baseImage}:${version}` })
|
executeDockerCmd({ dockerId, command: `docker pull ${baseImage}:${version}` })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -279,15 +280,12 @@ export async function startDatabase(request: FastifyRequest<OnlyId>) {
|
|||||||
await fs.writeFile(composeFileDestination, yaml.dump(composeFile));
|
await fs.writeFile(composeFileDestination, yaml.dump(composeFile));
|
||||||
try {
|
try {
|
||||||
await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker volume create ${volumeName}` })
|
await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker volume create ${volumeName}` })
|
||||||
} catch (error) {
|
} catch (error) { }
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker compose -f ${composeFileDestination} up -d` })
|
await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker compose -f ${composeFileDestination} up -d` })
|
||||||
if (isPublic) await startTraefikTCPProxy(destinationDocker, id, publicPort, privatePort);
|
if (isPublic) await startTraefikTCPProxy(destinationDocker, id, publicPort, privatePort);
|
||||||
return {};
|
return {};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
|
||||||
throw {
|
throw {
|
||||||
error
|
error
|
||||||
};
|
};
|
||||||
@@ -360,19 +358,22 @@ export async function getDatabaseLogs(request: FastifyRequest<GetDatabaseLogs>)
|
|||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export async function deleteDatabase(request: FastifyRequest<OnlyId>) {
|
export async function deleteDatabase(request: FastifyRequest<DeleteDatabase>) {
|
||||||
try {
|
try {
|
||||||
const teamId = request.user.teamId;
|
const teamId = request.user.teamId;
|
||||||
const { id } = request.params;
|
const { id } = request.params;
|
||||||
|
const { force } = request.body;
|
||||||
const database = await prisma.database.findFirst({
|
const database = await prisma.database.findFirst({
|
||||||
where: { id, teams: { some: { id: teamId === '0' ? undefined : teamId } } },
|
where: { id, teams: { some: { id: teamId === '0' ? undefined : teamId } } },
|
||||||
include: { destinationDocker: true, settings: true }
|
include: { destinationDocker: true, settings: true }
|
||||||
});
|
});
|
||||||
if (database.dbUserPassword) database.dbUserPassword = decrypt(database.dbUserPassword);
|
if (!force) {
|
||||||
if (database.rootUserPassword) database.rootUserPassword = decrypt(database.rootUserPassword);
|
if (database.dbUserPassword) database.dbUserPassword = decrypt(database.dbUserPassword);
|
||||||
if (database.destinationDockerId) {
|
if (database.rootUserPassword) database.rootUserPassword = decrypt(database.rootUserPassword);
|
||||||
const everStarted = await stopDatabaseContainer(database);
|
if (database.destinationDockerId) {
|
||||||
if (everStarted) await stopTcpHttpProxy(id, database.destinationDocker, database.publicPort);
|
const everStarted = await stopDatabaseContainer(database);
|
||||||
|
if (everStarted) await stopTcpHttpProxy(id, database.destinationDocker, database.publicPort);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await prisma.databaseSettings.deleteMany({ where: { databaseId: id } });
|
await prisma.databaseSettings.deleteMany({ where: { databaseId: id } });
|
||||||
await prisma.database.delete({ where: { id } });
|
await prisma.database.delete({ where: { id } });
|
||||||
@@ -433,9 +434,13 @@ export async function saveDatabaseSettings(request: FastifyRequest<SaveDatabaseS
|
|||||||
const { id } = request.params;
|
const { id } = request.params;
|
||||||
const { isPublic, appendOnly = true } = request.body;
|
const { isPublic, appendOnly = true } = request.body;
|
||||||
|
|
||||||
const { destinationDocker: { id: dockerId } } = await prisma.database.findUnique({ where: { id }, include: { destinationDocker: true } })
|
let publicPort = null
|
||||||
const publicPort = await getFreePublicPort(id, dockerId);
|
|
||||||
|
|
||||||
|
const { destinationDocker: { id: dockerId } } = await prisma.database.findUnique({ where: { id }, include: { destinationDocker: true } })
|
||||||
|
|
||||||
|
if (isPublic) {
|
||||||
|
publicPort = await getFreePublicPort(id, dockerId);
|
||||||
|
}
|
||||||
await prisma.database.update({
|
await prisma.database.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { FastifyPluginAsync } from 'fastify';
|
import { FastifyPluginAsync } from 'fastify';
|
||||||
import { deleteDatabase, getDatabase, getDatabaseLogs, getDatabaseStatus, getDatabaseTypes, getDatabaseUsage, getVersions, listDatabases, newDatabase, saveDatabase, saveDatabaseDestination, saveDatabaseSettings, saveDatabaseType, saveVersion, startDatabase, stopDatabase } from './handlers';
|
import { deleteDatabase, getDatabase, getDatabaseLogs, getDatabaseStatus, getDatabaseTypes, getDatabaseUsage, getVersions, listDatabases, newDatabase, saveDatabase, saveDatabaseDestination, saveDatabaseSettings, saveDatabaseType, saveVersion, startDatabase, stopDatabase } from './handlers';
|
||||||
|
|
||||||
import type { GetDatabaseLogs, OnlyId, SaveDatabase, SaveDatabaseDestination, SaveDatabaseSettings, SaveVersion } from '../../../../types';
|
import type { DeleteDatabase, GetDatabaseLogs, OnlyId, SaveDatabase, SaveDatabaseDestination, SaveDatabaseSettings, SaveVersion } from '../../../../types';
|
||||||
import type { SaveDatabaseType } from './types';
|
import type { SaveDatabaseType } from './types';
|
||||||
|
|
||||||
const root: FastifyPluginAsync = async (fastify): Promise<void> => {
|
const root: FastifyPluginAsync = async (fastify): Promise<void> => {
|
||||||
@@ -13,7 +13,7 @@ const root: FastifyPluginAsync = async (fastify): Promise<void> => {
|
|||||||
|
|
||||||
fastify.get<OnlyId>('/:id', async (request) => await getDatabase(request));
|
fastify.get<OnlyId>('/:id', async (request) => await getDatabase(request));
|
||||||
fastify.post<SaveDatabase>('/:id', async (request, reply) => await saveDatabase(request, reply));
|
fastify.post<SaveDatabase>('/:id', async (request, reply) => await saveDatabase(request, reply));
|
||||||
fastify.delete<OnlyId>('/:id', async (request) => await deleteDatabase(request));
|
fastify.delete<DeleteDatabase>('/:id', async (request) => await deleteDatabase(request));
|
||||||
|
|
||||||
fastify.get<OnlyId>('/:id/status', async (request) => await getDatabaseStatus(request));
|
fastify.get<OnlyId>('/:id/status', async (request) => await getDatabaseStatus(request));
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,7 @@ import type { OnlyId } from "../../../../types";
|
|||||||
|
|
||||||
export interface SaveDatabaseType extends OnlyId {
|
export interface SaveDatabaseType extends OnlyId {
|
||||||
Body: { type: string }
|
Body: { type: string }
|
||||||
|
}
|
||||||
|
export interface DeleteDatabase extends OnlyId {
|
||||||
|
Body: { force: string }
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,6 @@ export async function listDestinations(request: FastifyRequest<ListDestinations>
|
|||||||
destinations
|
destinations
|
||||||
}
|
}
|
||||||
} catch ({ status, message }) {
|
} catch ({ status, message }) {
|
||||||
console.log({ status, message })
|
|
||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,7 +113,6 @@ export async function newDestination(request: FastifyRequest<NewDestination>, re
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch ({ status, message }) {
|
} catch ({ status, message }) {
|
||||||
console.log({ status, message })
|
|
||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,7 +160,6 @@ export async function startProxy(request: FastifyRequest<Proxy>) {
|
|||||||
await startTraefikProxy(id);
|
await startTraefikProxy(id);
|
||||||
return {}
|
return {}
|
||||||
} catch ({ status, message }) {
|
} catch ({ status, message }) {
|
||||||
console.log({ status, message })
|
|
||||||
await stopTraefikProxy(id);
|
await stopTraefikProxy(id);
|
||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
}
|
}
|
||||||
@@ -205,23 +202,21 @@ export async function assignSSHKey(request: FastifyRequest) {
|
|||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export async function verifyRemoteDockerEngine(request: FastifyRequest, reply: FastifyReply) {
|
export async function verifyRemoteDockerEngine(request: FastifyRequest<OnlyId>, reply: FastifyReply) {
|
||||||
try {
|
try {
|
||||||
const { id } = request.params;
|
const { id } = request.params;
|
||||||
await createRemoteEngineConfiguration(id);
|
await createRemoteEngineConfiguration(id);
|
||||||
|
const { remoteIpAddress, remoteUser, network, isCoolifyProxyUsed } = await prisma.destinationDocker.findFirst({ where: { id } })
|
||||||
const { remoteIpAddress, remoteUser, network } = await prisma.destinationDocker.findFirst({ where: { id } })
|
|
||||||
const host = `ssh://${remoteUser}@${remoteIpAddress}`
|
const host = `ssh://${remoteUser}@${remoteIpAddress}`
|
||||||
const { stdout } = await asyncExecShell(`DOCKER_HOST=${host} docker network ls --filter 'name=${network}' --no-trunc --format "{{json .}}"`);
|
const { stdout } = await asyncExecShell(`DOCKER_HOST=${host} docker network ls --filter 'name=${network}' --no-trunc --format "{{json .}}"`);
|
||||||
|
|
||||||
if (!stdout) {
|
if (!stdout) {
|
||||||
await asyncExecShell(`DOCKER_HOST=${host} docker network create --attachable ${network}`);
|
await asyncExecShell(`DOCKER_HOST=${host} docker network create --attachable ${network}`);
|
||||||
}
|
}
|
||||||
const { stdout:coolifyNetwork } = await asyncExecShell(`DOCKER_HOST=${host} docker network ls --filter 'name=coolify-infra' --no-trunc --format "{{json .}}"`);
|
const { stdout: coolifyNetwork } = await asyncExecShell(`DOCKER_HOST=${host} docker network ls --filter 'name=coolify-infra' --no-trunc --format "{{json .}}"`);
|
||||||
|
|
||||||
if (!coolifyNetwork) {
|
if (!coolifyNetwork) {
|
||||||
await asyncExecShell(`DOCKER_HOST=${host} docker network create --attachable coolify-infra`);
|
await asyncExecShell(`DOCKER_HOST=${host} docker network create --attachable coolify-infra`);
|
||||||
}
|
}
|
||||||
|
if (isCoolifyProxyUsed) await startTraefikProxy(id);
|
||||||
await prisma.destinationDocker.update({ where: { id }, data: { remoteVerified: true } })
|
await prisma.destinationDocker.update({ where: { id }, data: { remoteVerified: true } })
|
||||||
return reply.code(201).send()
|
return reply.code(201).send()
|
||||||
|
|
||||||
@@ -234,7 +229,7 @@ export async function getDestinationStatus(request: FastifyRequest<OnlyId>) {
|
|||||||
try {
|
try {
|
||||||
const { id } = request.params
|
const { id } = request.params
|
||||||
const destination = await prisma.destinationDocker.findUnique({ where: { id } })
|
const destination = await prisma.destinationDocker.findUnique({ where: { id } })
|
||||||
const isRunning = await checkContainer({ dockerId: destination.id, container: 'coolify-proxy' })
|
const isRunning = await checkContainer({ dockerId: destination.id, container: 'coolify-proxy', remove: true })
|
||||||
return {
|
return {
|
||||||
isRunning
|
isRunning
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const root: FastifyPluginAsync = async (fastify): Promise<void> => {
|
|||||||
|
|
||||||
fastify.post('/:id/configuration/sshKey', async (request) => await assignSSHKey(request));
|
fastify.post('/:id/configuration/sshKey', async (request) => await assignSSHKey(request));
|
||||||
|
|
||||||
fastify.post('/:id/verify', async (request, reply) => await verifyRemoteDockerEngine(request, reply));
|
fastify.post<OnlyId>('/:id/verify', async (request, reply) => await verifyRemoteDockerEngine(request, reply));
|
||||||
};
|
};
|
||||||
|
|
||||||
export default root;
|
export default root;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import os from 'node:os';
|
import os from 'node:os';
|
||||||
import osu from 'node-os-utils';
|
import osu from 'node-os-utils';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import compare from 'compare-versions';
|
import { compareVersions } from 'compare-versions';
|
||||||
import cuid from 'cuid';
|
import cuid from 'cuid';
|
||||||
import bcrypt from 'bcryptjs';
|
import bcrypt from 'bcryptjs';
|
||||||
import { asyncExecShell, asyncSleep, cleanupDockerStorage, errorHandler, isDev, listSettings, prisma, uniqueName, version } from '../../../lib/common';
|
import { asyncExecShell, asyncSleep, cleanupDockerStorage, errorHandler, isDev, listSettings, prisma, uniqueName, version } from '../../../lib/common';
|
||||||
|
import { supportedServiceTypesAndVersions } from '../../../lib/services/supportedVersions';
|
||||||
import type { FastifyReply, FastifyRequest } from 'fastify';
|
import type { FastifyReply, FastifyRequest } from 'fastify';
|
||||||
import type { Login, Update } from '.';
|
import type { Login, Update } from '.';
|
||||||
import type { GetCurrentUser } from './types';
|
import type { GetCurrentUser } from './types';
|
||||||
@@ -32,7 +32,7 @@ export async function checkUpdate(request: FastifyRequest) {
|
|||||||
`https://get.coollabs.io/versions.json?appId=${process.env['COOLIFY_APP_ID']}&version=${currentVersion}`
|
`https://get.coollabs.io/versions.json?appId=${process.env['COOLIFY_APP_ID']}&version=${currentVersion}`
|
||||||
);
|
);
|
||||||
const latestVersion = versions['coolify'].main.version
|
const latestVersion = versions['coolify'].main.version
|
||||||
const isUpdateAvailable = compare(latestVersion, currentVersion);
|
const isUpdateAvailable = compareVersions(latestVersion, currentVersion);
|
||||||
if (isStaging) {
|
if (isStaging) {
|
||||||
return {
|
return {
|
||||||
isUpdateAvailable: true,
|
isUpdateAvailable: true,
|
||||||
@@ -65,7 +65,6 @@ export async function update(request: FastifyRequest<Update>) {
|
|||||||
);
|
);
|
||||||
return {};
|
return {};
|
||||||
} else {
|
} else {
|
||||||
console.log(latestVersion);
|
|
||||||
await asyncSleep(2000);
|
await asyncSleep(2000);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -73,6 +72,22 @@ export async function update(request: FastifyRequest<Update>) {
|
|||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export async function restartCoolify(request: FastifyRequest<any>) {
|
||||||
|
try {
|
||||||
|
const teamId = request.user.teamId;
|
||||||
|
if (teamId === '0') {
|
||||||
|
if (!isDev) {
|
||||||
|
asyncExecShell(`docker restart coolify`);
|
||||||
|
return {};
|
||||||
|
} else {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw { status: 500, message: 'You are not authorized to restart Coolify.' };
|
||||||
|
} catch ({ status, message }) {
|
||||||
|
return errorHandler({ status, message })
|
||||||
|
}
|
||||||
|
}
|
||||||
export async function showUsage() {
|
export async function showUsage() {
|
||||||
try {
|
try {
|
||||||
return {
|
return {
|
||||||
@@ -101,7 +116,8 @@ export async function showDashboard(request: FastifyRequest) {
|
|||||||
include: { settings: true }
|
include: { settings: true }
|
||||||
});
|
});
|
||||||
const databases = await prisma.database.findMany({
|
const databases = await prisma.database.findMany({
|
||||||
where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } }
|
where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } },
|
||||||
|
include: { settings: true }
|
||||||
});
|
});
|
||||||
const services = await prisma.service.findMany({
|
const services = await prisma.service.findMany({
|
||||||
where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } }
|
where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } }
|
||||||
@@ -282,6 +298,7 @@ export async function getCurrentUser(request: FastifyRequest<GetCurrentUser>, fa
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
settings: await prisma.setting.findFirst(),
|
settings: await prisma.setting.findFirst(),
|
||||||
|
supportedServiceTypesAndVersions,
|
||||||
token,
|
token,
|
||||||
...request.user
|
...request.user
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,8 +158,11 @@ export async function getTeam(request: FastifyRequest<OnlyId>, reply: FastifyRep
|
|||||||
});
|
});
|
||||||
const team = await prisma.team.findUnique({ where: { id }, include: { permissions: true } });
|
const team = await prisma.team.findUnique({ where: { id }, include: { permissions: true } });
|
||||||
const invitations = await prisma.teamInvitation.findMany({ where: { teamId: team.id } });
|
const invitations = await prisma.teamInvitation.findMany({ where: { teamId: team.id } });
|
||||||
|
const { teams } = await prisma.user.findUnique({ where: { id: userId }, include: { teams: true } })
|
||||||
return {
|
return {
|
||||||
|
currentTeam: teamId,
|
||||||
team,
|
team,
|
||||||
|
teams,
|
||||||
permissions,
|
permissions,
|
||||||
invitations
|
invitations
|
||||||
};
|
};
|
||||||
@@ -275,10 +278,10 @@ export async function inviteToTeam(request: FastifyRequest<InviteToTeam>, reply:
|
|||||||
if (!userFound) {
|
if (!userFound) {
|
||||||
throw {
|
throw {
|
||||||
message: `No user found with '${email}' email address.`
|
message: `No user found with '${email}' email address.`
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const uid = userFound.id;
|
const uid = userFound.id;
|
||||||
if (uid === userId) {
|
if (uid === userId) {
|
||||||
throw {
|
throw {
|
||||||
message: `Invitation to yourself? Whaaaaat?`
|
message: `Invitation to yourself? Whaaaaat?`
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { FastifyPluginAsync } from 'fastify';
|
import { FastifyPluginAsync } from 'fastify';
|
||||||
import { checkUpdate, login, showDashboard, update, showUsage, getCurrentUser, cleanupManually } from './handlers';
|
import { checkUpdate, login, showDashboard, update, showUsage, getCurrentUser, cleanupManually, restartCoolify } from './handlers';
|
||||||
import { GetCurrentUser } from './types';
|
import { GetCurrentUser } from './types';
|
||||||
|
|
||||||
export interface Update {
|
export interface Update {
|
||||||
@@ -47,6 +47,10 @@ const root: FastifyPluginAsync = async (fastify): Promise<void> => {
|
|||||||
onRequest: [fastify.authenticate]
|
onRequest: [fastify.authenticate]
|
||||||
}, async () => await showUsage());
|
}, async () => await showUsage());
|
||||||
|
|
||||||
|
fastify.post('/internal/restart', {
|
||||||
|
onRequest: [fastify.authenticate]
|
||||||
|
}, async (request) => await restartCoolify(request));
|
||||||
|
|
||||||
fastify.post('/internal/cleanup', {
|
fastify.post('/internal/cleanup', {
|
||||||
onRequest: [fastify.authenticate]
|
onRequest: [fastify.authenticate]
|
||||||
}, async () => await cleanupManually());
|
}, async () => await cleanupManually());
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -26,12 +26,11 @@ import {
|
|||||||
saveServiceType,
|
saveServiceType,
|
||||||
saveServiceVersion,
|
saveServiceVersion,
|
||||||
setSettingsService,
|
setSettingsService,
|
||||||
startService,
|
|
||||||
stopService
|
|
||||||
} from './handlers';
|
} from './handlers';
|
||||||
|
|
||||||
import type { OnlyId } from '../../../../types';
|
import type { OnlyId } from '../../../../types';
|
||||||
import type { ActivateWordpressFtp, CheckService, CheckServiceDomain, DeleteServiceSecret, DeleteServiceStorage, GetServiceLogs, SaveService, SaveServiceDestination, SaveServiceSecret, SaveServiceSettings, SaveServiceStorage, SaveServiceType, SaveServiceVersion, ServiceStartStop, SetWordpressSettings } from './types';
|
import type { ActivateWordpressFtp, CheckService, CheckServiceDomain, DeleteServiceSecret, DeleteServiceStorage, GetServiceLogs, SaveService, SaveServiceDestination, SaveServiceSecret, SaveServiceSettings, SaveServiceStorage, SaveServiceType, SaveServiceVersion, ServiceStartStop, SetGlitchTipSettings, SetWordpressSettings } from './types';
|
||||||
|
import { startService, stopService } from '../../../../lib/services/handlers';
|
||||||
|
|
||||||
const root: FastifyPluginAsync = async (fastify): Promise<void> => {
|
const root: FastifyPluginAsync = async (fastify): Promise<void> => {
|
||||||
fastify.addHook('onRequest', async (request) => {
|
fastify.addHook('onRequest', async (request) => {
|
||||||
@@ -72,7 +71,7 @@ const root: FastifyPluginAsync = async (fastify): Promise<void> => {
|
|||||||
|
|
||||||
fastify.post<ServiceStartStop>('/:id/:type/start', async (request) => await startService(request));
|
fastify.post<ServiceStartStop>('/:id/:type/start', async (request) => await startService(request));
|
||||||
fastify.post<ServiceStartStop>('/:id/:type/stop', async (request) => await stopService(request));
|
fastify.post<ServiceStartStop>('/:id/:type/stop', async (request) => await stopService(request));
|
||||||
fastify.post<ServiceStartStop & SetWordpressSettings>('/:id/:type/settings', async (request, reply) => await setSettingsService(request, reply));
|
fastify.post<ServiceStartStop & SetWordpressSettings & SetGlitchTipSettings>('/:id/:type/settings', async (request, reply) => await setSettingsService(request, reply));
|
||||||
|
|
||||||
fastify.post<OnlyId>('/:id/plausibleanalytics/activate', async (request, reply) => await activatePlausibleUsers(request, reply));
|
fastify.post<OnlyId>('/:id/plausibleanalytics/activate', async (request, reply) => await activatePlausibleUsers(request, reply));
|
||||||
fastify.post<OnlyId>('/:id/plausibleanalytics/cleanup', async (request, reply) => await cleanupPlausibleLogs(request, reply));
|
fastify.post<OnlyId>('/:id/plausibleanalytics/cleanup', async (request, reply) => await cleanupPlausibleLogs(request, reply));
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ export interface ActivateWordpressFtp extends OnlyId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SetGlitchTipSettings extends OnlyId {
|
||||||
|
Body: {
|
||||||
|
enableOpenUserRegistration: boolean,
|
||||||
|
emailSmtpUseSsl: boolean,
|
||||||
|
emailSmtpUseTls: boolean
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import cuid from "cuid";
|
|||||||
import crypto from "crypto";
|
import crypto from "crypto";
|
||||||
import { encrypt, errorHandler, getUIUrl, isDev, prisma } from "../../../lib/common";
|
import { encrypt, errorHandler, getUIUrl, isDev, prisma } from "../../../lib/common";
|
||||||
import { checkContainer, removeContainer } from "../../../lib/docker";
|
import { checkContainer, removeContainer } from "../../../lib/docker";
|
||||||
import { scheduler } from "../../../lib/scheduler";
|
import { createdBranchDatabase, getApplicationFromDBWebhook, removeBranchDatabase } from "../../api/v1/applications/handlers";
|
||||||
import { getApplicationFromDBWebhook } from "../../api/v1/applications/handlers";
|
|
||||||
|
|
||||||
import type { FastifyReply, FastifyRequest } from "fastify";
|
import type { FastifyReply, FastifyRequest } from "fastify";
|
||||||
import type { GitHubEvents, InstallGithub } from "./types";
|
import type { GitHubEvents, InstallGithub } from "./types";
|
||||||
@@ -67,7 +66,6 @@ export async function configureGitHubApp(request, reply) {
|
|||||||
}
|
}
|
||||||
export async function gitHubEvents(request: FastifyRequest<GitHubEvents>): Promise<any> {
|
export async function gitHubEvents(request: FastifyRequest<GitHubEvents>): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const buildId = cuid();
|
|
||||||
const allowedGithubEvents = ['push', 'pull_request'];
|
const allowedGithubEvents = ['push', 'pull_request'];
|
||||||
const allowedActions = ['opened', 'reopened', 'synchronize', 'closed'];
|
const allowedActions = ['opened', 'reopened', 'synchronize', 'closed'];
|
||||||
const githubEvent = request.headers['x-github-event']?.toString().toLowerCase();
|
const githubEvent = request.headers['x-github-event']?.toString().toLowerCase();
|
||||||
@@ -87,137 +85,139 @@ export async function gitHubEvents(request: FastifyRequest<GitHubEvents>): Promi
|
|||||||
if (!projectId || !branch) {
|
if (!projectId || !branch) {
|
||||||
throw { status: 500, message: 'Cannot parse projectId or branch from the webhook?!' }
|
throw { status: 500, message: 'Cannot parse projectId or branch from the webhook?!' }
|
||||||
}
|
}
|
||||||
const applicationFound = await getApplicationFromDBWebhook(projectId, branch);
|
const applicationsFound = await getApplicationFromDBWebhook(projectId, branch);
|
||||||
if (applicationFound) {
|
if (applicationsFound && applicationsFound.length > 0) {
|
||||||
const webhookSecret = applicationFound.gitSource.githubApp.webhookSecret || null;
|
for (const application of applicationsFound) {
|
||||||
//@ts-ignore
|
const buildId = cuid();
|
||||||
const hmac = crypto.createHmac('sha256', webhookSecret);
|
const webhookSecret = application.gitSource.githubApp.webhookSecret || null;
|
||||||
const digest = Buffer.from(
|
|
||||||
'sha256=' + hmac.update(JSON.stringify(body)).digest('hex'),
|
|
||||||
'utf8'
|
|
||||||
);
|
|
||||||
if (!isDev) {
|
|
||||||
const checksum = Buffer.from(githubSignature, 'utf8');
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
if (checksum.length !== digest.length || !crypto.timingSafeEqual(digest, checksum)) {
|
const hmac = crypto.createHmac('sha256', webhookSecret);
|
||||||
throw { status: 500, message: 'SHA256 checksum failed. Are you doing something fishy?' }
|
const digest = Buffer.from(
|
||||||
};
|
'sha256=' + hmac.update(JSON.stringify(body)).digest('hex'),
|
||||||
}
|
'utf8'
|
||||||
|
);
|
||||||
|
if (!isDev) {
|
||||||
if (githubEvent === 'push') {
|
const checksum = Buffer.from(githubSignature, 'utf8');
|
||||||
if (!applicationFound.configHash) {
|
//@ts-ignore
|
||||||
const configHash = crypto
|
if (checksum.length !== digest.length || !crypto.timingSafeEqual(digest, checksum)) {
|
||||||
//@ts-ignore
|
throw { status: 500, message: 'SHA256 checksum failed. Are you doing something fishy?' }
|
||||||
.createHash('sha256')
|
};
|
||||||
.update(
|
|
||||||
JSON.stringify({
|
|
||||||
buildPack: applicationFound.buildPack,
|
|
||||||
port: applicationFound.port,
|
|
||||||
exposePort: applicationFound.exposePort,
|
|
||||||
installCommand: applicationFound.installCommand,
|
|
||||||
buildCommand: applicationFound.buildCommand,
|
|
||||||
startCommand: applicationFound.startCommand
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.digest('hex');
|
|
||||||
await prisma.application.updateMany({
|
|
||||||
where: { branch, projectId },
|
|
||||||
data: { configHash }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
await prisma.application.update({
|
|
||||||
where: { id: applicationFound.id },
|
|
||||||
data: { updatedAt: new Date() }
|
|
||||||
});
|
|
||||||
await prisma.build.create({
|
|
||||||
data: {
|
|
||||||
id: buildId,
|
|
||||||
applicationId: applicationFound.id,
|
|
||||||
destinationDockerId: applicationFound.destinationDocker.id,
|
|
||||||
gitSourceId: applicationFound.gitSource.id,
|
|
||||||
githubAppId: applicationFound.gitSource.githubApp?.id,
|
|
||||||
gitlabAppId: applicationFound.gitSource.gitlabApp?.id,
|
|
||||||
status: 'queued',
|
|
||||||
type: 'webhook_commit'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
scheduler.workers.get('deployApplication').postMessage({
|
|
||||||
build_id: buildId,
|
|
||||||
type: 'webhook_commit',
|
|
||||||
...applicationFound
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
message: 'Queued. Thank you!'
|
|
||||||
};
|
|
||||||
} else if (githubEvent === 'pull_request') {
|
|
||||||
const pullmergeRequestId = body.number;
|
|
||||||
const pullmergeRequestAction = body.action;
|
|
||||||
const sourceBranch = body.pull_request.head.ref.includes('/') ? body.pull_request.head.ref.split('/')[2] : body.pull_request.head.ref;
|
|
||||||
if (!allowedActions.includes(pullmergeRequestAction)) {
|
|
||||||
throw { status: 500, message: 'Action not allowed.' }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (applicationFound.settings.previews) {
|
if (githubEvent === 'push') {
|
||||||
if (applicationFound.destinationDockerId) {
|
if (!application.configHash) {
|
||||||
const isRunning = await checkContainer(
|
const configHash = crypto
|
||||||
{
|
//@ts-ignore
|
||||||
dockerId: applicationFound.destinationDocker.id,
|
.createHash('sha256')
|
||||||
container: applicationFound.id
|
.update(
|
||||||
}
|
JSON.stringify({
|
||||||
);
|
buildPack: application.buildPack,
|
||||||
if (!isRunning) {
|
port: application.port,
|
||||||
throw { status: 500, message: 'Application not running.' }
|
exposePort: application.exposePort,
|
||||||
}
|
installCommand: application.installCommand,
|
||||||
}
|
buildCommand: application.buildCommand,
|
||||||
if (
|
startCommand: application.startCommand
|
||||||
pullmergeRequestAction === 'opened' ||
|
})
|
||||||
pullmergeRequestAction === 'reopened' ||
|
)
|
||||||
pullmergeRequestAction === 'synchronize'
|
.digest('hex');
|
||||||
) {
|
|
||||||
await prisma.application.update({
|
await prisma.application.update({
|
||||||
where: { id: applicationFound.id },
|
where: { id: application.id },
|
||||||
data: { updatedAt: new Date() }
|
data: { configHash }
|
||||||
});
|
});
|
||||||
await prisma.build.create({
|
|
||||||
data: {
|
|
||||||
id: buildId,
|
|
||||||
applicationId: applicationFound.id,
|
|
||||||
destinationDockerId: applicationFound.destinationDocker.id,
|
|
||||||
gitSourceId: applicationFound.gitSource.id,
|
|
||||||
githubAppId: applicationFound.gitSource.githubApp?.id,
|
|
||||||
gitlabAppId: applicationFound.gitSource.gitlabApp?.id,
|
|
||||||
status: 'queued',
|
|
||||||
type: 'webhook_pr'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
scheduler.workers.get('deployApplication').postMessage({
|
|
||||||
build_id: buildId,
|
|
||||||
type: 'webhook_pr',
|
|
||||||
...applicationFound,
|
|
||||||
sourceBranch,
|
|
||||||
pullmergeRequestId
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
message: 'Queued. Thank you!'
|
|
||||||
};
|
|
||||||
} else if (pullmergeRequestAction === 'closed') {
|
|
||||||
if (applicationFound.destinationDockerId) {
|
|
||||||
const id = `${applicationFound.id}-${pullmergeRequestId}`;
|
|
||||||
await removeContainer({ id, dockerId: applicationFound.destinationDocker.id });
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
message: 'Removed preview. Thank you!'
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
throw { status: 500, message: 'Pull request previews are not enabled.' }
|
await prisma.application.update({
|
||||||
|
where: { id: application.id },
|
||||||
|
data: { updatedAt: new Date() }
|
||||||
|
});
|
||||||
|
await prisma.build.create({
|
||||||
|
data: {
|
||||||
|
id: buildId,
|
||||||
|
applicationId: application.id,
|
||||||
|
destinationDockerId: application.destinationDocker.id,
|
||||||
|
gitSourceId: application.gitSource.id,
|
||||||
|
githubAppId: application.gitSource.githubApp?.id,
|
||||||
|
gitlabAppId: application.gitSource.gitlabApp?.id,
|
||||||
|
status: 'queued',
|
||||||
|
type: 'webhook_commit'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log(`Webhook for ${application.name} queued.`)
|
||||||
|
|
||||||
|
} else if (githubEvent === 'pull_request') {
|
||||||
|
const pullmergeRequestId = body.number.toString();
|
||||||
|
const pullmergeRequestAction = body.action;
|
||||||
|
const sourceBranch = body.pull_request.head.ref.includes('/') ? body.pull_request.head.ref.split('/')[2] : body.pull_request.head.ref;
|
||||||
|
if (!allowedActions.includes(pullmergeRequestAction)) {
|
||||||
|
throw { status: 500, message: 'Action not allowed.' }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (application.settings.previews) {
|
||||||
|
if (application.destinationDockerId) {
|
||||||
|
const isRunning = await checkContainer(
|
||||||
|
{
|
||||||
|
dockerId: application.destinationDocker.id,
|
||||||
|
container: application.id
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (!isRunning) {
|
||||||
|
throw { status: 500, message: 'Application not running.' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
pullmergeRequestAction === 'opened' ||
|
||||||
|
pullmergeRequestAction === 'reopened' ||
|
||||||
|
pullmergeRequestAction === 'synchronize'
|
||||||
|
) {
|
||||||
|
await prisma.application.update({
|
||||||
|
where: { id: application.id },
|
||||||
|
data: { updatedAt: new Date() }
|
||||||
|
});
|
||||||
|
if (application.connectedDatabase && pullmergeRequestAction === 'opened' || pullmergeRequestAction === 'reopened') {
|
||||||
|
// Coolify hosted database
|
||||||
|
if (application.connectedDatabase.databaseId) {
|
||||||
|
const databaseId = application.connectedDatabase.databaseId;
|
||||||
|
const database = await prisma.database.findUnique({ where: { id: databaseId } });
|
||||||
|
if (database) {
|
||||||
|
await createdBranchDatabase(database, application.connectedDatabase.hostedDatabaseDBName, pullmergeRequestId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await prisma.build.create({
|
||||||
|
data: {
|
||||||
|
id: buildId,
|
||||||
|
pullmergeRequestId,
|
||||||
|
sourceBranch,
|
||||||
|
applicationId: application.id,
|
||||||
|
destinationDockerId: application.destinationDocker.id,
|
||||||
|
gitSourceId: application.gitSource.id,
|
||||||
|
githubAppId: application.gitSource.githubApp?.id,
|
||||||
|
gitlabAppId: application.gitSource.gitlabApp?.id,
|
||||||
|
status: 'queued',
|
||||||
|
type: 'webhook_pr'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
} else if (pullmergeRequestAction === 'closed') {
|
||||||
|
if (application.destinationDockerId) {
|
||||||
|
const id = `${application.id}-${pullmergeRequestId}`;
|
||||||
|
try {
|
||||||
|
await removeContainer({ id, dockerId: application.destinationDocker.id });
|
||||||
|
} catch (error) { }
|
||||||
|
}
|
||||||
|
if (application.connectedDatabase.databaseId) {
|
||||||
|
const databaseId = application.connectedDatabase.databaseId;
|
||||||
|
const database = await prisma.database.findUnique({ where: { id: databaseId } });
|
||||||
|
if (database) {
|
||||||
|
await removeBranchDatabase(database, pullmergeRequestId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw { status: 500, message: 'Not handled event.' }
|
|
||||||
} catch ({ status, message }) {
|
} catch ({ status, message }) {
|
||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,8 @@ import axios from "axios";
|
|||||||
import cuid from "cuid";
|
import cuid from "cuid";
|
||||||
import crypto from "crypto";
|
import crypto from "crypto";
|
||||||
import type { FastifyReply, FastifyRequest } from "fastify";
|
import type { FastifyReply, FastifyRequest } from "fastify";
|
||||||
import { errorHandler, getAPIUrl, isDev, listSettings, prisma } from "../../../lib/common";
|
import { errorHandler, getAPIUrl, getUIUrl, isDev, listSettings, prisma } from "../../../lib/common";
|
||||||
import { checkContainer, removeContainer } from "../../../lib/docker";
|
import { checkContainer, removeContainer } from "../../../lib/docker";
|
||||||
import { scheduler } from "../../../lib/scheduler";
|
|
||||||
import { getApplicationFromDB, getApplicationFromDBWebhook } from "../../api/v1/applications/handlers";
|
import { getApplicationFromDB, getApplicationFromDBWebhook } from "../../api/v1/applications/handlers";
|
||||||
|
|
||||||
import type { ConfigureGitLabApp, GitLabEvents } from "./types";
|
import type { ConfigureGitLabApp, GitLabEvents } from "./types";
|
||||||
@@ -30,7 +29,7 @@ export async function configureGitLabApp(request: FastifyRequest<ConfigureGitLab
|
|||||||
});
|
});
|
||||||
const { data } = await axios.post(`${htmlUrl}/oauth/token`, params)
|
const { data } = await axios.post(`${htmlUrl}/oauth/token`, params)
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
return reply.redirect(`${getAPIUrl()}/webhooks/success?token=${data.access_token}`)
|
return reply.redirect(`${getUIUrl()}/webhooks/success?token=${data.access_token}`)
|
||||||
}
|
}
|
||||||
return reply.redirect(`/webhooks/success?token=${data.access_token}`)
|
return reply.redirect(`/webhooks/success?token=${data.access_token}`)
|
||||||
} catch ({ status, message, ...other }) {
|
} catch ({ status, message, ...other }) {
|
||||||
@@ -40,65 +39,56 @@ export async function configureGitLabApp(request: FastifyRequest<ConfigureGitLab
|
|||||||
export async function gitLabEvents(request: FastifyRequest<GitLabEvents>) {
|
export async function gitLabEvents(request: FastifyRequest<GitLabEvents>) {
|
||||||
const { object_kind: objectKind, ref, project_id } = request.body
|
const { object_kind: objectKind, ref, project_id } = request.body
|
||||||
try {
|
try {
|
||||||
const buildId = cuid();
|
|
||||||
|
|
||||||
const allowedActions = ['opened', 'reopen', 'close', 'open', 'update'];
|
const allowedActions = ['opened', 'reopen', 'close', 'open', 'update'];
|
||||||
|
|
||||||
const webhookToken = request.headers['x-gitlab-token'];
|
const webhookToken = request.headers['x-gitlab-token'];
|
||||||
if (!webhookToken) {
|
if (!webhookToken && !isDev) {
|
||||||
throw { status: 500, message: 'Invalid webhookToken.' }
|
throw { status: 500, message: 'Invalid webhookToken.' }
|
||||||
}
|
}
|
||||||
if (objectKind === 'push') {
|
if (objectKind === 'push') {
|
||||||
const projectId = Number(project_id);
|
const projectId = Number(project_id);
|
||||||
const branch = ref.split('/')[2];
|
const branch = ref.split('/')[2];
|
||||||
const applicationFound = await getApplicationFromDBWebhook(projectId, branch);
|
const applicationsFound = await getApplicationFromDBWebhook(projectId, branch);
|
||||||
if (applicationFound) {
|
if (applicationsFound && applicationsFound.length > 0) {
|
||||||
if (!applicationFound.configHash) {
|
for (const application of applicationsFound) {
|
||||||
const configHash = crypto
|
const buildId = cuid();
|
||||||
.createHash('sha256')
|
if (!application.configHash) {
|
||||||
.update(
|
const configHash = crypto
|
||||||
JSON.stringify({
|
.createHash('sha256')
|
||||||
buildPack: applicationFound.buildPack,
|
.update(
|
||||||
port: applicationFound.port,
|
JSON.stringify({
|
||||||
exposePort: applicationFound.exposePort,
|
buildPack: application.buildPack,
|
||||||
installCommand: applicationFound.installCommand,
|
port: application.port,
|
||||||
buildCommand: applicationFound.buildCommand,
|
exposePort: application.exposePort,
|
||||||
startCommand: applicationFound.startCommand
|
installCommand: application.installCommand,
|
||||||
})
|
buildCommand: application.buildCommand,
|
||||||
)
|
startCommand: application.startCommand
|
||||||
.digest('hex');
|
})
|
||||||
await prisma.application.updateMany({
|
)
|
||||||
where: { branch, projectId },
|
.digest('hex');
|
||||||
data: { configHash }
|
await prisma.application.update({
|
||||||
|
where: { id: application.id },
|
||||||
|
data: { configHash }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await prisma.application.update({
|
||||||
|
where: { id: application.id },
|
||||||
|
data: { updatedAt: new Date() }
|
||||||
|
});
|
||||||
|
await prisma.build.create({
|
||||||
|
data: {
|
||||||
|
id: buildId,
|
||||||
|
applicationId: application.id,
|
||||||
|
destinationDockerId: application.destinationDocker.id,
|
||||||
|
gitSourceId: application.gitSource.id,
|
||||||
|
githubAppId: application.gitSource.githubApp?.id,
|
||||||
|
gitlabAppId: application.gitSource.gitlabApp?.id,
|
||||||
|
status: 'queued',
|
||||||
|
type: 'webhook_commit'
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
await prisma.application.update({
|
|
||||||
where: { id: applicationFound.id },
|
|
||||||
data: { updatedAt: new Date() }
|
|
||||||
});
|
|
||||||
await prisma.build.create({
|
|
||||||
data: {
|
|
||||||
id: buildId,
|
|
||||||
applicationId: applicationFound.id,
|
|
||||||
destinationDockerId: applicationFound.destinationDocker.id,
|
|
||||||
gitSourceId: applicationFound.gitSource.id,
|
|
||||||
githubAppId: applicationFound.gitSource.githubApp?.id,
|
|
||||||
gitlabAppId: applicationFound.gitSource.gitlabApp?.id,
|
|
||||||
status: 'queued',
|
|
||||||
type: 'webhook_commit'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
scheduler.workers.get('deployApplication').postMessage({
|
|
||||||
build_id: buildId,
|
|
||||||
type: 'webhook_commit',
|
|
||||||
...applicationFound
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
message: 'Queued. Thank you!'
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if (objectKind === 'merge_request') {
|
} else if (objectKind === 'merge_request') {
|
||||||
const { object_attributes: { work_in_progress: isDraft, action, source_branch: sourceBranch, target_branch: targetBranch, iid: pullmergeRequestId }, project: { id } } = request.body
|
const { object_attributes: { work_in_progress: isDraft, action, source_branch: sourceBranch, target_branch: targetBranch, iid: pullmergeRequestId }, project: { id } } = request.body
|
||||||
@@ -111,71 +101,63 @@ export async function gitLabEvents(request: FastifyRequest<GitLabEvents>) {
|
|||||||
throw { status: 500, message: 'Draft MR, do nothing.' }
|
throw { status: 500, message: 'Draft MR, do nothing.' }
|
||||||
}
|
}
|
||||||
|
|
||||||
const applicationFound = await getApplicationFromDBWebhook(projectId, targetBranch);
|
const applicationsFound = await getApplicationFromDBWebhook(projectId, targetBranch);
|
||||||
if (applicationFound) {
|
if (applicationsFound && applicationsFound.length > 0) {
|
||||||
if (applicationFound.settings.previews) {
|
for (const application of applicationsFound) {
|
||||||
if (applicationFound.destinationDockerId) {
|
const buildId = cuid();
|
||||||
const isRunning = await checkContainer(
|
if (application.settings.previews) {
|
||||||
{
|
if (application.destinationDockerId) {
|
||||||
dockerId: applicationFound.destinationDocker.id,
|
const isRunning = await checkContainer(
|
||||||
container: applicationFound.id
|
{
|
||||||
|
dockerId: application.destinationDocker.id,
|
||||||
|
container: application.id
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (!isRunning) {
|
||||||
|
throw { status: 500, message: 'Application not running.' }
|
||||||
}
|
}
|
||||||
);
|
|
||||||
if (!isRunning) {
|
|
||||||
throw { status: 500, message: 'Application not running.' }
|
|
||||||
}
|
}
|
||||||
}
|
if (!isDev && application.gitSource.gitlabApp.webhookToken !== webhookToken) {
|
||||||
if (!isDev && applicationFound.gitSource.gitlabApp.webhookToken !== webhookToken) {
|
throw { status: 500, message: 'Invalid webhookToken. Are you doing something nasty?!' }
|
||||||
throw { status: 500, message: 'Invalid webhookToken. Are you doing something nasty?!' }
|
}
|
||||||
}
|
if (
|
||||||
if (
|
action === 'opened' ||
|
||||||
action === 'opened' ||
|
action === 'reopen' ||
|
||||||
action === 'reopen' ||
|
action === 'open' ||
|
||||||
action === 'open' ||
|
action === 'update'
|
||||||
action === 'update'
|
) {
|
||||||
) {
|
await prisma.application.update({
|
||||||
await prisma.application.update({
|
where: { id: application.id },
|
||||||
where: { id: applicationFound.id },
|
data: { updatedAt: new Date() }
|
||||||
data: { updatedAt: new Date() }
|
});
|
||||||
});
|
await prisma.build.create({
|
||||||
await prisma.build.create({
|
data: {
|
||||||
data: {
|
id: buildId,
|
||||||
id: buildId,
|
pullmergeRequestId,
|
||||||
applicationId: applicationFound.id,
|
sourceBranch,
|
||||||
destinationDockerId: applicationFound.destinationDocker.id,
|
applicationId: application.id,
|
||||||
gitSourceId: applicationFound.gitSource.id,
|
destinationDockerId: application.destinationDocker.id,
|
||||||
githubAppId: applicationFound.gitSource.githubApp?.id,
|
gitSourceId: application.gitSource.id,
|
||||||
gitlabAppId: applicationFound.gitSource.gitlabApp?.id,
|
githubAppId: application.gitSource.githubApp?.id,
|
||||||
status: 'queued',
|
gitlabAppId: application.gitSource.gitlabApp?.id,
|
||||||
type: 'webhook_mr'
|
status: 'queued',
|
||||||
|
type: 'webhook_mr'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
message: 'Queued. Thank you!'
|
||||||
|
};
|
||||||
|
} else if (action === 'close') {
|
||||||
|
if (application.destinationDockerId) {
|
||||||
|
const id = `${application.id}-${pullmergeRequestId}`;
|
||||||
|
await removeContainer({ id, dockerId: application.destinationDocker.id });
|
||||||
}
|
}
|
||||||
});
|
|
||||||
scheduler.workers.get('deployApplication').postMessage({
|
|
||||||
build_id: buildId,
|
|
||||||
type: 'webhook_mr',
|
|
||||||
...applicationFound,
|
|
||||||
sourceBranch,
|
|
||||||
pullmergeRequestId
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
message: 'Queued. Thank you!'
|
|
||||||
};
|
|
||||||
} else if (action === 'close') {
|
|
||||||
if (applicationFound.destinationDockerId) {
|
|
||||||
const id = `${applicationFound.id}-${pullmergeRequestId}`;
|
|
||||||
const engine = applicationFound.destinationDocker.engine;
|
|
||||||
await removeContainer({ id, dockerId: applicationFound.destinationDocker.id });
|
|
||||||
}
|
}
|
||||||
return {
|
|
||||||
message: 'Removed preview. Thank you!'
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw { status: 500, message: 'Merge request previews are not enabled.' }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw { status: 500, message: 'Not handled event.' }
|
|
||||||
} catch ({ status, message }) {
|
} catch ({ status, message }) {
|
||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import { FastifyRequest } from "fastify";
|
import { FastifyRequest } from "fastify";
|
||||||
import { errorHandler, getDomain, isDev, prisma, supportedServiceTypesAndVersions, include, executeDockerCmd } from "../../../lib/common";
|
import { errorHandler, getDomain, isDev, prisma, executeDockerCmd } from "../../../lib/common";
|
||||||
|
import { supportedServiceTypesAndVersions } from "../../../lib/services/supportedVersions";
|
||||||
|
import { includeServices } from "../../../lib/services/common";
|
||||||
import { TraefikOtherConfiguration } from "./types";
|
import { TraefikOtherConfiguration } from "./types";
|
||||||
|
import { OnlyId } from "../../../types";
|
||||||
|
|
||||||
function configureMiddleware(
|
function configureMiddleware(
|
||||||
{ id, container, port, domain, nakedDomain, isHttps, isWWW, isDualCerts, scriptName, type },
|
{ id, container, port, domain, nakedDomain, isHttps, isWWW, isDualCerts, scriptName, type },
|
||||||
@@ -23,7 +26,30 @@ function configureMiddleware(
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (type === 'appwrite') {
|
||||||
|
traefik.http.routers[`${id}-realtime`] = {
|
||||||
|
entrypoints: ['websecure'],
|
||||||
|
rule: `(Host(\`${nakedDomain}\`) || Host(\`www.${nakedDomain}\`)) && PathPrefix(\`/v1/realtime\`)`,
|
||||||
|
service: `${`${id}-realtime`}`,
|
||||||
|
tls: {
|
||||||
|
domains: {
|
||||||
|
main: `${domain}`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
middlewares: []
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
traefik.http.services[`${id}-realtime`] = {
|
||||||
|
loadbalancer: {
|
||||||
|
servers: [
|
||||||
|
{
|
||||||
|
url: `http://${container}-realtime:${port}`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
if (isDualCerts) {
|
if (isDualCerts) {
|
||||||
traefik.http.routers[`${id}-secure`] = {
|
traefik.http.routers[`${id}-secure`] = {
|
||||||
entrypoints: ['websecure'],
|
entrypoints: ['websecure'],
|
||||||
@@ -110,6 +136,23 @@ function configureMiddleware(
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (type === 'appwrite') {
|
||||||
|
traefik.http.routers[`${id}-realtime`] = {
|
||||||
|
entrypoints: ['web'],
|
||||||
|
rule: `(Host(\`${nakedDomain}\`) || Host(\`www.${nakedDomain}\`)) && PathPrefix(\`/v1/realtime\`)`,
|
||||||
|
service: `${id}-realtime`,
|
||||||
|
middlewares: []
|
||||||
|
};
|
||||||
|
traefik.http.services[`${id}-realtime`] = {
|
||||||
|
loadbalancer: {
|
||||||
|
servers: [
|
||||||
|
{
|
||||||
|
url: `http://${container}-realtime:${port}`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (!isDualCerts) {
|
if (!isDualCerts) {
|
||||||
if (isWWW) {
|
if (isWWW) {
|
||||||
@@ -234,7 +277,7 @@ export async function traefikConfiguration(request, reply) {
|
|||||||
}
|
}
|
||||||
const services: any = await prisma.service.findMany({
|
const services: any = await prisma.service.findMany({
|
||||||
where: { destinationDocker: { remoteEngine: false } },
|
where: { destinationDocker: { remoteEngine: false } },
|
||||||
include,
|
include: includeServices,
|
||||||
orderBy: { createdAt: 'desc' },
|
orderBy: { createdAt: 'desc' },
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -488,7 +531,7 @@ export async function traefikOtherConfiguration(request: FastifyRequest<TraefikO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function remoteTraefikConfiguration(request: FastifyRequest) {
|
export async function remoteTraefikConfiguration(request: FastifyRequest<OnlyId>) {
|
||||||
const { id } = request.params
|
const { id } = request.params
|
||||||
try {
|
try {
|
||||||
const traefik = {
|
const traefik = {
|
||||||
@@ -590,7 +633,7 @@ export async function remoteTraefikConfiguration(request: FastifyRequest) {
|
|||||||
}
|
}
|
||||||
const services: any = await prisma.service.findMany({
|
const services: any = await prisma.service.findMany({
|
||||||
where: { destinationDocker: { id } },
|
where: { destinationDocker: { id } },
|
||||||
include,
|
include: includeServices,
|
||||||
orderBy: { createdAt: 'desc' }
|
orderBy: { createdAt: 'desc' }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -36,4 +36,3 @@ export interface SaveDatabaseSettings extends OnlyId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
4
apps/i18n/.env.example
Normal file
4
apps/i18n/.env.example
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
WEBLATE_INSTANCE_URL=http://localhost
|
||||||
|
WEBLATE_COMPONENT_NAME=coolify
|
||||||
|
WEBLATE_TOKEN=
|
||||||
|
TRANSLATION_DIR=
|
||||||
1
apps/i18n/.gitignore
vendored
Normal file
1
apps/i18n/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
locales/*
|
||||||
63
apps/i18n/index.mjs
Normal file
63
apps/i18n/index.mjs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import dotenv from 'dotenv';
|
||||||
|
dotenv.config()
|
||||||
|
import fs from 'fs'
|
||||||
|
import path from 'path'
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
import Gettext from 'node-gettext'
|
||||||
|
import { po } from 'gettext-parser'
|
||||||
|
import got from 'got';
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
const weblateInstanceURL = process.env.WEBLATE_INSTANCE_URL;
|
||||||
|
const weblateComponentName = process.env.WEBLATE_COMPONENT_NAME
|
||||||
|
const token = process.env.WEBLATE_TOKEN;
|
||||||
|
|
||||||
|
const translationsDir = process.env.TRANSLATION_DIR;
|
||||||
|
const translationsPODir = './locales';
|
||||||
|
const locales = []
|
||||||
|
const domain = 'locale'
|
||||||
|
|
||||||
|
const translations = await got(`${weblateInstanceURL}/api/components/${weblateComponentName}/glossary/translations/?format=json`, {
|
||||||
|
headers: {
|
||||||
|
"Authorization": `Token ${token}`
|
||||||
|
}
|
||||||
|
}).json()
|
||||||
|
for (const translation of translations.results) {
|
||||||
|
const code = translation.language_code
|
||||||
|
locales.push(code)
|
||||||
|
|
||||||
|
const fileUrl = translation.file_url.replace('=json', '=po')
|
||||||
|
const file = await got(fileUrl, {
|
||||||
|
headers: {
|
||||||
|
"Authorization": `Token ${token}`
|
||||||
|
}
|
||||||
|
}).text()
|
||||||
|
fs.writeFileSync(path.join(__dirname, translationsPODir, domain + '-' + code + '.po'), file)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const gt = new Gettext()
|
||||||
|
|
||||||
|
locales.forEach((locale) => {
|
||||||
|
let json = {}
|
||||||
|
const fileName = `${domain}-${locale}.po`
|
||||||
|
const translationsFilePath = path.join(translationsPODir, fileName)
|
||||||
|
const translationsContent = fs.readFileSync(translationsFilePath)
|
||||||
|
|
||||||
|
const parsedTranslations = po.parse(translationsContent)
|
||||||
|
const a = gt.gettext(parsedTranslations)
|
||||||
|
for (const [key, value] of Object.entries(a)) {
|
||||||
|
if (key === 'translations') {
|
||||||
|
for (const [key1, value1] of Object.entries(value)) {
|
||||||
|
if (key1 !== '') {
|
||||||
|
for (const [key2, value2] of Object.entries(value1)) {
|
||||||
|
json[value2.msgctxt] = value2.msgstr[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fs.writeFileSync(`${translationsDir}/${locale}.json`, JSON.stringify(json))
|
||||||
|
})
|
||||||
15
apps/i18n/package.json
Normal file
15
apps/i18n/package.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "i18n-converter",
|
||||||
|
"description": "Convert Weblate translations to sveltekit-i18n",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"scripts": {
|
||||||
|
"translate": "node index.mjs"
|
||||||
|
},
|
||||||
|
"type": "module",
|
||||||
|
"dependencies": {
|
||||||
|
"node-gettext": "3.0.0",
|
||||||
|
"gettext-parser": "6.0.0",
|
||||||
|
"got": "12.3.1",
|
||||||
|
"dotenv": "16.0.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,32 +14,38 @@
|
|||||||
"format": "prettier --write --plugin-search-dir=. ."
|
"format": "prettier --write --plugin-search-dir=. ."
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@playwright/test": "1.24.2",
|
"@floating-ui/dom": "1.0.1",
|
||||||
|
"@playwright/test": "1.25.1",
|
||||||
|
"@popperjs/core": "2.11.6",
|
||||||
"@sveltejs/kit": "1.0.0-next.405",
|
"@sveltejs/kit": "1.0.0-next.405",
|
||||||
"@types/js-cookie": "3.0.2",
|
"@types/js-cookie": "3.0.2",
|
||||||
"@typescript-eslint/eslint-plugin": "5.33.0",
|
"@typescript-eslint/eslint-plugin": "5.36.1",
|
||||||
"@typescript-eslint/parser": "5.33.0",
|
"@typescript-eslint/parser": "5.36.1",
|
||||||
"autoprefixer": "10.4.8",
|
"autoprefixer": "10.4.8",
|
||||||
"eslint": "8.21.0",
|
"classnames": "2.3.1",
|
||||||
|
"eslint": "8.23.0",
|
||||||
"eslint-config-prettier": "8.5.0",
|
"eslint-config-prettier": "8.5.0",
|
||||||
"eslint-plugin-svelte3": "4.0.0",
|
"eslint-plugin-svelte3": "4.0.0",
|
||||||
|
"flowbite": "1.5.2",
|
||||||
|
"flowbite-svelte": "0.26.2",
|
||||||
"postcss": "8.4.16",
|
"postcss": "8.4.16",
|
||||||
"prettier": "2.7.1",
|
"prettier": "2.7.1",
|
||||||
"prettier-plugin-svelte": "2.7.0",
|
"prettier-plugin-svelte": "2.7.0",
|
||||||
"svelte": "3.49.0",
|
"svelte": "3.50.0",
|
||||||
"svelte-check": "2.8.0",
|
"svelte-check": "2.9.0",
|
||||||
"svelte-preprocess": "4.10.7",
|
"svelte-preprocess": "4.10.7",
|
||||||
"tailwindcss": "3.1.8",
|
"tailwindcss": "3.1.8",
|
||||||
"tailwindcss-scrollbar": "0.1.0",
|
"tailwindcss-scrollbar": "0.1.0",
|
||||||
"tslib": "2.4.0",
|
"tslib": "2.4.0",
|
||||||
"typescript": "4.7.4",
|
"typescript": "4.8.2",
|
||||||
"vite": "3.0.5"
|
"vite": "3.1.0"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sveltejs/adapter-static": "1.0.0-next.39",
|
"@sveltejs/adapter-static": "1.0.0-next.39",
|
||||||
|
"@tailwindcss/typography": "^0.5.7",
|
||||||
"cuid": "2.1.8",
|
"cuid": "2.1.8",
|
||||||
"daisyui": "2.22.0",
|
"daisyui": "2.24.2",
|
||||||
"js-cookie": "3.0.1",
|
"js-cookie": "3.0.1",
|
||||||
"p-limit": "4.0.0",
|
"p-limit": "4.0.0",
|
||||||
"svelte-select": "4.4.7",
|
"svelte-select": "4.4.7",
|
||||||
|
|||||||
@@ -1,188 +1,5 @@
|
|||||||
import { addToast } from '$lib/store';
|
import { addToast } from '$lib/store';
|
||||||
|
|
||||||
export const supportedServiceTypesAndVersions = [
|
|
||||||
{
|
|
||||||
name: 'plausibleanalytics',
|
|
||||||
fancyName: 'Plausible Analytics',
|
|
||||||
baseImage: 'plausible/analytics',
|
|
||||||
images: ['bitnami/postgresql:13.2.0', 'yandex/clickhouse-server:21.3.2.5'],
|
|
||||||
versions: ['latest', 'stable'],
|
|
||||||
recommendedVersion: 'stable',
|
|
||||||
ports: {
|
|
||||||
main: 8000
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'nocodb',
|
|
||||||
fancyName: 'NocoDB',
|
|
||||||
baseImage: 'nocodb/nocodb',
|
|
||||||
versions: ['latest'],
|
|
||||||
recommendedVersion: 'latest',
|
|
||||||
ports: {
|
|
||||||
main: 8080
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'minio',
|
|
||||||
fancyName: 'MinIO',
|
|
||||||
baseImage: 'minio/minio',
|
|
||||||
versions: ['latest'],
|
|
||||||
recommendedVersion: 'latest',
|
|
||||||
ports: {
|
|
||||||
main: 9001
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'vscodeserver',
|
|
||||||
fancyName: 'VSCode Server',
|
|
||||||
baseImage: 'codercom/code-server',
|
|
||||||
versions: ['latest'],
|
|
||||||
recommendedVersion: 'latest',
|
|
||||||
ports: {
|
|
||||||
main: 8080
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'wordpress',
|
|
||||||
fancyName: 'Wordpress',
|
|
||||||
baseImage: 'wordpress',
|
|
||||||
images: ['bitnami/mysql:5.7'],
|
|
||||||
versions: ['latest', 'php8.1', 'php8.0', 'php7.4', 'php7.3'],
|
|
||||||
recommendedVersion: 'latest',
|
|
||||||
ports: {
|
|
||||||
main: 80
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'vaultwarden',
|
|
||||||
fancyName: 'Vaultwarden',
|
|
||||||
baseImage: 'vaultwarden/server',
|
|
||||||
versions: ['latest'],
|
|
||||||
recommendedVersion: 'latest',
|
|
||||||
ports: {
|
|
||||||
main: 80
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'languagetool',
|
|
||||||
fancyName: 'LanguageTool',
|
|
||||||
baseImage: 'silviof/docker-languagetool',
|
|
||||||
versions: ['latest'],
|
|
||||||
recommendedVersion: 'latest',
|
|
||||||
ports: {
|
|
||||||
main: 8010
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'n8n',
|
|
||||||
fancyName: 'n8n',
|
|
||||||
baseImage: 'n8nio/n8n',
|
|
||||||
versions: ['latest'],
|
|
||||||
recommendedVersion: 'latest',
|
|
||||||
ports: {
|
|
||||||
main: 5678
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'uptimekuma',
|
|
||||||
fancyName: 'Uptime Kuma',
|
|
||||||
baseImage: 'louislam/uptime-kuma',
|
|
||||||
versions: ['latest'],
|
|
||||||
recommendedVersion: 'latest',
|
|
||||||
ports: {
|
|
||||||
main: 3001
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'ghost',
|
|
||||||
fancyName: 'Ghost',
|
|
||||||
baseImage: 'bitnami/ghost',
|
|
||||||
images: ['bitnami/mariadb'],
|
|
||||||
versions: ['latest'],
|
|
||||||
recommendedVersion: 'latest',
|
|
||||||
ports: {
|
|
||||||
main: 2368
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'meilisearch',
|
|
||||||
fancyName: 'Meilisearch',
|
|
||||||
baseImage: 'getmeili/meilisearch',
|
|
||||||
images: [],
|
|
||||||
versions: ['latest'],
|
|
||||||
recommendedVersion: 'latest',
|
|
||||||
ports: {
|
|
||||||
main: 7700
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'umami',
|
|
||||||
fancyName: 'Umami',
|
|
||||||
baseImage: 'ghcr.io/mikecao/umami',
|
|
||||||
images: ['postgres:12-alpine'],
|
|
||||||
versions: ['postgresql-latest'],
|
|
||||||
recommendedVersion: 'postgresql-latest',
|
|
||||||
ports: {
|
|
||||||
main: 3000
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'hasura',
|
|
||||||
fancyName: 'Hasura',
|
|
||||||
baseImage: 'hasura/graphql-engine',
|
|
||||||
images: ['postgres:12-alpine'],
|
|
||||||
versions: ['latest', 'v2.10.0', 'v2.5.1'],
|
|
||||||
recommendedVersion: 'v2.10.0',
|
|
||||||
ports: {
|
|
||||||
main: 8080
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'fider',
|
|
||||||
fancyName: 'Fider',
|
|
||||||
baseImage: 'getfider/fider',
|
|
||||||
images: ['postgres:12-alpine'],
|
|
||||||
versions: ['stable'],
|
|
||||||
recommendedVersion: 'stable',
|
|
||||||
ports: {
|
|
||||||
main: 3000
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'appwrite',
|
|
||||||
fancyName: 'Appwrite',
|
|
||||||
baseImage: 'appwrite/appwrite',
|
|
||||||
images: ['mariadb:10.7', 'redis:6.2-alpine', 'appwrite/telegraf:1.4.0'],
|
|
||||||
versions: ['latest', '0.15.3'],
|
|
||||||
recommendedVersion: '0.15.3',
|
|
||||||
ports: {
|
|
||||||
main: 80
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// {
|
|
||||||
// name: 'moodle',
|
|
||||||
// fancyName: 'Moodle',
|
|
||||||
// baseImage: 'bitnami/moodle',
|
|
||||||
// images: [],
|
|
||||||
// versions: ['latest', 'v4.0.2'],
|
|
||||||
// recommendedVersion: 'latest',
|
|
||||||
// ports: {
|
|
||||||
// main: 8080
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
{
|
|
||||||
name: 'glitchTip',
|
|
||||||
fancyName: 'GlitchTip',
|
|
||||||
baseImage: 'glitchtip/glitchtip',
|
|
||||||
images: ['postgres:14-alpine', 'redis:7-alpine'],
|
|
||||||
versions: ['latest'],
|
|
||||||
recommendedVersion: 'latest',
|
|
||||||
ports: {
|
|
||||||
main: 8000
|
|
||||||
}
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const asyncSleep = (delay: number) =>
|
export const asyncSleep = (delay: number) =>
|
||||||
new Promise((resolve) => setTimeout(resolve, delay));
|
new Promise((resolve) => setTimeout(resolve, delay));
|
||||||
|
|
||||||
@@ -254,15 +71,6 @@ export function changeQueryParams(buildId: string) {
|
|||||||
return history.pushState(null, null, '?' + queryParams.toString());
|
return history.pushState(null, null, '?' + queryParams.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getServiceMainPort = (service: string) => {
|
|
||||||
const serviceType = supportedServiceTypesAndVersions.find((s) => s.name === service);
|
|
||||||
if (serviceType) {
|
|
||||||
return serviceType.ports.main;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export function handlerNotFoundLoad(error: any, url: URL) {
|
export function handlerNotFoundLoad(error: any, url: URL) {
|
||||||
if (error?.status === 404) {
|
if (error?.status === 404) {
|
||||||
|
|||||||
32
apps/ui/src/lib/components/DocLink.svelte
Normal file
32
apps/ui/src/lib/components/DocLink.svelte
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import Tooltip from './Tooltip.svelte';
|
||||||
|
export let url = 'https://docs.coollabs.io';
|
||||||
|
let id =
|
||||||
|
'cool-' +
|
||||||
|
url
|
||||||
|
.split('')
|
||||||
|
.map((c) => c.charCodeAt(0).toString(16).padStart(2, '0'))
|
||||||
|
.join('')
|
||||||
|
.slice(-16);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<a {id} href={url} target="_blank" class="icons inline-block text-pink-500 cursor-pointer text-xs">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class="w-6 h-6"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
fill="none"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<path
|
||||||
|
d="M6 4h11a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-11a1 1 0 0 1 -1 -1v-14a1 1 0 0 1 1 -1m3 0v18"
|
||||||
|
/>
|
||||||
|
<line x1="13" y1="8" x2="15" y2="8" />
|
||||||
|
<line x1="13" y1="12" x2="15" y2="12" />
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
<Tooltip triggeredBy={`#${id}`}>See details in the documentation</Tooltip>
|
||||||
@@ -1,6 +1,31 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let text: string;
|
import { onMount } from 'svelte';
|
||||||
export let customClass = 'max-w-[24rem]';
|
|
||||||
|
import Tooltip from './Tooltip.svelte';
|
||||||
|
export let explanation = '';
|
||||||
|
let id: any;
|
||||||
|
let self: any;
|
||||||
|
onMount(() => {
|
||||||
|
id = `info-${self.offsetLeft}-${self.offsetTop}`;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="p-2 text-xs text-stone-400 {customClass}">{@html text}</div>
|
<div {id} class="inline-block mx-2 text-pink-500 cursor-pointer" bind:this={self}>
|
||||||
|
<svg
|
||||||
|
fill="none"
|
||||||
|
height="18"
|
||||||
|
shape-rendering="geometricPrecision"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="1.5"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
width="18"
|
||||||
|
><path d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z" /><path
|
||||||
|
d="M9.09 9a3 3 0 015.83 1c0 2-3 3-3 3"
|
||||||
|
/><circle cx="12" cy="17" r=".5" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
{#if id}
|
||||||
|
<Tooltip triggeredBy={`#${id}`}>{@html explanation}</Tooltip>
|
||||||
|
{/if}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Explainer from '$lib/components/Explainer.svelte';
|
import Explaner from './Explainer.svelte';
|
||||||
|
import Tooltip from './Tooltip.svelte';
|
||||||
|
|
||||||
|
export let id: any;
|
||||||
export let setting: any;
|
export let setting: any;
|
||||||
export let title: any;
|
export let title: any;
|
||||||
export let description: any;
|
export let description: any;
|
||||||
@@ -8,22 +10,17 @@
|
|||||||
export let disabled = false;
|
export let disabled = false;
|
||||||
export let dataTooltip: any = null;
|
export let dataTooltip: any = null;
|
||||||
export let loading = false;
|
export let loading = false;
|
||||||
|
let triggeredBy = `#${id}`;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex items-center py-4 pr-8">
|
<div class="flex items-center py-4 pr-8">
|
||||||
<div class="flex w-96 flex-col">
|
<div class="flex w-96 flex-col">
|
||||||
<div class="text-xs font-bold text-stone-100 md:text-base">{title}</div>
|
<div class="text-xs font-bold text-stone-100 md:text-base">
|
||||||
<Explainer text={description} />
|
{title}<Explaner explanation={description} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div class:text-center={isCenter} class="flex justify-center">
|
||||||
class:tooltip-right={dataTooltip}
|
|
||||||
class:tooltip-primary={dataTooltip}
|
|
||||||
class:tooltip={dataTooltip}
|
|
||||||
class:text-center={isCenter}
|
|
||||||
data-tip={dataTooltip}
|
|
||||||
class="flex justify-center"
|
|
||||||
>
|
|
||||||
<div
|
<div
|
||||||
on:click
|
on:click
|
||||||
aria-pressed="false"
|
aria-pressed="false"
|
||||||
@@ -32,6 +29,7 @@
|
|||||||
class:bg-green-600={!loading && setting}
|
class:bg-green-600={!loading && setting}
|
||||||
class:bg-stone-700={!loading && !setting}
|
class:bg-stone-700={!loading && !setting}
|
||||||
class:bg-yellow-500={loading}
|
class:bg-yellow-500={loading}
|
||||||
|
{id}
|
||||||
>
|
>
|
||||||
<span class="sr-only">Use setting</span>
|
<span class="sr-only">Use setting</span>
|
||||||
<span
|
<span
|
||||||
@@ -72,3 +70,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{#if dataTooltip}
|
||||||
|
<Tooltip {triggeredBy} placement="top">{dataTooltip}</Tooltip>
|
||||||
|
{/if}
|
||||||
|
|||||||
6
apps/ui/src/lib/components/SimpleExplainer.svelte
Normal file
6
apps/ui/src/lib/components/SimpleExplainer.svelte
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export let text: string;
|
||||||
|
export let customClass = 'max-w-[24rem]';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="p-2 text-xs text-stone-400 {customClass}">{@html text}</div>
|
||||||
8
apps/ui/src/lib/components/Tooltip.svelte
Normal file
8
apps/ui/src/lib/components/Tooltip.svelte
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { Tooltip } from 'flowbite-svelte';
|
||||||
|
export let placement = 'bottom';
|
||||||
|
export let color = 'bg-coollabs text-left';
|
||||||
|
export let triggeredBy = '#tooltip-default';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Tooltip {triggeredBy} {placement} arrow={false} {color} style="custom"><slot /></Tooltip>
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
updateStatus.loading = true;
|
updateStatus.loading = true;
|
||||||
try {
|
try {
|
||||||
if (dev) {
|
if (dev) {
|
||||||
console.log(`updating to ${latestVersion}`);
|
|
||||||
await asyncSleep(4000);
|
await asyncSleep(4000);
|
||||||
return window.location.reload();
|
return window.location.reload();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -20,12 +20,13 @@
|
|||||||
let usageInterval: any;
|
let usageInterval: any;
|
||||||
let loading = {
|
let loading = {
|
||||||
usage: false,
|
usage: false,
|
||||||
cleanup: false
|
cleanup: false,
|
||||||
|
restart: false
|
||||||
};
|
};
|
||||||
import { appSession } from '$lib/store';
|
import { addToast, appSession } from '$lib/store';
|
||||||
import { onDestroy, onMount } from 'svelte';
|
import { onDestroy, onMount } from 'svelte';
|
||||||
import { get } from '$lib/api';
|
import { get, post } from '$lib/api';
|
||||||
import { errorNotification } from '$lib/common';
|
import { asyncSleep, errorNotification } from '$lib/common';
|
||||||
async function getStatus() {
|
async function getStatus() {
|
||||||
if (loading.usage) return;
|
if (loading.usage) return;
|
||||||
loading.usage = true;
|
loading.usage = true;
|
||||||
@@ -33,6 +34,45 @@
|
|||||||
usage = data.usage;
|
usage = data.usage;
|
||||||
loading.usage = false;
|
loading.usage = false;
|
||||||
}
|
}
|
||||||
|
async function restartCoolify() {
|
||||||
|
const sure = confirm(
|
||||||
|
'Are you sure you would like to restart Coolify? Currently running deployments will be stopped and restarted.'
|
||||||
|
);
|
||||||
|
if (sure) {
|
||||||
|
loading.restart = true;
|
||||||
|
try {
|
||||||
|
await post(`/internal/restart`, {});
|
||||||
|
await asyncSleep(10000);
|
||||||
|
let reachable = false;
|
||||||
|
let tries = 0;
|
||||||
|
do {
|
||||||
|
await asyncSleep(4000);
|
||||||
|
try {
|
||||||
|
await get(`/undead`);
|
||||||
|
reachable = true;
|
||||||
|
} catch (error) {
|
||||||
|
reachable = false;
|
||||||
|
}
|
||||||
|
if (reachable) break;
|
||||||
|
tries++;
|
||||||
|
} while (!reachable || tries < 120);
|
||||||
|
addToast({
|
||||||
|
message: 'New version reachable. Reloading...',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
await asyncSleep(3000);
|
||||||
|
return window.location.reload();
|
||||||
|
addToast({
|
||||||
|
type: 'success',
|
||||||
|
message: 'Coolify restarted successfully. It will take a moment.'
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return errorNotification(error);
|
||||||
|
} finally {
|
||||||
|
loading.restart = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
clearInterval(usageInterval);
|
clearInterval(usageInterval);
|
||||||
});
|
});
|
||||||
@@ -48,65 +88,103 @@
|
|||||||
return errorNotification(error);
|
return errorNotification(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
async function manuallyCleanupStorage() {
|
||||||
|
try {
|
||||||
|
loading.cleanup = true;
|
||||||
|
await post('/internal/cleanup', {});
|
||||||
|
return addToast({
|
||||||
|
message: 'Cleanup done.',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return errorNotification(error);
|
||||||
|
} finally {
|
||||||
|
loading.cleanup = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="pb-4">
|
<div class="w-full">
|
||||||
<div class="title">Hardware Details</div>
|
<div class="flex lg:flex-row flex-col gap-4">
|
||||||
<div class="text-center p-8 ">
|
<h1 class="title lg:text-3xl">Hardware Details</h1>
|
||||||
<div>
|
<div class="flex lg:flex-row flex-col space-x-0 lg:space-x-2 space-y-2 lg:space-y-0">
|
||||||
<div class="stat w-64">
|
{#if $appSession.teamId === '0'}
|
||||||
|
<button on:click={manuallyCleanupStorage} class:loading={loading.cleanup} class="btn btn-sm"
|
||||||
|
>Cleanup Storage</button
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
on:click={restartCoolify}
|
||||||
|
class:loading={loading.restart}
|
||||||
|
class="btn btn-sm bg-red-600 hover:bg-red-500">Restart Coolify</button
|
||||||
|
>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="divider" />
|
||||||
|
<div class="grid grid-flow-col gap-4 grid-rows-3 justify-start lg:justify-center lg:grid-rows-1">
|
||||||
|
<div class="stats stats-vertical min-w-[16rem] mb-5 rounded bg-transparent">
|
||||||
|
<div class="stat">
|
||||||
<div class="stat-title">Total Memory</div>
|
<div class="stat-title">Total Memory</div>
|
||||||
<div class="stat-value">
|
<div class="stat-value text-2xl">
|
||||||
{(usage?.memory.totalMemMb).toFixed(0)}<span class="text-sm">MB</span>
|
{(usage?.memory.totalMemMb).toFixed(0)}<span class="text-sm">MB</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="stat w-64">
|
|
||||||
|
<div class="stat">
|
||||||
<div class="stat-title">Used Memory</div>
|
<div class="stat-title">Used Memory</div>
|
||||||
<div class="stat-value">
|
<div class="stat-value text-2xl">
|
||||||
{(usage?.memory.usedMemMb).toFixed(0)}<span class="text-sm">MB</span>
|
{(usage?.memory.usedMemMb).toFixed(0)}<span class="text-sm">MB</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="stat w-64">
|
|
||||||
|
<div class="stat">
|
||||||
<div class="stat-title">Free Memory</div>
|
<div class="stat-title">Free Memory</div>
|
||||||
<div class="stat-value">
|
<div class="stat-value text-2xl">
|
||||||
{usage?.memory.freeMemPercentage}<span class="text-sm">%</span>
|
{usage?.memory.freeMemPercentage}<span class="text-sm">%</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="py-10">
|
|
||||||
<div class="stat w-64">
|
<div class="stats stats-vertical min-w-[20rem] mb-5 bg-transparent rounded">
|
||||||
<div class="stat-title">Total CPUs</div>
|
<div class="stat">
|
||||||
<div class="stat-value">
|
<div class="stat-title">Total CPU</div>
|
||||||
|
<div class="stat-value text-2xl">
|
||||||
{usage?.cpu.count}
|
{usage?.cpu.count}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="stat w-64">
|
|
||||||
|
<div class="stat">
|
||||||
<div class="stat-title">CPU Usage</div>
|
<div class="stat-title">CPU Usage</div>
|
||||||
<div class="stat-value">
|
<div class="stat-value text-2xl">
|
||||||
{usage?.cpu.usage}<span class="text-sm">%</span>
|
{usage?.cpu.usage}<span class="text-sm">%</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="stat w-64">
|
|
||||||
|
<div class="stat">
|
||||||
<div class="stat-title">Load Average (5,10,30mins)</div>
|
<div class="stat-title">Load Average (5,10,30mins)</div>
|
||||||
<div class="stat-value">{usage?.cpu.load}</div>
|
<div class="stat-value text-2xl">{usage?.cpu.load}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="stats stats-vertical min-w-[16rem] mb-5 bg-transparent rounded">
|
||||||
<div class="stat w-64">
|
<div class="stat">
|
||||||
<div class="stat-title">Total Disk</div>
|
<div class="stat-title">Total Disk</div>
|
||||||
<div class="stat-value">
|
<div class="stat-value text-2xl">
|
||||||
{usage?.disk.totalGb}<span class="text-sm">GB</span>
|
{usage?.disk.totalGb}<span class="text-sm">GB</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="stat w-64">
|
|
||||||
|
<div class="stat">
|
||||||
<div class="stat-title">Used Disk</div>
|
<div class="stat-title">Used Disk</div>
|
||||||
<div class="stat-value">
|
<div class="stat-value text-2xl">
|
||||||
{usage?.disk.usedGb}<span class="text-sm">GB</span>
|
{usage?.disk.usedGb}<span class="text-sm">GB</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="stat w-64">
|
|
||||||
|
<div class="stat">
|
||||||
<div class="stat-title">Free Disk</div>
|
<div class="stat-title">Free Disk</div>
|
||||||
<div class="stat-value">{usage?.disk.freePercentage}<span class="text-sm">%</span></div>
|
<div class="stat-value text-2xl">
|
||||||
|
{usage?.disk.freePercentage}<span class="text-sm">%</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,79 +2,8 @@
|
|||||||
export let isAbsolute = true;
|
export let isAbsolute = true;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svg
|
|
||||||
viewBox="0 0 128 128"
|
<svg viewBox="0 0 128 128" class={isAbsolute ? 'absolute top-0 left-0 -m-5 h-12 w-12' : 'mx-auto w-10 h-10'}>
|
||||||
class={isAbsolute ? 'absolute top-0 left-0 -m-8 h-16 w-16' : 'mx-auto w-8 h-8'}
|
<path d="M124.8 52.1c-4.3-2.5-10-2.8-14.8-1.4-.6-5.2-4-9.7-8-12.9l-1.6-1.3-1.4 1.6c-2.7 3.1-3.5 8.3-3.1 12.3.3 2.9 1.2 5.9 3 8.3-1.4.8-2.9 1.9-4.3 2.4-2.8 1-5.9 2-8.9 2H79V49H66V24H51v12H26v13H13v14H1.8l-.2 1.5c-.5 6.4.3 12.6 3 18.5l1.1 2.2.1.2c7.9 13.4 21.7 19 36.8 19 29.2 0 53.3-13.1 64.3-40.6 7.4.4 15-1.8 18.6-8.9l.9-1.8-1.6-1zM28 39h10v11H28V39zm13.1 44.2c0 1.7-1.4 3.1-3.1 3.1-1.7 0-3.1-1.4-3.1-3.1 0-1.7 1.4-3.1 3.1-3.1 1.7.1 3.1 1.4 3.1 3.1zM28 52h10v11H28V52zm-13 0h11v11H15V52zm27.7 50.2c-15.8-.1-24.3-5.4-31.3-12.4 2.1.1 4.1.2 5.9.2 1.6 0 3.2 0 4.7-.1 3.9-.2 7.3-.7 10.1-1.5 2.3 5.3 6.5 10.2 14 13.8h-3.4zM51 63H40V52h11v11zm0-13H40V39h11v11zm13 13H53V52h11v11zm0-13H53V39h11v11zm0-13H53V26h11v11zm13 26H66V52h11v11zM38.8 81.2c-.2-.1-.5-.2-.8-.2-1.2 0-2.2 1-2.2 2.2 0 1.2 1 2.2 2.2 2.2s2.2-1 2.2-2.2c0-.3-.1-.6-.2-.8-.2.3-.4.5-.8.5-.5 0-.9-.4-.9-.9.1-.4.3-.7.5-.8z" fill="#019BC6"></path>
|
||||||
>
|
</svg>
|
||||||
<g
|
|
||||||
><path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
fill="#3A4D54"
|
|
||||||
d="M73.8 50.8h11.3v11.5h5.7c2.6 0 5.3-.5 7.8-1.3 1.2-.4 2.6-1 3.8-1.7-1.6-2.1-2.4-4.7-2.6-7.3-.3-3.5.4-8.1 2.8-10.8l1.2-1.4 1.4 1.1c3.6 2.9 6.5 6.8 7.1 11.4 4.3-1.3 9.3-1 13.1 1.2l1.5.9-.8 1.6c-3.2 6.2-9.9 8.2-16.4 7.8-9.8 24.3-31 35.8-56.8 35.8-13.3 0-25.5-5-32.5-16.8l-.1-.2-1-2.1c-2.4-5.2-3.1-10.9-2.6-16.6l.2-1.7h9.6v-11.4h11.3v-11.2h22.5v-11.3h13.5v22.5z"
|
|
||||||
/><path
|
|
||||||
fill="#00AADA"
|
|
||||||
d="M110.4 55.1c.8-5.9-3.6-10.5-6.4-12.7-3.1 3.6-3.6 13.2 1.3 17.2-2.8 2.4-8.5 4.7-14.5 4.7h-72.2c-.6 6.2.5 11.9 3 16.8l.8 1.5c.5.9 1.1 1.7 1.7 2.6 3 .2 5.7.3 8.2.2 4.9-.1 8.9-.7 12-1.7.5-.2.9.1 1.1.5.2.5-.1.9-.5 1.1-.4.1-.8.3-1.3.4-2.4.7-5 1.1-8.3 1.3h-.6000000000000001c-1.3.1-2.7.1-4.2.1-1.6 0-3.1 0-4.9-.1 6 6.8 15.4 10.8 27.2 10.8 25 0 46.2-11.1 55.5-35.9 6.7.7 13.1-1 16-6.7-4.5-2.7-10.5-1.8-13.9-.1z"
|
|
||||||
/><path
|
|
||||||
fill="#28B8EB"
|
|
||||||
d="M110.4 55.1c.8-5.9-3.6-10.5-6.4-12.7-3.1 3.6-3.6 13.2 1.3 17.2-2.8 2.4-8.5 4.7-14.5 4.7h-68c-.3 9.5 3.2 16.7 9.5 21 4.9-.1 8.9-.7 12-1.7.5-.2.9.1 1.1.5.2.5-.1.9-.5 1.1-.4.1-.8.3-1.3.4-2.4.7-5.2 1.2-8.5 1.4l-.1-.1c8.5 4.4 20.8 4.3 35-1.1 15.8-6.1 30.6-17.7 40.9-30.9-.2.1-.4.1-.5.2z"
|
|
||||||
/><path
|
|
||||||
fill="#028BB8"
|
|
||||||
d="M18.7 71.8c.4 3.3 1.4 6.4 2.9 9.3l.8 1.5c.5.9 1.1 1.7 1.7 2.6 3 .2 5.7.3 8.2.2 4.9-.1 8.9-.7 12-1.7.5-.2.9.1 1.1.5.2.5-.1.9-.5 1.1-.4.1-.8.3-1.3.4-2.4.7-5.2 1.2-8.5 1.4h-.4c-1.3.1-2.7.1-4.1.1-1.6 0-3.2 0-4.9-.1 6 6.8 15.5 10.8 27.3 10.8 21.4 0 40-8.1 50.8-26h-85.1v-.1z"
|
|
||||||
/><path
|
|
||||||
fill="#019BC6"
|
|
||||||
d="M23.5 71.8c1.3 5.8 4.3 10.4 8.8 13.5 4.9-.1 8.9-.7 12-1.7.5-.2.9.1 1.1.5.2.5-.1.9-.5 1.1-.4.1-.8.3-1.3.4-2.4.7-5.2 1.2-8.6 1.4 8.5 4.4 20.8 4.3 34.9-1.1 8.5-3.3 16.8-8.2 24.2-14.1h-70.6z"
|
|
||||||
/><path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
fill="#00ACD3"
|
|
||||||
d="M28.4 52.7h9.8v9.8h-9.8v-9.8zm.8.8h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zM39.6 41.5h9.8v9.8h-9.8v-9.8zm.9.8h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1z"
|
|
||||||
/><path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
fill="#23C2EE"
|
|
||||||
d="M39.6 52.7h9.8v9.8h-9.8v-9.8zm.9.8h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1z"
|
|
||||||
/><path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
fill="#00ACD3"
|
|
||||||
d="M50.9 52.7h9.8v9.8h-9.8v-9.8zm.8.8h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1z"
|
|
||||||
/><path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
fill="#23C2EE"
|
|
||||||
d="M50.9 41.5h9.8v9.8h-9.8v-9.8zm.8.8h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zM62.2 52.7h9.8v9.8h-9.8v-9.8zm.8.8h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1z"
|
|
||||||
/><path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
fill="#00ACD3"
|
|
||||||
d="M62.2 41.5h9.8v9.8h-9.8v-9.8zm.8.8h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1z"
|
|
||||||
/><path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
fill="#23C2EE"
|
|
||||||
d="M62.2 30.2h9.8v9.8h-9.8v-9.8zm.8.8h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1z"
|
|
||||||
/><path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
fill="#00ACD3"
|
|
||||||
d="M73.5 52.7h9.8v9.8h-9.8v-9.8zm.8.8h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1z"
|
|
||||||
/><path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
fill="#D4EEF1"
|
|
||||||
d="M48.8 78.3c1.5 0 2.7 1.2 2.7 2.7 0 1.5-1.2 2.7-2.7 2.7-1.5 0-2.7-1.2-2.7-2.7 0-1.5 1.2-2.7 2.7-2.7"
|
|
||||||
/><path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
fill="#3A4D54"
|
|
||||||
d="M48.8 79.1c.2 0 .5 0 .7.1-.2.1-.4.4-.4.7 0 .4.4.8.8.8.3 0 .6-.2.7-.4.1.2.1.5.1.7 0 1.1-.9 1.9-1.9 1.9-1.1 0-1.9-.9-1.9-1.9 0-1 .8-1.9 1.9-1.9M1.1 72.8h125.4c-2.7-.7-8.6-1.6-7.7-5.2-5 5.7-16.9 4-20 1.2-3.4 4.9-23 3-24.3-.8-4.2 5-17.3 5-21.5 0-1.4 3.8-21 5.7-24.3.8-3 2.8-15 4.5-20-1.2 1.1 3.5-4.9 4.5-7.6 5.2"
|
|
||||||
/><path
|
|
||||||
fill="#BFDBE0"
|
|
||||||
d="M56 97.8c-6.7-3.2-10.3-7.5-12.4-12.2-2.5.7-5.5 1.2-8.9 1.4-1.3.1-2.7.1-4.1.1-1.7 0-3.4 0-5.2-.1 6 6 13.6 10.7 27.5 10.8h3.1z"
|
|
||||||
/><path
|
|
||||||
fill="#D4EEF1"
|
|
||||||
d="M46.1 89.9c-.9-1.3-1.8-2.8-2.5-4.3-2.5.7-5.5 1.2-8.9 1.4 2.3 1.2 5.7 2.4 11.4 2.9z"
|
|
||||||
/></g
|
|
||||||
>
|
|
||||||
</svg>
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class={isAbsolute ? 'w-14 h-14 absolute top-0 left-0 -m-5' : 'w-9 mx-auto'}
|
class={isAbsolute ? 'w-14 h-14 absolute top-0 left-0 -m-5' : 'w-9 h-9 mx-auto'}
|
||||||
viewBox="0 0 384 384"
|
viewBox="0 0 384 384"
|
||||||
fill="none"
|
fill="none"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<svg
|
<svg
|
||||||
viewBox="0 0 700 240"
|
viewBox="0 0 700 240"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class={isAbsolute ? 'w-36 absolute top-0 left-0 -m-3 -mt-5' : 'w-28 mx-auto'}
|
class={isAbsolute ? 'w-36 absolute top-0 left-0 -m-3 -mt-5' : 'w-28 h-28 mx-auto'}
|
||||||
><path fill="#FDBC3D" d="m90.694 107.498-.981.39-20.608 8.23 6.332 6.547z" /><path
|
><path fill="#FDBC3D" d="m90.694 107.498-.981.39-20.608 8.23 6.332 6.547z" /><path
|
||||||
fill="#8EC63F"
|
fill="#8EC63F"
|
||||||
d="M61.139 77.914 46.632 93 56.9 103.547c8.649-7.169 17.832-10.502 18.653-10.789L61.139 77.914z"
|
d="M61.139 77.914 46.632 93 56.9 103.547c8.649-7.169 17.832-10.502 18.653-10.789L61.139 77.914z"
|
||||||
|
|||||||
@@ -4,6 +4,6 @@
|
|||||||
|
|
||||||
<img
|
<img
|
||||||
alt="ghost logo"
|
alt="ghost logo"
|
||||||
class={isAbsolute ? 'w-12 absolute top-0 left-0 -m-3 -mt-5' : 'w-8 mx-auto'}
|
class={isAbsolute ? 'w-12 h-12 absolute top-0 left-0 -m-3 -mt-5' : 'w-8 h-8 mx-auto'}
|
||||||
src="/ghost.png"
|
src="/ghost.png"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svg
|
<svg
|
||||||
class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 mx-auto'}
|
class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 h-8 mx-auto'}
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
style="isolation:isolate"
|
style="isolation:isolate"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svg
|
<svg
|
||||||
class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 mx-auto'}
|
class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 h-8 mx-auto'}
|
||||||
viewBox="0 0 81 84"
|
viewBox="0 0 81 84"
|
||||||
fill="none"
|
fill="none"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 mx-auto'}
|
class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 h-8 mx-auto'}
|
||||||
fill="none"
|
fill="none"
|
||||||
viewBox="0 0 140 140"
|
viewBox="0 0 140 140"
|
||||||
data-lt-extension-installed="true"
|
data-lt-extension-installed="true"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<svg
|
<svg
|
||||||
viewBox="0 0 127 74"
|
viewBox="0 0 127 74"
|
||||||
class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 mx-auto'}
|
class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 h-8 mx-auto'}
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
><path
|
><path
|
||||||
d="M.825 73.993l23.244-59.47A21.85 21.85 0 0144.42.625h14.014L35.19 60.096a21.85 21.85 0 01-20.352 13.897H.825z"
|
d="M.825 73.993l23.244-59.47A21.85 21.85 0 0144.42.625h14.014L35.19 60.096a21.85 21.85 0 01-20.352 13.897H.825z"
|
||||||
|
|||||||
@@ -4,6 +4,6 @@
|
|||||||
|
|
||||||
<img
|
<img
|
||||||
alt="minio logo"
|
alt="minio logo"
|
||||||
class={isAbsolute ? 'w-7 absolute top-0 left-0 -m-3 -mt-5' : 'w-4 mx-auto'}
|
class={isAbsolute ? 'w-7 h-12 absolute top-0 left-0 -m-3 -mt-5' : 'w-4 h-8 mx-auto'}
|
||||||
src="/minio.png"
|
src="/minio.png"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
</script>
|
</script>
|
||||||
<img
|
<img
|
||||||
alt="moodle logo"
|
alt="moodle logo"
|
||||||
class={isAbsolute ? 'w-9 absolute top-0 left-0 -m-3 -mt-5' : 'w-8 mx-auto'}
|
class={isAbsolute ? 'w-9 h-9 absolute top-0 left-0 -m-3 -mt-5' : 'w-8 h-8 mx-auto'}
|
||||||
src="/moodle.png"
|
src="/moodle.png"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svg
|
<svg
|
||||||
class={isAbsolute ? 'w-12 h-12 absolute top-0 left-0 -m-5' : 'w-8 mx-auto'}
|
class={isAbsolute ? 'w-12 h-12 absolute top-0 left-0 -m-5' : 'w-8 h-8 mx-auto'}
|
||||||
viewBox="0 0 220 105"
|
viewBox="0 0 220 105"
|
||||||
>
|
>
|
||||||
<g>
|
<g>
|
||||||
|
|||||||
@@ -4,6 +4,6 @@
|
|||||||
|
|
||||||
<img
|
<img
|
||||||
alt="nocodb logo"
|
alt="nocodb logo"
|
||||||
class={isAbsolute ? 'w-10 absolute top-0 left-0 -m-5' : 'w-8 mx-auto'}
|
class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 h-8 mx-auto'}
|
||||||
src="/nocodb.png"
|
src="/nocodb.png"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -4,6 +4,6 @@
|
|||||||
|
|
||||||
<img
|
<img
|
||||||
alt="plausible logo"
|
alt="plausible logo"
|
||||||
class={isAbsolute ? 'w-9 absolute top-0 left-0 -m-4' : 'w-6 mx-auto'}
|
class={isAbsolute ? 'w-9 h-12 absolute top-0 left-0 -m-4' : 'w-6 h-8 mx-auto'}
|
||||||
src="/plausible.png"
|
src="/plausible.png"
|
||||||
/>
|
/>
|
||||||
|
|||||||
56
apps/ui/src/lib/components/svg/services/Searxng.svelte
Normal file
56
apps/ui/src/lib/components/svg/services/Searxng.svelte
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export let isAbsolute = false;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
id="svg8"
|
||||||
|
version="1.1"
|
||||||
|
viewBox="0 0 92 92"
|
||||||
|
class={isAbsolute ? 'w-12 h-12 absolute top-0 left-0 -m-3 -mt-5' : 'w-8 h-8 mx-auto'}
|
||||||
|
>
|
||||||
|
<defs id="defs2" />
|
||||||
|
<metadata id="metadata5">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g transform="translate(-40.921303,-17.416526)" id="layer1">
|
||||||
|
<circle
|
||||||
|
r="0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:12;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
cy="92"
|
||||||
|
cx="75"
|
||||||
|
id="path3713"
|
||||||
|
/>
|
||||||
|
<circle
|
||||||
|
r="30"
|
||||||
|
cy="53.902557"
|
||||||
|
cx="75.921303"
|
||||||
|
id="path834"
|
||||||
|
style="fill:none;fill-opacity:1;stroke:#3050ff;stroke-width:10;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="m 67.514849,37.91524 a 18,18 0 0 1 21.051475,3.312407 18,18 0 0 1 3.137312,21.078282"
|
||||||
|
id="path852"
|
||||||
|
style="fill:none;fill-opacity:1;stroke:#3050ff;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
/>
|
||||||
|
<rect
|
||||||
|
transform="rotate(-46.234709)"
|
||||||
|
ry="1.8669105e-13"
|
||||||
|
y="122.08995"
|
||||||
|
x="3.7063529"
|
||||||
|
height="39.963303"
|
||||||
|
width="18.846331"
|
||||||
|
id="rect912"
|
||||||
|
style="opacity:1;fill:#3050ff;fill-opacity:1;stroke:none;stroke-width:8;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
@@ -38,4 +38,8 @@
|
|||||||
<Icons.Moodle {isAbsolute} />
|
<Icons.Moodle {isAbsolute} />
|
||||||
{:else if type === 'glitchTip'}
|
{:else if type === 'glitchTip'}
|
||||||
<Icons.GlitchTip {isAbsolute} />
|
<Icons.GlitchTip {isAbsolute} />
|
||||||
|
{:else if type === 'searxng'}
|
||||||
|
<Icons.Searxng {isAbsolute} />
|
||||||
|
{:else if type === 'weblate'}
|
||||||
|
<Icons.Weblate {isAbsolute} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
viewBox="0 0 856.000000 856.000000"
|
viewBox="0 0 856.000000 856.000000"
|
||||||
preserveAspectRatio="xMidYMid meet"
|
preserveAspectRatio="xMidYMid meet"
|
||||||
class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 mx-auto'}
|
class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 h-8 mx-auto'}
|
||||||
>
|
>
|
||||||
<metadata> Created by potrace 1.11, written by Peter Selinger 2001-2013 </metadata>
|
<metadata> Created by potrace 1.11, written by Peter Selinger 2001-2013 </metadata>
|
||||||
<g
|
<g
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svg
|
<svg
|
||||||
class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 mx-auto'}
|
class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 h-8mx-auto'}
|
||||||
viewBox="0 0 128 128"
|
viewBox="0 0 128 128"
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svg
|
<svg
|
||||||
class={isAbsolute ? 'w-10 absolute top-0 left-0 -m-5' : 'w-8 mx-auto'}
|
class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 h-8mx-auto'}
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
version="1.1"
|
version="1.1"
|
||||||
|
|||||||
61
apps/ui/src/lib/components/svg/services/Weblate.svelte
Normal file
61
apps/ui/src/lib/components/svg/services/Weblate.svelte
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export let isAbsolute = false;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class={isAbsolute ? 'w-16 h-16 absolute top-0 left-0 -m-7' : 'w-12 h-12 mx-auto'}
|
||||||
|
version="1.1"
|
||||||
|
viewBox="0 0 300 300"
|
||||||
|
><linearGradient
|
||||||
|
id="a"
|
||||||
|
x1=".3965"
|
||||||
|
x2="98.808"
|
||||||
|
y1="55.253"
|
||||||
|
y2="55.253"
|
||||||
|
gradientTransform="scale(.98308 1.0172)"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
><stop stop-color="#00d2e6" offset="0" /><stop
|
||||||
|
stop-color="#2eccaa"
|
||||||
|
offset="1"
|
||||||
|
/></linearGradient
|
||||||
|
><linearGradient
|
||||||
|
id="b"
|
||||||
|
x1="49.017"
|
||||||
|
x2="99.793"
|
||||||
|
y1="137.89"
|
||||||
|
y2="113.96"
|
||||||
|
gradientTransform="scale(1.1631 .8598)"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
><stop stop-opacity="0" offset="0" /><stop offset=".51413" /><stop
|
||||||
|
stop-opacity="0"
|
||||||
|
offset="1"
|
||||||
|
/></linearGradient
|
||||||
|
><linearGradient
|
||||||
|
id="c"
|
||||||
|
x1="201.82"
|
||||||
|
x2="103.58"
|
||||||
|
y1="57.649"
|
||||||
|
y2="57.649"
|
||||||
|
gradientTransform="scale(.98308 1.0172)"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
><stop stop-color="#1fa385" offset="0" /><stop
|
||||||
|
stop-color="#2eccaa"
|
||||||
|
offset="1"
|
||||||
|
/></linearGradient
|
||||||
|
><g transform="translate(50,76)" fill-rule="evenodd"
|
||||||
|
><path
|
||||||
|
d="m127.25 111.61c-2.8884-0.0145-5.7666-0.6024-8.4797-1.7847-6.1117-2.6626-11.493-7.6912-15.872-14.495 1.2486-2.2193 2.3738-4.5173 3.3784-6.8535 4.4051-10.243 6.5-21.46 6.6607-32.593-0.0233-0.22082-0.0416-0.44244-0.0552-0.66483l-0.0121-0.57132c-0.01-4.3654-0.67459-8.7898-2.1767-12.909-1.7304-4.7458-4.4887-9.4955-8.865-11.348-0.79519-0.33595-1.6316-0.47701-2.4642-0.45737-5.5049-10.289-5.6799-20.149 0-29.537 0.10115 0 0.20619 3.9293e-4 0.30734 0.001179 6.7012 0.07387 13.34 2.1418 19.021 5.7536 15.469 9.835 23.182 29.001 23.352 47.818 2e-3 0.22083-3.9e-4 0.44126-7e-3 0.66169h0.0868c-0.0226 19.887-4.8049 40.054-14.875 56.979zm-34.3 31.216c-14.448 5.9425-31.228 5.6236-45.549-1.025-16.476-7.6476-29.065-22.512-36.818-39.479-13.262-29.022-13.566-63.715-0.98815-93.182 9.4458 3.7788 17.845-2.2397 17.845-2.2397s-0.01945 9.2605 8.9478 13.905c-9.2007 21.556-8.979 47.167 0.2412 68.173 4.4389 10.107 11.22 19.519 20.619 24.842 3.3547 1.8996 7.041 3.126 10.833 3.5862 0.01404 0.0219 0.02808 0.0439 0.04214 0.0658 6.6965 10.449 15.132 19.157 24.828 25.354z"
|
||||||
|
fill="url(#a)"
|
||||||
|
fill-rule="nonzero"
|
||||||
|
/><path
|
||||||
|
d="m127.24 111.61c-2.8869-0.0151-5.7636-0.60296-8.4755-1.7846-6.1127-2.663-11.495-7.6928-15.874-14.498 1.2494-2.2205 2.3754-4.5198 3.3806-6.8572 1.3282-3.0884 2.4463-6.2648 3.3644-9.501 2.128-7.4978 30.382 2.0181 26.072 14.371-2.2239 6.373-5.0394 12.509-8.4675 18.27zm-34.302 31.212c-14.446 5.9396-31.224 5.6198-45.543-1.0278-16.476-7.6476 0.44739-33.303 9.8465-27.981 3.3533 1.8988 7.0378 3.125 10.828 3.5856 0.01567 0.0245 0.03135 0.049 0.04704 0.0735 6.695 10.447 15.128 19.153 24.821 25.349z"
|
||||||
|
fill="url(#b)"
|
||||||
|
opacity=".3"
|
||||||
|
/><path
|
||||||
|
d="m56.762 54.628c-0.0066-0.22043-0.0093-0.44086-7e-3 -0.66169 0.17001-18.817 7.8827-37.983 23.352-47.818 5.6811-3.6118 12.32-5.6798 19.021-5.7536 0.10115-7.8585e-4 0.20619-0.001179 0.30734-0.001179v29.537c-0.83254-0.01965-1.669 0.12141-2.4642 0.45737-4.3763 1.8523-7.1345 6.602-8.865 11.348-1.5021 4.1191-2.1669 8.5434-2.1767 12.909l-0.01206 0.57132c-0.01362 0.2224-0.0319 0.44401-0.05524 0.66483 0.16067 11.134 2.2556 22.35 6.6607 32.593 4.9334 11.472 12.775 22.025 23.847 26.849 8.3526 3.6397 17.612 2.7811 25.182-1.5057 9.3991-5.3226 16.18-14.734 20.619-24.842 9.2202-21.006 9.4419-46.617 0.24121-68.173 8.9673-4.6444 8.9478-13.905 8.9478-13.905s8.3993 6.0185 17.845 2.2397c12.578 29.466 12.274 64.16-0.98815 93.182-7.7535 16.967-20.343 31.831-36.818 39.479-14.667 6.809-31.913 6.9792-46.591 0.58389-13.19-5.7489-23.918-16.106-31.637-28.15-11.179-17.443-16.472-38.678-16.496-59.604z"
|
||||||
|
fill="url(#c)"
|
||||||
|
fill-rule="nonzero"
|
||||||
|
/></g
|
||||||
|
></svg
|
||||||
|
>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
export let isAbsolute = false;
|
export let isAbsolute = false;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svg class={isAbsolute ? 'w-10 absolute top-0 left-0 -m-5' : 'w-8 mx-auto'} viewBox="0 0 128 128">
|
<svg class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 h-8mx-auto'} viewBox="0 0 128 128">
|
||||||
<path
|
<path
|
||||||
fill-rule="evenodd"
|
fill-rule="evenodd"
|
||||||
clip-rule="evenodd"
|
clip-rule="evenodd"
|
||||||
|
|||||||
@@ -16,3 +16,5 @@ export { default as Fider } from './Fider.svelte';
|
|||||||
export { default as Appwrite } from './Appwrite.svelte';
|
export { default as Appwrite } from './Appwrite.svelte';
|
||||||
export { default as Moodle } from './Moodle.svelte';
|
export { default as Moodle } from './Moodle.svelte';
|
||||||
export { default as GlitchTip } from './GlitchTip.svelte';
|
export { default as GlitchTip } from './GlitchTip.svelte';
|
||||||
|
export { default as Searxng } from './Searxng.svelte';
|
||||||
|
export { default as Weblate } from './Weblate.svelte';
|
||||||
@@ -209,7 +209,7 @@
|
|||||||
"expose_a_port": "Expose a port",
|
"expose_a_port": "Expose a port",
|
||||||
"enable_preview_deploy_mr_pr_requests": "Enable preview deployments from pull or merge requests.",
|
"enable_preview_deploy_mr_pr_requests": "Enable preview deployments from pull or merge requests.",
|
||||||
"debug_logs": "Debug Logs",
|
"debug_logs": "Debug Logs",
|
||||||
"enable_debug_log_during_build": "Enable debug logs during build phase.<br><span class='text-red-500 font-bold'>Sensitive information</span> could be visible and saved in logs.",
|
"enable_debug_log_during_build": "Enable debug logs during build phase.<br><span class='text-settings font-bold'>Sensitive information</span> could be visible and saved in logs.",
|
||||||
"cant_activate_auto_deploy_without_repo": "Cannot activate automatic deployments until only one application is defined for this repository / branch.",
|
"cant_activate_auto_deploy_without_repo": "Cannot activate automatic deployments until only one application is defined for this repository / branch.",
|
||||||
"no_applications_found": "No applications found",
|
"no_applications_found": "No applications found",
|
||||||
"secret__batch_dot_env": "Paste .env file",
|
"secret__batch_dot_env": "Paste .env file",
|
||||||
@@ -275,7 +275,7 @@
|
|||||||
"application_id": "Application ID",
|
"application_id": "Application ID",
|
||||||
"group_name": "Group Name",
|
"group_name": "Group Name",
|
||||||
"oauth_id": "OAuth ID",
|
"oauth_id": "OAuth ID",
|
||||||
"oauth_id_explainer": "The OAuth ID is the unique identifier of the GitLab application. <br>You can find it <span class='font-bold text-orange-600' >in the URL</span> of your GitLab OAuth Application.",
|
"oauth_id_explainer": "The OAuth ID is the unique identifier of the GitLab application. <br>You can find it <span class='font-bold text-settings' >in the URL</span> of your GitLab OAuth Application.",
|
||||||
"register_oauth_gitlab": "Register new OAuth application on GitLab",
|
"register_oauth_gitlab": "Register new OAuth application on GitLab",
|
||||||
"gitlab": {
|
"gitlab": {
|
||||||
"self_hosted": "Instance-wide application (self-hosted)",
|
"self_hosted": "Instance-wide application (self-hosted)",
|
||||||
@@ -306,7 +306,7 @@
|
|||||||
"change_language": "Change Language",
|
"change_language": "Change Language",
|
||||||
"permission_denied": "You do not have permission to do this. \\nAsk an admin to modify your permissions.",
|
"permission_denied": "You do not have permission to do this. \\nAsk an admin to modify your permissions.",
|
||||||
"domain_removed": "Domain removed",
|
"domain_removed": "Domain removed",
|
||||||
"ssl_explainer": "If you specify <span class='text-settings font-bold'>https</span>, Coolify will be accessible only over https. SSL certificate will be generated for you.<br>If you specify <span class='text-settings font-bold'>www</span>, Coolify will be redirected (302) from non-www and vice versa.<br><br><span class='text-settings font-bold'>WARNING:</span> If you change an already set domain, it will brake webhooks and other integrations! You need to manually update them.",
|
"ssl_explainer": "If you specify <span class='text-settings font-bold'>https</span>, Coolify will be accessible only over https. SSL certificate will be generated for you.<br>If you specify <span class='text-settings font-bold'>www</span>, Coolify will be redirected (302) from non-www and vice versa.<br><br><span class='text-settings font-bold'>WARNING:</span> If you change an already set domain, it will break webhooks and other integrations! You need to manually update them.",
|
||||||
"must_remove_domain_before_changing": "Must remove the domain before you can change this setting.",
|
"must_remove_domain_before_changing": "Must remove the domain before you can change this setting.",
|
||||||
"registration_allowed": "Registration allowed?",
|
"registration_allowed": "Registration allowed?",
|
||||||
"registration_allowed_explainer": "Allow further registrations to the application. <br>It's turned off after the first registration.",
|
"registration_allowed_explainer": "Allow further registrations to the application. <br>It's turned off after the first registration.",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import cuid from 'cuid';
|
|||||||
import { writable, readable, type Writable } from 'svelte/store';
|
import { writable, readable, type Writable } from 'svelte/store';
|
||||||
|
|
||||||
interface AppSession {
|
interface AppSession {
|
||||||
|
registrationEnabled: boolean;
|
||||||
ipv4: string | null,
|
ipv4: string | null,
|
||||||
ipv6: string | null,
|
ipv6: string | null,
|
||||||
version: string | null,
|
version: string | null,
|
||||||
@@ -17,7 +18,8 @@ interface AppSession {
|
|||||||
tokens: {
|
tokens: {
|
||||||
github: string | null,
|
github: string | null,
|
||||||
gitlab: string | null,
|
gitlab: string | null,
|
||||||
}
|
},
|
||||||
|
supportedServiceTypesAndVersions: Array<any>
|
||||||
}
|
}
|
||||||
interface AddToast {
|
interface AddToast {
|
||||||
type?: "info" | "success" | "error",
|
type?: "info" | "success" | "error",
|
||||||
@@ -40,9 +42,30 @@ export const appSession: Writable<AppSession> = writable({
|
|||||||
tokens: {
|
tokens: {
|
||||||
github: null,
|
github: null,
|
||||||
gitlab: null
|
gitlab: null
|
||||||
}
|
},
|
||||||
|
supportedServiceTypesAndVersions: []
|
||||||
});
|
});
|
||||||
export const disabledButton: Writable<boolean> = writable(false);
|
export const disabledButton: Writable<boolean> = writable(false);
|
||||||
|
export const isDeploymentEnabled: Writable<boolean> = writable(false);
|
||||||
|
export function checkIfDeploymentEnabledApplications(isAdmin: boolean, application: any) {
|
||||||
|
return (
|
||||||
|
isAdmin &&
|
||||||
|
(application.fqdn || application.settings.isBot) &&
|
||||||
|
application.gitSource &&
|
||||||
|
application.repository &&
|
||||||
|
application.destinationDocker &&
|
||||||
|
application.buildPack
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export function checkIfDeploymentEnabledServices(isAdmin: boolean, service: any) {
|
||||||
|
return (
|
||||||
|
isAdmin &&
|
||||||
|
service.fqdn &&
|
||||||
|
service.destinationDocker &&
|
||||||
|
service.version &&
|
||||||
|
service.type
|
||||||
|
);
|
||||||
|
}
|
||||||
export const status: Writable<any> = writable({
|
export const status: Writable<any> = writable({
|
||||||
application: {
|
application: {
|
||||||
isRunning: false,
|
isRunning: false,
|
||||||
|
|||||||
@@ -65,11 +65,14 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let baseSettings: any;
|
export let baseSettings: any;
|
||||||
|
export let supportedServiceTypesAndVersions: any;
|
||||||
|
$appSession.registrationEnabled = baseSettings.registrationEnabled;
|
||||||
$appSession.ipv4 = baseSettings.ipv4;
|
$appSession.ipv4 = baseSettings.ipv4;
|
||||||
$appSession.ipv6 = baseSettings.ipv6;
|
$appSession.ipv6 = baseSettings.ipv6;
|
||||||
$appSession.version = baseSettings.version;
|
$appSession.version = baseSettings.version;
|
||||||
$appSession.whiteLabeled = baseSettings.whiteLabeled;
|
$appSession.whiteLabeled = baseSettings.whiteLabeled;
|
||||||
$appSession.whiteLabeledDetails.icon = baseSettings.whiteLabeledIcon;
|
$appSession.whiteLabeledDetails.icon = baseSettings.whiteLabeledIcon;
|
||||||
|
$appSession.supportedServiceTypesAndVersions = supportedServiceTypesAndVersions;
|
||||||
|
|
||||||
export let userId: string;
|
export let userId: string;
|
||||||
export let teamId: string;
|
export let teamId: string;
|
||||||
@@ -86,6 +89,7 @@
|
|||||||
import { errorNotification } from '$lib/common';
|
import { errorNotification } from '$lib/common';
|
||||||
import { appSession } from '$lib/store';
|
import { appSession } from '$lib/store';
|
||||||
import Toasts from '$lib/components/Toasts.svelte';
|
import Toasts from '$lib/components/Toasts.svelte';
|
||||||
|
import Tooltip from '$lib/components/Tooltip.svelte';
|
||||||
|
|
||||||
if (userId) $appSession.userId = userId;
|
if (userId) $appSession.userId = userId;
|
||||||
if (teamId) $appSession.teamId = teamId;
|
if (teamId) $appSession.teamId = teamId;
|
||||||
@@ -120,20 +124,26 @@
|
|||||||
<nav class="nav-main">
|
<nav class="nav-main">
|
||||||
<div class="flex h-screen w-full flex-col items-center transition-all duration-100">
|
<div class="flex h-screen w-full flex-col items-center transition-all duration-100">
|
||||||
{#if !$appSession.whiteLabeled}
|
{#if !$appSession.whiteLabeled}
|
||||||
<div class="my-4 h-10 w-10"><img src="/favicon.png" alt="coolLabs logo" /></div>
|
<div class="mb-2 mt-4 h-10 w-10">
|
||||||
|
<img src="/favicon.png" alt="coolLabs logo" />
|
||||||
|
</div>
|
||||||
|
{:else if $appSession.whiteLabeledDetails.icon}
|
||||||
|
<div class="mb-2 mt-4 h-10 w-10">
|
||||||
|
<img src={$appSession.whiteLabeledDetails.icon} alt="White labeled logo" />
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="flex flex-col space-y-2 py-2" class:mt-2={$appSession.whiteLabeled}>
|
<div class="flex flex-col space-y-2 py-2" class:mt-2={$appSession.whiteLabeled}>
|
||||||
<a
|
<a
|
||||||
|
id="dashboard"
|
||||||
sveltekit:prefetch
|
sveltekit:prefetch
|
||||||
href="/"
|
href="/"
|
||||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200 hover:text-white"
|
class="icons bg-coolgray-200 hover:text-white"
|
||||||
class:text-white={$page.url.pathname === '/'}
|
class:text-white={$page.url.pathname === '/'}
|
||||||
class:bg-coolgray-500={$page.url.pathname === '/'}
|
class:bg-coolgray-500={$page.url.pathname === '/'}
|
||||||
data-tip="Dashboard"
|
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class="h-8 w-8"
|
class="h-9 w-9"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
stroke-width="1.5"
|
stroke-width="1.5"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
@@ -148,12 +158,13 @@
|
|||||||
<path d="M16 15c-2.21 1.333 -5.792 1.333 -8 0" />
|
<path d="M16 15c-2.21 1.333 -5.792 1.333 -8 0" />
|
||||||
</svg>
|
</svg>
|
||||||
</a>
|
</a>
|
||||||
<div class="border-t border-stone-700" />
|
|
||||||
|
|
||||||
|
<div class="border-t border-stone-700" />
|
||||||
<a
|
<a
|
||||||
|
id="applications"
|
||||||
sveltekit:prefetch
|
sveltekit:prefetch
|
||||||
href="/applications"
|
href="/applications"
|
||||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200"
|
class="icons bg-coolgray-200"
|
||||||
class:text-applications={$page.url.pathname.startsWith('/applications') ||
|
class:text-applications={$page.url.pathname.startsWith('/applications') ||
|
||||||
$page.url.pathname.startsWith('/new/application')}
|
$page.url.pathname.startsWith('/new/application')}
|
||||||
class:bg-coolgray-500={$page.url.pathname.startsWith('/applications') ||
|
class:bg-coolgray-500={$page.url.pathname.startsWith('/applications') ||
|
||||||
@@ -162,7 +173,7 @@
|
|||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class="h-8 w-8"
|
class="h-9 w-9"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
stroke-width="1.5"
|
stroke-width="1.5"
|
||||||
stroke="currentcolor"
|
stroke="currentcolor"
|
||||||
@@ -178,10 +189,12 @@
|
|||||||
<line x1="17" y1="4" x2="17" y2="10" />
|
<line x1="17" y1="4" x2="17" y2="10" />
|
||||||
</svg>
|
</svg>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
|
id="sources"
|
||||||
sveltekit:prefetch
|
sveltekit:prefetch
|
||||||
href="/sources"
|
href="/sources"
|
||||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200"
|
class="icons bg-coolgray-200"
|
||||||
class:text-sources={$page.url.pathname.startsWith('/sources') ||
|
class:text-sources={$page.url.pathname.startsWith('/sources') ||
|
||||||
$page.url.pathname.startsWith('/new/source')}
|
$page.url.pathname.startsWith('/new/source')}
|
||||||
class:bg-coolgray-500={$page.url.pathname.startsWith('/sources') ||
|
class:bg-coolgray-500={$page.url.pathname.startsWith('/sources') ||
|
||||||
@@ -190,7 +203,7 @@
|
|||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class="h-8 w-8"
|
class="h-9 w-9"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
stroke-width="1.5"
|
stroke-width="1.5"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
@@ -208,9 +221,10 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
|
id="destinations"
|
||||||
sveltekit:prefetch
|
sveltekit:prefetch
|
||||||
href="/destinations"
|
href="/destinations"
|
||||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200"
|
class="icons bg-coolgray-200"
|
||||||
class:text-destinations={$page.url.pathname.startsWith('/destinations') ||
|
class:text-destinations={$page.url.pathname.startsWith('/destinations') ||
|
||||||
$page.url.pathname.startsWith('/new/destination')}
|
$page.url.pathname.startsWith('/new/destination')}
|
||||||
class:bg-coolgray-500={$page.url.pathname.startsWith('/destinations') ||
|
class:bg-coolgray-500={$page.url.pathname.startsWith('/destinations') ||
|
||||||
@@ -219,7 +233,7 @@
|
|||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class="h-8 w-8"
|
class="h-9 w-9"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
stroke-width="1.5"
|
stroke-width="1.5"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
@@ -243,9 +257,10 @@
|
|||||||
</a>
|
</a>
|
||||||
<div class="border-t border-stone-700" />
|
<div class="border-t border-stone-700" />
|
||||||
<a
|
<a
|
||||||
|
id="databases"
|
||||||
sveltekit:prefetch
|
sveltekit:prefetch
|
||||||
href="/databases"
|
href="/databases"
|
||||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200"
|
class="icons bg-coolgray-200"
|
||||||
class:text-databases={$page.url.pathname.startsWith('/databases') ||
|
class:text-databases={$page.url.pathname.startsWith('/databases') ||
|
||||||
$page.url.pathname.startsWith('/new/database')}
|
$page.url.pathname.startsWith('/new/database')}
|
||||||
class:bg-coolgray-500={$page.url.pathname.startsWith('/databases') ||
|
class:bg-coolgray-500={$page.url.pathname.startsWith('/databases') ||
|
||||||
@@ -254,7 +269,7 @@
|
|||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class="h-8 w-8"
|
class="h-9 w-9"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
stroke-width="1.5"
|
stroke-width="1.5"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
@@ -269,9 +284,10 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
|
id="services"
|
||||||
sveltekit:prefetch
|
sveltekit:prefetch
|
||||||
href="/services"
|
href="/services"
|
||||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200"
|
class="icons bg-coolgray-200"
|
||||||
class:text-services={$page.url.pathname.startsWith('/services') ||
|
class:text-services={$page.url.pathname.startsWith('/services') ||
|
||||||
$page.url.pathname.startsWith('/new/service')}
|
$page.url.pathname.startsWith('/new/service')}
|
||||||
class:bg-coolgray-500={$page.url.pathname.startsWith('/services') ||
|
class:bg-coolgray-500={$page.url.pathname.startsWith('/services') ||
|
||||||
@@ -280,7 +296,7 @@
|
|||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class="h-8 w-8"
|
class="h-9 w-9"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
stroke-width="1.5"
|
stroke-width="1.5"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
@@ -298,16 +314,16 @@
|
|||||||
<UpdateAvailable />
|
<UpdateAvailable />
|
||||||
<div class="flex flex-col space-y-2 py-2">
|
<div class="flex flex-col space-y-2 py-2">
|
||||||
<a
|
<a
|
||||||
|
id="iam"
|
||||||
sveltekit:prefetch
|
sveltekit:prefetch
|
||||||
href="/iam"
|
href="/iam"
|
||||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200"
|
class="icons bg-coolgray-200"
|
||||||
class:text-iam={$page.url.pathname.startsWith('/iam')}
|
class:text-iam={$page.url.pathname.startsWith('/iam')}
|
||||||
class:bg-coolgray-500={$page.url.pathname.startsWith('/iam')}
|
class:bg-coolgray-500={$page.url.pathname.startsWith('/iam')}
|
||||||
data-tip="IAM"
|
|
||||||
><svg
|
><svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class="h-8 w-8"
|
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
|
class="h-9 w-9"
|
||||||
stroke-width="1.5"
|
stroke-width="1.5"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
fill="none"
|
fill="none"
|
||||||
@@ -322,17 +338,17 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
|
id="settings"
|
||||||
sveltekit:prefetch
|
sveltekit:prefetch
|
||||||
href={$appSession.teamId === '0' ? '/settings/global' : '/settings/ssh-keys'}
|
href={$appSession.teamId === '0' ? '/settings/global' : '/settings/ssh-keys'}
|
||||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200"
|
class="icons bg-coolgray-200"
|
||||||
class:text-settings={$page.url.pathname.startsWith('/settings')}
|
class:text-settings={$page.url.pathname.startsWith('/settings')}
|
||||||
class:bg-coolgray-500={$page.url.pathname.startsWith('/settings')}
|
class:bg-coolgray-500={$page.url.pathname.startsWith('/settings')}
|
||||||
data-tip="Settings"
|
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class="h-8 w-8"
|
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
|
class="h-9 w-9"
|
||||||
stroke-width="1.5"
|
stroke-width="1.5"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
fill="none"
|
fill="none"
|
||||||
@@ -348,13 +364,13 @@
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200 hover:text-error"
|
id="logout"
|
||||||
data-tip="Logout"
|
class="icons bg-coolgray-200 hover:text-error"
|
||||||
on:click={logout}
|
on:click={logout}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class="ml-1 h-7 w-7"
|
class="ml-1 h-8 w-8"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
stroke-width="1.5"
|
stroke-width="1.5"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
@@ -388,5 +404,20 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
<main>
|
<main>
|
||||||
<slot />
|
<div class={$appSession.userId ? 'pl-14 lg:px-20' : null}>
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
<Tooltip triggeredBy="#dashboard" placement="right">Dashboard</Tooltip>
|
||||||
|
<Tooltip triggeredBy="#applications" placement="right" color="bg-applications">Applications</Tooltip
|
||||||
|
>
|
||||||
|
<Tooltip triggeredBy="#sources" placement="right" color="bg-sources">Git Sources</Tooltip>
|
||||||
|
<Tooltip triggeredBy="#destinations" placement="right" color="bg-destinations">Destinations</Tooltip
|
||||||
|
>
|
||||||
|
<Tooltip triggeredBy="#databases" placement="right" color="bg-databases">Databases</Tooltip>
|
||||||
|
<Tooltip triggeredBy="#services" placement="right" color="bg-services">Services</Tooltip>
|
||||||
|
<Tooltip triggeredBy="#iam" placement="right" color="bg-iam">IAM</Tooltip>
|
||||||
|
<Tooltip triggeredBy="#settings" placement="right" color="bg-settings text-black">Settings</Tooltip
|
||||||
|
>
|
||||||
|
<Tooltip triggeredBy="#logout" placement="right" color="bg-red-600">Logout</Tooltip>
|
||||||
|
|||||||
@@ -57,14 +57,14 @@
|
|||||||
message: 'Secret added.',
|
message: 'Secret added.',
|
||||||
type: 'success'
|
type: 'success'
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
addToast({
|
addToast({
|
||||||
message: 'Secret updated.',
|
message: 'Secret updated.',
|
||||||
type: 'success'
|
type: 'success'
|
||||||
});
|
});
|
||||||
|
}
|
||||||
dispatch('refresh');
|
dispatch('refresh');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
return errorNotification(error);
|
return errorNotification(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import Explainer from '$lib/components/Explainer.svelte';
|
|
||||||
|
|
||||||
export let setting: any;
|
|
||||||
export let title: any;
|
|
||||||
export let description: any;
|
|
||||||
export let isCenter = true;
|
|
||||||
export let disabled = false;
|
|
||||||
export let dataTooltip: any = null;
|
|
||||||
export let loading = false;
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="flex items-center py-4 pr-8">
|
|
||||||
<div class="flex w-96 flex-col">
|
|
||||||
<div class="text-xs font-bold text-stone-100 md:text-base">{title}</div>
|
|
||||||
<Explainer text={description} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class:tooltip={dataTooltip}
|
|
||||||
class:text-center={isCenter}
|
|
||||||
data-tip={dataTooltip}
|
|
||||||
class="flex justify-center"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
on:click
|
|
||||||
aria-pressed="false"
|
|
||||||
class="relative mx-20 inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out"
|
|
||||||
class:opacity-50={disabled || loading}
|
|
||||||
class:bg-green-600={!loading && setting}
|
|
||||||
class:bg-stone-700={!loading && !setting}
|
|
||||||
class:bg-yellow-500={loading}
|
|
||||||
>
|
|
||||||
<span class="sr-only">Use setting</span>
|
|
||||||
<span
|
|
||||||
class="pointer-events-none relative inline-block h-5 w-5 transform rounded-full bg-white shadow transition duration-200 ease-in-out"
|
|
||||||
class:translate-x-5={setting}
|
|
||||||
class:translate-x-0={!setting}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class=" absolute inset-0 flex h-full w-full items-center justify-center transition-opacity duration-200 ease-in"
|
|
||||||
class:opacity-0={setting}
|
|
||||||
class:opacity-100={!setting}
|
|
||||||
class:animate-spin={loading}
|
|
||||||
aria-hidden="true"
|
|
||||||
>
|
|
||||||
<svg class="h-3 w-3 bg-white text-red-600" fill="none" viewBox="0 0 12 12">
|
|
||||||
<path
|
|
||||||
d="M4 8l2-2m0 0l2-2M6 6L4 4m2 2l2 2"
|
|
||||||
stroke="currentColor"
|
|
||||||
stroke-width="2"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="absolute inset-0 flex h-full w-full items-center justify-center transition-opacity duration-100 ease-out"
|
|
||||||
aria-hidden="true"
|
|
||||||
class:opacity-100={setting}
|
|
||||||
class:opacity-0={!setting}
|
|
||||||
class:animate-spin={loading}
|
|
||||||
>
|
|
||||||
<svg class="h-3 w-3 bg-white text-green-600" fill="currentColor" viewBox="0 0 12 12">
|
|
||||||
<path
|
|
||||||
d="M3.707 5.293a1 1 0 00-1.414 1.414l1.414-1.414zM5 8l-.707.707a1 1 0 001.414 0L5 8zm4.707-3.293a1 1 0 00-1.414-1.414l1.414 1.414zm-7.414 2l2 2 1.414-1.414-2-2-1.414 1.414zm3.414 2l4-4-1.414-1.414-4 4 1.414 1.414z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -60,26 +60,31 @@
|
|||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { onDestroy, onMount } from 'svelte';
|
import { onDestroy, onMount } from 'svelte';
|
||||||
import { t } from '$lib/translations';
|
import { t } from '$lib/translations';
|
||||||
import { appSession, disabledButton, status, location, setLocation, addToast } from '$lib/store';
|
import {
|
||||||
|
appSession,
|
||||||
|
status,
|
||||||
|
location,
|
||||||
|
setLocation,
|
||||||
|
addToast,
|
||||||
|
isDeploymentEnabled,
|
||||||
|
checkIfDeploymentEnabledApplications
|
||||||
|
} from '$lib/store';
|
||||||
import { errorNotification, handlerNotFoundLoad } from '$lib/common';
|
import { errorNotification, handlerNotFoundLoad } from '$lib/common';
|
||||||
import Loading from '$lib/components/Loading.svelte';
|
import Tooltip from '$lib/components/Tooltip.svelte';
|
||||||
|
|
||||||
let loading = false;
|
|
||||||
let statusInterval: any;
|
let statusInterval: any;
|
||||||
let isQueueActive = false;
|
let forceDelete = false;
|
||||||
$disabledButton =
|
|
||||||
!$appSession.isAdmin ||
|
|
||||||
(!application.fqdn && !application.settings.isBot) ||
|
|
||||||
!application.gitSource ||
|
|
||||||
!application.repository ||
|
|
||||||
!application.destinationDocker ||
|
|
||||||
!application.buildPack;
|
|
||||||
|
|
||||||
const { id } = $page.params;
|
const { id } = $page.params;
|
||||||
|
|
||||||
|
$isDeploymentEnabled = checkIfDeploymentEnabledApplications($appSession.isAdmin, application);
|
||||||
|
|
||||||
async function handleDeploySubmit(forceRebuild = false) {
|
async function handleDeploySubmit(forceRebuild = false) {
|
||||||
|
if (!$isDeploymentEnabled) return;
|
||||||
try {
|
try {
|
||||||
const { buildId } = await post(`/applications/${id}/deploy`, { ...application, forceRebuild });
|
const { buildId } = await post(`/applications/${id}/deploy`, {
|
||||||
|
...application,
|
||||||
|
forceRebuild
|
||||||
|
});
|
||||||
addToast({
|
addToast({
|
||||||
message: $t('application.deployment_queued'),
|
message: $t('application.deployment_queued'),
|
||||||
type: 'success'
|
type: 'success'
|
||||||
@@ -96,32 +101,57 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteApplication(name: string) {
|
async function deleteApplication(name: string, force: boolean) {
|
||||||
const sure = confirm($t('application.confirm_to_delete', { name }));
|
const sure = confirm($t('application.confirm_to_delete', { name }));
|
||||||
if (sure) {
|
if (sure) {
|
||||||
loading = true;
|
$status.application.initialLoading = true;
|
||||||
try {
|
try {
|
||||||
await del(`/applications/${id}`, { id });
|
await del(`/applications/${id}`, { id, force });
|
||||||
return await goto(`/applications`);
|
return await goto(`/applications`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error.message.startsWith(`Command failed: SSH_AUTH_SOCK=/tmp/coolify-ssh-agent.pid`)) {
|
||||||
|
forceDelete = true;
|
||||||
|
}
|
||||||
return errorNotification(error);
|
return errorNotification(error);
|
||||||
|
} finally {
|
||||||
|
$status.application.initialLoading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
async function restartApplication() {
|
||||||
|
try {
|
||||||
|
$status.application.initialLoading = true;
|
||||||
|
$status.application.loading = true;
|
||||||
|
await post(`/applications/${id}/restart`, {});
|
||||||
|
addToast({
|
||||||
|
type: 'success',
|
||||||
|
message: 'Restart successful.'
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return errorNotification(error);
|
||||||
|
} finally {
|
||||||
|
$status.application.initialLoading = false;
|
||||||
|
$status.application.loading = false;
|
||||||
|
await getStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
async function stopApplication() {
|
async function stopApplication() {
|
||||||
try {
|
try {
|
||||||
loading = true;
|
$status.application.initialLoading = true;
|
||||||
|
// $status.application.loading = true;
|
||||||
await post(`/applications/${id}/stop`, {});
|
await post(`/applications/${id}/stop`, {});
|
||||||
return window.location.reload();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return errorNotification(error);
|
return errorNotification(error);
|
||||||
|
} finally {
|
||||||
|
$status.application.initialLoading = false;
|
||||||
|
// $status.application.loading = false;
|
||||||
|
await getStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function getStatus() {
|
async function getStatus() {
|
||||||
if ($status.application.loading) return;
|
if ($status.application.loading) return;
|
||||||
$status.application.loading = true;
|
$status.application.loading = true;
|
||||||
const data = await get(`/applications/${id}/status`);
|
const data = await get(`/applications/${id}/status`);
|
||||||
isQueueActive = data.isQueueActive;
|
|
||||||
$status.application.isRunning = data.isRunning;
|
$status.application.isRunning = data.isRunning;
|
||||||
$status.application.isExited = data.isExited;
|
$status.application.isExited = data.isExited;
|
||||||
$status.application.loading = false;
|
$status.application.loading = false;
|
||||||
@@ -130,7 +160,11 @@
|
|||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
$status.application.initialLoading = true;
|
$status.application.initialLoading = true;
|
||||||
|
$status.application.isRunning = false;
|
||||||
|
$status.application.isExited = false;
|
||||||
|
$status.application.loading = false;
|
||||||
$location = null;
|
$location = null;
|
||||||
|
$isDeploymentEnabled = false;
|
||||||
clearInterval(statusInterval);
|
clearInterval(statusInterval);
|
||||||
});
|
});
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
@@ -154,374 +188,401 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav class="nav-side">
|
<nav class="nav-side">
|
||||||
{#if loading}
|
{#if $location}
|
||||||
<Loading fullscreen cover />
|
<a
|
||||||
{:else}
|
id="open"
|
||||||
{#if $location}
|
href={$location}
|
||||||
<a
|
target="_blank"
|
||||||
href={$location}
|
class="icons flex items-center bg-transparent text-sm"
|
||||||
target="_blank"
|
><svg
|
||||||
class="icons tooltip-bottom flex items-center bg-transparent text-sm"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
><svg
|
class="h-6 w-6"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
viewBox="0 0 24 24"
|
||||||
class="h-6 w-6"
|
stroke-width="1.5"
|
||||||
viewBox="0 0 24 24"
|
stroke="currentColor"
|
||||||
stroke-width="1.5"
|
fill="none"
|
||||||
stroke="currentColor"
|
stroke-linecap="round"
|
||||||
fill="none"
|
stroke-linejoin="round"
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
>
|
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
||||||
<path d="M11 7h-5a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-5" />
|
|
||||||
<line x1="10" y1="14" x2="20" y2="4" />
|
|
||||||
<polyline points="15 4 20 4 20 9" />
|
|
||||||
</svg></a
|
|
||||||
>
|
>
|
||||||
<div class="border border-coolgray-500 h-8" />
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<path d="M11 7h-5a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-5" />
|
||||||
{/if}
|
<line x1="10" y1="14" x2="20" y2="4" />
|
||||||
|
<polyline points="15 4 20 4 20 9" />
|
||||||
{#if $status.application.isExited}
|
</svg></a
|
||||||
<a
|
>
|
||||||
href={!$disabledButton ? `/applications/${id}/logs` : null}
|
<Tooltip triggeredBy="#open">Open</Tooltip>
|
||||||
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm flex items-center text-error"
|
|
||||||
data-tip="Application exited with an error!"
|
|
||||||
sveltekit:prefetch
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
class="w-6 h-6"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke-width="1.5"
|
|
||||||
stroke="currentcolor"
|
|
||||||
fill="none"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
>
|
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
||||||
<path
|
|
||||||
d="M8.7 3h6.6c.3 0 .5 .1 .7 .3l4.7 4.7c.2 .2 .3 .4 .3 .7v6.6c0 .3 -.1 .5 -.3 .7l-4.7 4.7c-.2 .2 -.4 .3 -.7 .3h-6.6c-.3 0 -.5 -.1 -.7 -.3l-4.7 -4.7c-.2 -.2 -.3 -.4 -.3 -.7v-6.6c0 -.3 .1 -.5 .3 -.7l4.7 -4.7c.2 -.2 .4 -.3 .7 -.3z"
|
|
||||||
/>
|
|
||||||
<line x1="12" y1="8" x2="12" y2="12" />
|
|
||||||
<line x1="12" y1="16" x2="12.01" y2="16" />
|
|
||||||
</svg>
|
|
||||||
</a>
|
|
||||||
{/if}
|
|
||||||
{#if $status.application.initialLoading}
|
|
||||||
<button
|
|
||||||
class="icons tooltip-bottom flex animate-spin items-center space-x-2 bg-transparent text-sm duration-500 ease-in-out"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
class="h-6 w-6"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke-width="1.5"
|
|
||||||
stroke="currentColor"
|
|
||||||
fill="none"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
>
|
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
||||||
<path d="M9 4.55a8 8 0 0 1 6 14.9m0 -4.45v5h5" />
|
|
||||||
<line x1="5.63" y1="7.16" x2="5.63" y2="7.17" />
|
|
||||||
<line x1="4.06" y1="11" x2="4.06" y2="11.01" />
|
|
||||||
<line x1="4.63" y1="15.1" x2="4.63" y2="15.11" />
|
|
||||||
<line x1="7.16" y1="18.37" x2="7.16" y2="18.38" />
|
|
||||||
<line x1="11" y1="19.94" x2="11" y2="19.95" />
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
{:else if $status.application.isRunning}
|
|
||||||
<button
|
|
||||||
on:click={stopApplication}
|
|
||||||
type="submit"
|
|
||||||
disabled={$disabledButton}
|
|
||||||
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm flex items-center space-x-2 text-error"
|
|
||||||
data-tip={$appSession.isAdmin
|
|
||||||
? $t('application.stop_application')
|
|
||||||
: $t('application.permission_denied_stop_application')}
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
class="w-6 h-6"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke-width="1.5"
|
|
||||||
stroke="currentColor"
|
|
||||||
fill="none"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
>
|
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
||||||
<rect x="6" y="5" width="4" height="14" rx="1" />
|
|
||||||
<rect x="14" y="5" width="4" height="14" rx="1" />
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
<form on:submit|preventDefault={() => handleDeploySubmit(true)}>
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
disabled={$disabledButton || !isQueueActive}
|
|
||||||
class:hover:text-green-500={isQueueActive}
|
|
||||||
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm flex items-center space-x-2"
|
|
||||||
data-tip={$appSession.isAdmin
|
|
||||||
? isQueueActive
|
|
||||||
? 'Force Rebuild Application'
|
|
||||||
: 'Autoupdate inprogress. Cannot rebuild application.'
|
|
||||||
: 'You do not have permission to rebuild application.'}
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
class="w-6 h-6"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke-width="1.5"
|
|
||||||
stroke="currentColor"
|
|
||||||
fill="none"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
>
|
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
||||||
<path
|
|
||||||
d="M16.3 5h.7a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2h5l-2.82 -2.82m0 5.64l2.82 -2.82"
|
|
||||||
transform="rotate(-45 12 12)"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
{:else}
|
|
||||||
<form on:submit|preventDefault={handleDeploySubmit}>
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
disabled={$disabledButton}
|
|
||||||
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm flex items-center space-x-2 text-success"
|
|
||||||
data-tip={$appSession.isAdmin
|
|
||||||
? 'Deploy'
|
|
||||||
: 'You do not have permission to deploy application.'}
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
class="w-6 h-6"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke-width="1.5"
|
|
||||||
stroke="currentColor"
|
|
||||||
fill="none"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
>
|
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
||||||
<path d="M7 4v16l13 -8z" />
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<div class="border border-coolgray-500 h-8" />
|
<div class="border border-coolgray-500 h-8" />
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if $status.application.isExited}
|
||||||
<a
|
<a
|
||||||
href={!$disabledButton ? `/applications/${id}` : null}
|
id="applicationerror"
|
||||||
|
href={$isDeploymentEnabled ? `/applications/${id}/logs` : null}
|
||||||
|
class="icons bg-transparent text-sm flex items-center text-error"
|
||||||
sveltekit:prefetch
|
sveltekit:prefetch
|
||||||
class="hover:text-yellow-500 rounded"
|
|
||||||
class:text-yellow-500={$page.url.pathname === `/applications/${id}`}
|
|
||||||
class:bg-coolgray-500={$page.url.pathname === `/applications/${id}`}
|
|
||||||
>
|
>
|
||||||
<button
|
<svg
|
||||||
disabled={$disabledButton}
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm"
|
class="w-6 h-6"
|
||||||
data-tip="Configurations"
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentcolor"
|
||||||
|
fill="none"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
>
|
>
|
||||||
<svg
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
<path
|
||||||
class="h-6 w-6"
|
d="M8.7 3h6.6c.3 0 .5 .1 .7 .3l4.7 4.7c.2 .2 .3 .4 .3 .7v6.6c0 .3 -.1 .5 -.3 .7l-4.7 4.7c-.2 .2 -.4 .3 -.7 .3h-6.6c-.3 0 -.5 -.1 -.7 -.3l-4.7 -4.7c-.2 -.2 -.3 -.4 -.3 -.7v-6.6c0 -.3 .1 -.5 .3 -.7l4.7 -4.7c.2 -.2 .4 -.3 .7 -.3z"
|
||||||
viewBox="0 0 24 24"
|
/>
|
||||||
stroke-width="1.5"
|
<line x1="12" y1="8" x2="12" y2="12" />
|
||||||
stroke="currentColor"
|
<line x1="12" y1="16" x2="12.01" y2="16" />
|
||||||
fill="none"
|
</svg>
|
||||||
stroke-linecap="round"
|
</a>
|
||||||
stroke-linejoin="round"
|
<Tooltip triggeredBy="#applicationerror">Application exited with an error!</Tooltip>
|
||||||
>
|
{/if}
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
{#if $status.application.initialLoading}
|
||||||
<rect x="4" y="8" width="4" height="4" />
|
<button
|
||||||
<line x1="6" y1="4" x2="6" y2="8" />
|
class="icons flex animate-spin items-center space-x-2 bg-transparent text-sm duration-500 ease-in-out"
|
||||||
<line x1="6" y1="12" x2="6" y2="20" />
|
|
||||||
<rect x="10" y="14" width="4" height="4" />
|
|
||||||
<line x1="12" y1="4" x2="12" y2="14" />
|
|
||||||
<line x1="12" y1="18" x2="12" y2="20" />
|
|
||||||
<rect x="16" y="5" width="4" height="4" />
|
|
||||||
<line x1="18" y1="4" x2="18" y2="5" />
|
|
||||||
<line x1="18" y1="9" x2="18" y2="20" />
|
|
||||||
</svg></button
|
|
||||||
></a
|
|
||||||
>
|
>
|
||||||
<a
|
<svg
|
||||||
href={!$disabledButton ? `/applications/${id}/secrets` : null}
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
sveltekit:prefetch
|
class="h-6 w-6"
|
||||||
class="hover:text-pink-500 rounded"
|
viewBox="0 0 24 24"
|
||||||
class:text-pink-500={$page.url.pathname === `/applications/${id}/secrets`}
|
stroke-width="1.5"
|
||||||
class:bg-coolgray-500={$page.url.pathname === `/applications/${id}/secrets`}
|
stroke="currentColor"
|
||||||
>
|
fill="none"
|
||||||
<button
|
stroke-linecap="round"
|
||||||
disabled={$disabledButton}
|
stroke-linejoin="round"
|
||||||
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm"
|
|
||||||
data-tip="Secret"
|
|
||||||
>
|
>
|
||||||
<svg
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
<path d="M9 4.55a8 8 0 0 1 6 14.9m0 -4.45v5h5" />
|
||||||
class="w-6 h-6"
|
<line x1="5.63" y1="7.16" x2="5.63" y2="7.17" />
|
||||||
viewBox="0 0 24 24"
|
<line x1="4.06" y1="11" x2="4.06" y2="11.01" />
|
||||||
stroke-width="1.5"
|
<line x1="4.63" y1="15.1" x2="4.63" y2="15.11" />
|
||||||
stroke="currentColor"
|
<line x1="7.16" y1="18.37" x2="7.16" y2="18.38" />
|
||||||
fill="none"
|
<line x1="11" y1="19.94" x2="11" y2="19.95" />
|
||||||
stroke-linecap="round"
|
</svg>
|
||||||
stroke-linejoin="round"
|
</button>
|
||||||
>
|
{:else if $status.application.isRunning}
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
<button
|
||||||
<path
|
id="stop"
|
||||||
d="M12 3a12 12 0 0 0 8.5 3a12 12 0 0 1 -8.5 15a12 12 0 0 1 -8.5 -15a12 12 0 0 0 8.5 -3"
|
on:click={stopApplication}
|
||||||
/>
|
type="submit"
|
||||||
<circle cx="12" cy="11" r="1" />
|
disabled={!$isDeploymentEnabled}
|
||||||
<line x1="12" y1="12" x2="12" y2="14.5" />
|
class="icons bg-transparent text-sm flex items-center space-x-2 text-error"
|
||||||
</svg></button
|
|
||||||
></a
|
|
||||||
>
|
>
|
||||||
<a
|
<svg
|
||||||
href={!$disabledButton ? `/applications/${id}/storages` : null}
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
sveltekit:prefetch
|
class="w-6 h-6"
|
||||||
class="hover:text-pink-500 rounded"
|
viewBox="0 0 24 24"
|
||||||
class:text-pink-500={$page.url.pathname === `/applications/${id}/storages`}
|
stroke-width="1.5"
|
||||||
class:bg-coolgray-500={$page.url.pathname === `/applications/${id}/storages`}
|
stroke="currentColor"
|
||||||
>
|
fill="none"
|
||||||
<button
|
stroke-linecap="round"
|
||||||
disabled={$disabledButton}
|
stroke-linejoin="round"
|
||||||
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm"
|
|
||||||
data-tip="Persistent Storages"
|
|
||||||
>
|
>
|
||||||
<svg
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
<rect x="6" y="5" width="4" height="14" rx="1" />
|
||||||
class="w-6 h-6"
|
<rect x="14" y="5" width="4" height="14" rx="1" />
|
||||||
viewBox="0 0 24 24"
|
</svg>
|
||||||
stroke-width="1.5"
|
</button>
|
||||||
stroke="currentColor"
|
<Tooltip triggeredBy="#stop">Stop</Tooltip>
|
||||||
fill="none"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
>
|
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
||||||
<ellipse cx="12" cy="6" rx="8" ry="3" />
|
|
||||||
<path d="M4 6v6a8 3 0 0 0 16 0v-6" />
|
|
||||||
<path d="M4 12v6a8 3 0 0 0 16 0v-6" />
|
|
||||||
</svg>
|
|
||||||
</button></a
|
|
||||||
>
|
|
||||||
{#if !application.settings.isBot}
|
|
||||||
<a
|
|
||||||
href={!$disabledButton ? `/applications/${id}/previews` : null}
|
|
||||||
sveltekit:prefetch
|
|
||||||
class="hover:text-orange-500 rounded"
|
|
||||||
class:text-orange-500={$page.url.pathname === `/applications/${id}/previews`}
|
|
||||||
class:bg-coolgray-500={$page.url.pathname === `/applications/${id}/previews`}
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
disabled={$disabledButton}
|
|
||||||
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm"
|
|
||||||
data-tip="Previews"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
class="w-6 h-6"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke-width="1.5"
|
|
||||||
stroke="currentColor"
|
|
||||||
fill="none"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
>
|
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
||||||
<circle cx="7" cy="18" r="2" />
|
|
||||||
<circle cx="7" cy="6" r="2" />
|
|
||||||
<circle cx="17" cy="12" r="2" />
|
|
||||||
<line x1="7" y1="8" x2="7" y2="16" />
|
|
||||||
<path d="M7 8a4 4 0 0 0 4 4h4" />
|
|
||||||
</svg></button
|
|
||||||
></a
|
|
||||||
>
|
|
||||||
{/if}
|
|
||||||
<div class="border border-coolgray-500 h-8" />
|
|
||||||
<a
|
|
||||||
href={!$disabledButton && $status.application.isRunning ? `/applications/${id}/logs` : null}
|
|
||||||
sveltekit:prefetch
|
|
||||||
class="hover:text-sky-500 rounded"
|
|
||||||
class:text-sky-500={$page.url.pathname === `/applications/${id}/logs`}
|
|
||||||
class:bg-coolgray-500={$page.url.pathname === `/applications/${id}/logs`}
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
disabled={$disabledButton || !$status.application.isRunning}
|
|
||||||
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm"
|
|
||||||
data-tip={$t('application.logs')}
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
class="h-6 w-6"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke-width="1.5"
|
|
||||||
stroke="currentColor"
|
|
||||||
fill="none"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
>
|
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
||||||
<path d="M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0" />
|
|
||||||
<path d="M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0" />
|
|
||||||
<line x1="3" y1="6" x2="3" y2="19" />
|
|
||||||
<line x1="12" y1="6" x2="12" y2="19" />
|
|
||||||
<line x1="21" y1="6" x2="21" y2="19" />
|
|
||||||
</svg>
|
|
||||||
</button></a
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href={!$disabledButton ? `/applications/${id}/logs/build` : null}
|
|
||||||
sveltekit:prefetch
|
|
||||||
class="hover:text-red-500 rounded"
|
|
||||||
class:text-red-500={$page.url.pathname === `/applications/${id}/logs/build`}
|
|
||||||
class:bg-coolgray-500={$page.url.pathname === `/applications/${id}/logs/build`}
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
disabled={$disabledButton}
|
|
||||||
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm"
|
|
||||||
data-tip="Build Logs"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
class="h-6 w-6"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke-width="1.5"
|
|
||||||
stroke="currentColor"
|
|
||||||
fill="none"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
>
|
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
||||||
<circle cx="19" cy="13" r="2" />
|
|
||||||
<circle cx="4" cy="17" r="2" />
|
|
||||||
<circle cx="13" cy="17" r="2" />
|
|
||||||
<line x1="13" y1="19" x2="4" y2="19" />
|
|
||||||
<line x1="4" y1="15" x2="13" y2="15" />
|
|
||||||
<path d="M8 12v-5h2a3 3 0 0 1 3 3v5" />
|
|
||||||
<path d="M5 15v-2a1 1 0 0 1 1 -1h7" />
|
|
||||||
<path d="M19 11v-7l-6 7" />
|
|
||||||
</svg>
|
|
||||||
</button></a
|
|
||||||
>
|
|
||||||
<div class="border border-coolgray-500 h-8" />
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
on:click={() => deleteApplication(application.name)}
|
id="restart"
|
||||||
|
on:click={restartApplication}
|
||||||
|
type="submit"
|
||||||
|
disabled={!$isDeploymentEnabled}
|
||||||
|
class="icons bg-transparent text-sm flex items-center space-x-2"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class="w-6 h-6"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
fill="none"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<path d="M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4" />
|
||||||
|
<path d="M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<Tooltip triggeredBy="#restart">Restart (useful to change secrets)</Tooltip>
|
||||||
|
|
||||||
|
<form on:submit|preventDefault={() => handleDeploySubmit(true)}>
|
||||||
|
<button
|
||||||
|
id="forceredeploy"
|
||||||
|
type="submit"
|
||||||
|
disabled={!$isDeploymentEnabled}
|
||||||
|
class="icons bg-transparent text-sm flex items-center space-x-2"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class="w-6 h-6"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
fill="none"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<path
|
||||||
|
d="M16.3 5h.7a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2h5l-2.82 -2.82m0 5.64l2.82 -2.82"
|
||||||
|
transform="rotate(-45 12 12)"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<Tooltip triggeredBy="#forceredeploy">Force redeploy (without cache)</Tooltip>
|
||||||
|
</form>
|
||||||
|
{:else}
|
||||||
|
<form on:submit|preventDefault={() => handleDeploySubmit(false)}>
|
||||||
|
<button
|
||||||
|
id="deploy"
|
||||||
|
type="submit"
|
||||||
|
disabled={!$isDeploymentEnabled}
|
||||||
|
class="icons bg-transparent text-sm flex items-center space-x-2 text-success"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class="w-6 h-6"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
fill="none"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<path d="M7 4v16l13 -8z" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<Tooltip triggeredBy="#deploy">Deploy</Tooltip>
|
||||||
|
</form>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div class="border border-coolgray-500 h-8" />
|
||||||
|
<a
|
||||||
|
href={$isDeploymentEnabled ? `/applications/${id}` : null}
|
||||||
|
sveltekit:prefetch
|
||||||
|
class="hover:text-yellow-500 rounded"
|
||||||
|
class:text-yellow-500={$page.url.pathname === `/applications/${id}`}
|
||||||
|
class:bg-coolgray-500={$page.url.pathname === `/applications/${id}`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
disabled={!$isDeploymentEnabled}
|
||||||
|
id="configurations"
|
||||||
|
class="icons bg-transparent text-sm"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class="h-6 w-6"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
fill="none"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<rect x="4" y="8" width="4" height="4" />
|
||||||
|
<line x1="6" y1="4" x2="6" y2="8" />
|
||||||
|
<line x1="6" y1="12" x2="6" y2="20" />
|
||||||
|
<rect x="10" y="14" width="4" height="4" />
|
||||||
|
<line x1="12" y1="4" x2="12" y2="14" />
|
||||||
|
<line x1="12" y1="18" x2="12" y2="20" />
|
||||||
|
<rect x="16" y="5" width="4" height="4" />
|
||||||
|
<line x1="18" y1="4" x2="18" y2="5" />
|
||||||
|
<line x1="18" y1="9" x2="18" y2="20" />
|
||||||
|
</svg></button
|
||||||
|
></a
|
||||||
|
>
|
||||||
|
|
||||||
|
<Tooltip triggeredBy="#configurations">Configurations</Tooltip>
|
||||||
|
<a
|
||||||
|
href={$isDeploymentEnabled ? `/applications/${id}/secrets` : null}
|
||||||
|
sveltekit:prefetch
|
||||||
|
class="hover:text-pink-500 rounded"
|
||||||
|
class:text-pink-500={$page.url.pathname === `/applications/${id}/secrets`}
|
||||||
|
class:bg-coolgray-500={$page.url.pathname === `/applications/${id}/secrets`}
|
||||||
|
>
|
||||||
|
<button id="secrets" disabled={!$isDeploymentEnabled} class="icons bg-transparent text-sm">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class="w-6 h-6"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
fill="none"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<path
|
||||||
|
d="M12 3a12 12 0 0 0 8.5 3a12 12 0 0 1 -8.5 15a12 12 0 0 1 -8.5 -15a12 12 0 0 0 8.5 -3"
|
||||||
|
/>
|
||||||
|
<circle cx="12" cy="11" r="1" />
|
||||||
|
<line x1="12" y1="12" x2="12" y2="14.5" />
|
||||||
|
</svg></button
|
||||||
|
></a
|
||||||
|
>
|
||||||
|
<Tooltip triggeredBy="#secrets">Secrets</Tooltip>
|
||||||
|
<a
|
||||||
|
href={$isDeploymentEnabled ? `/applications/${id}/storages` : null}
|
||||||
|
sveltekit:prefetch
|
||||||
|
class="hover:text-pink-500 rounded"
|
||||||
|
class:text-pink-500={$page.url.pathname === `/applications/${id}/storages`}
|
||||||
|
class:bg-coolgray-500={$page.url.pathname === `/applications/${id}/storages`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
id="persistentstorages"
|
||||||
|
disabled={!$isDeploymentEnabled}
|
||||||
|
class="icons bg-transparent text-sm"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class="w-6 h-6"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
fill="none"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<ellipse cx="12" cy="6" rx="8" ry="3" />
|
||||||
|
<path d="M4 6v6a8 3 0 0 0 16 0v-6" />
|
||||||
|
<path d="M4 12v6a8 3 0 0 0 16 0v-6" />
|
||||||
|
</svg>
|
||||||
|
</button></a
|
||||||
|
>
|
||||||
|
<Tooltip triggeredBy="#persistentstorages">Persistent Storages</Tooltip>
|
||||||
|
{#if !application.settings.isBot}
|
||||||
|
<a
|
||||||
|
href={$isDeploymentEnabled ? `/applications/${id}/previews` : null}
|
||||||
|
sveltekit:prefetch
|
||||||
|
class="hover:text-orange-500 rounded"
|
||||||
|
class:text-orange-500={$page.url.pathname === `/applications/${id}/previews`}
|
||||||
|
class:bg-coolgray-500={$page.url.pathname === `/applications/${id}/previews`}
|
||||||
|
>
|
||||||
|
<button id="previews" disabled={!$isDeploymentEnabled} class="icons bg-transparent text-sm">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class="w-6 h-6"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
fill="none"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<circle cx="7" cy="18" r="2" />
|
||||||
|
<circle cx="7" cy="6" r="2" />
|
||||||
|
<circle cx="17" cy="12" r="2" />
|
||||||
|
<line x1="7" y1="8" x2="7" y2="16" />
|
||||||
|
<path d="M7 8a4 4 0 0 0 4 4h4" />
|
||||||
|
</svg></button
|
||||||
|
></a
|
||||||
|
>
|
||||||
|
<Tooltip triggeredBy="#previews">Previews</Tooltip>
|
||||||
|
{/if}
|
||||||
|
<div class="border border-coolgray-500 h-8" />
|
||||||
|
<a
|
||||||
|
href={$isDeploymentEnabled && $status.application.isRunning ? `/applications/${id}/logs` : null}
|
||||||
|
sveltekit:prefetch
|
||||||
|
class="hover:text-sky-500 rounded"
|
||||||
|
class:text-sky-500={$page.url.pathname === `/applications/${id}/logs`}
|
||||||
|
class:bg-coolgray-500={$page.url.pathname === `/applications/${id}/logs`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
id="applicationlogs"
|
||||||
|
disabled={!$isDeploymentEnabled || !$status.application.isRunning}
|
||||||
|
class="icons bg-transparent text-sm"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class="h-6 w-6"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
fill="none"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<path d="M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0" />
|
||||||
|
<path d="M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0" />
|
||||||
|
<line x1="3" y1="6" x2="3" y2="19" />
|
||||||
|
<line x1="12" y1="6" x2="12" y2="19" />
|
||||||
|
<line x1="21" y1="6" x2="21" y2="19" />
|
||||||
|
</svg>
|
||||||
|
</button></a
|
||||||
|
>
|
||||||
|
<Tooltip triggeredBy="#applicationlogs">Application Logs</Tooltip>
|
||||||
|
<a
|
||||||
|
href={$isDeploymentEnabled ? `/applications/${id}/logs/build` : null}
|
||||||
|
sveltekit:prefetch
|
||||||
|
class="hover:text-red-500 rounded"
|
||||||
|
class:text-red-500={$page.url.pathname === `/applications/${id}/logs/build`}
|
||||||
|
class:bg-coolgray-500={$page.url.pathname === `/applications/${id}/logs/build`}
|
||||||
|
>
|
||||||
|
<button id="buildlogs" disabled={!$isDeploymentEnabled} class="icons bg-transparent text-sm">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class="h-6 w-6"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
fill="none"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<circle cx="19" cy="13" r="2" />
|
||||||
|
<circle cx="4" cy="17" r="2" />
|
||||||
|
<circle cx="13" cy="17" r="2" />
|
||||||
|
<line x1="13" y1="19" x2="4" y2="19" />
|
||||||
|
<line x1="4" y1="15" x2="13" y2="15" />
|
||||||
|
<path d="M8 12v-5h2a3 3 0 0 1 3 3v5" />
|
||||||
|
<path d="M5 15v-2a1 1 0 0 1 1 -1h7" />
|
||||||
|
<path d="M19 11v-7l-6 7" />
|
||||||
|
</svg>
|
||||||
|
</button></a
|
||||||
|
>
|
||||||
|
<Tooltip triggeredBy="#buildlogs">Build Logs</Tooltip>
|
||||||
|
<div class="border border-coolgray-500 h-8" />
|
||||||
|
|
||||||
|
{#if forceDelete}
|
||||||
|
<button
|
||||||
|
id="forcedelete"
|
||||||
|
on:click={() => deleteApplication(application.name, true)}
|
||||||
|
type="submit"
|
||||||
|
disabled={!$appSession.isAdmin}
|
||||||
|
class:bg-red-600={$appSession.isAdmin}
|
||||||
|
class:hover:bg-red-500={$appSession.isAdmin}
|
||||||
|
class="icons bg-transparent text-sm"
|
||||||
|
>
|
||||||
|
Force Delete
|
||||||
|
</button>
|
||||||
|
<Tooltip triggeredBy="#forcedelete">Force Delete</Tooltip>
|
||||||
|
{:else}
|
||||||
|
<button
|
||||||
|
id="delete"
|
||||||
|
on:click={() => deleteApplication(application.name, false)}
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={!$appSession.isAdmin}
|
disabled={!$appSession.isAdmin}
|
||||||
class:hover:text-red-500={$appSession.isAdmin}
|
class:hover:text-red-500={$appSession.isAdmin}
|
||||||
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm"
|
class="icons bg-transparent text-sm"
|
||||||
data-tip={$appSession.isAdmin
|
|
||||||
? $t('application.delete_application')
|
|
||||||
: $t('application.permission_denied_delete_application')}
|
|
||||||
>
|
>
|
||||||
<DeleteIcon />
|
<DeleteIcon />
|
||||||
</button>
|
</button>
|
||||||
|
<Tooltip triggeredBy="#delete">Delete</Tooltip>
|
||||||
{/if}
|
{/if}
|
||||||
</nav>
|
</nav>
|
||||||
<slot />
|
<slot />
|
||||||
|
|||||||
@@ -95,19 +95,19 @@
|
|||||||
async function isBranchAlreadyUsed(event: any) {
|
async function isBranchAlreadyUsed(event: any) {
|
||||||
selected.branch = event.detail.value;
|
selected.branch = event.detail.value;
|
||||||
try {
|
try {
|
||||||
const data = await get(
|
// const data = await get(
|
||||||
`/applications/${id}/configuration/repository?repository=${selected.repository}&branch=${selected.branch}`
|
// `/applications/${id}/configuration/repository?repository=${selected.repository}&branch=${selected.branch}`
|
||||||
);
|
// );
|
||||||
if (data.used) {
|
// if (data.used) {
|
||||||
const sure = confirm($t('application.configuration.branch_already_in_use'));
|
// const sure = confirm($t('application.configuration.branch_already_in_use'));
|
||||||
if (sure) {
|
// if (sure) {
|
||||||
selected.autodeploy = false;
|
// selected.autodeploy = false;
|
||||||
showSave = true;
|
// showSave = true;
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
showSave = false;
|
// showSave = false;
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
showSave = true;
|
showSave = true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showSave = false;
|
showSave = false;
|
||||||
|
|||||||
@@ -169,10 +169,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function selectBranch(event: any) {
|
|
||||||
selected.branch = event.detail;
|
|
||||||
isBranchAlreadyUsed();
|
|
||||||
}
|
|
||||||
async function loadBranches(page: number = 1) {
|
async function loadBranches(page: number = 1) {
|
||||||
let perPage = 100;
|
let perPage = 100;
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
@@ -199,21 +195,22 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function isBranchAlreadyUsed() {
|
async function isBranchAlreadyUsed(event) {
|
||||||
|
selected.branch = event.detail;
|
||||||
try {
|
try {
|
||||||
const data = await get(
|
// const data = await get(
|
||||||
`/applications/${id}/configuration/repository?repository=${selected.project.path_with_namespace}&branch=${selected.branch.name}`
|
// `/applications/${id}/configuration/repository?repository=${selected.project.path_with_namespace}&branch=${selected.branch.name}`
|
||||||
);
|
// );
|
||||||
if (data.used) {
|
// if (data.used) {
|
||||||
const sure = confirm($t('application.configuration.branch_already_in_use'));
|
// const sure = confirm($t('application.configuration.branch_already_in_use'));
|
||||||
if (sure) {
|
// if (sure) {
|
||||||
autodeploy = false;
|
// autodeploy = false;
|
||||||
showSave = true;
|
// showSave = true;
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
showSave = false;
|
// showSave = false;
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
showSave = true;
|
showSave = true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return errorNotification(error);
|
return errorNotification(error);
|
||||||
@@ -227,9 +224,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function setWebhook(url: any, webhookToken: any) {
|
async function setWebhook(url: any, webhookToken: any) {
|
||||||
const host = dev
|
const host = dev ? getWebhookUrl('gitlab') : `${window.location.origin}/webhooks/gitlab/events`;
|
||||||
? getWebhookUrl('gitlab')
|
|
||||||
: `${window.location.origin}/webhooks/gitlab/events`;
|
|
||||||
try {
|
try {
|
||||||
await post(
|
await post(
|
||||||
url,
|
url,
|
||||||
@@ -294,17 +289,15 @@
|
|||||||
);
|
);
|
||||||
await post(updateDeployKeyIdUrl, { deployKeyId: id });
|
await post(updateDeployKeyIdUrl, { deployKeyId: id });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return errorNotification(error);
|
|
||||||
} finally {
|
|
||||||
loading.save = false;
|
loading.save = false;
|
||||||
|
return errorNotification(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await setWebhook(webhookUrl, webhookToken);
|
await setWebhook(webhookUrl, webhookToken);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return errorNotification(error);
|
|
||||||
} finally {
|
|
||||||
loading.save = false;
|
loading.save = false;
|
||||||
|
return errorNotification(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = `/applications/${id}/configuration/repository`;
|
const url = `/applications/${id}/configuration/repository`;
|
||||||
@@ -317,11 +310,11 @@
|
|||||||
autodeploy,
|
autodeploy,
|
||||||
webhookToken
|
webhookToken
|
||||||
});
|
});
|
||||||
|
loading.save = false;
|
||||||
return await goto(from || `/applications/${id}/configuration/buildpack`);
|
return await goto(from || `/applications/${id}/configuration/buildpack`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return errorNotification(error);
|
|
||||||
} finally {
|
|
||||||
loading.save = false;
|
loading.save = false;
|
||||||
|
return errorNotification(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
@@ -396,7 +389,7 @@
|
|||||||
showIndicator={!loading.branches}
|
showIndicator={!loading.branches}
|
||||||
isWaiting={loading.branches}
|
isWaiting={loading.branches}
|
||||||
isDisabled={loading.branches || !selected.project}
|
isDisabled={loading.branches || !selected.project}
|
||||||
on:select={selectBranch}
|
on:select={isBranchAlreadyUsed}
|
||||||
on:clear={() => {
|
on:clear={() => {
|
||||||
showSave = false;
|
showSave = false;
|
||||||
selected.branch = null;
|
selected.branch = null;
|
||||||
@@ -425,7 +418,7 @@
|
|||||||
configuration <a href={`/sources/${application.gitSource.id}`}>here.</a>
|
configuration <a href={`/sources/${application.gitSource.id}`}>here.</a>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
class="w-40 bg-green-600"
|
class="btn btn-sm w-40 bg-green-600"
|
||||||
on:click|stopPropagation|preventDefault={() => window.location.reload()}
|
on:click|stopPropagation|preventDefault={() => window.location.reload()}
|
||||||
>
|
>
|
||||||
Try again
|
Try again
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
|
|
||||||
import Select from 'svelte-select';
|
import Select from 'svelte-select';
|
||||||
import Explainer from '$lib/components/Explainer.svelte';
|
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { errorNotification } from '$lib/common';
|
import { errorNotification } from '$lib/common';
|
||||||
|
|
||||||
@@ -23,7 +22,7 @@
|
|||||||
async function loadBranches() {
|
async function loadBranches() {
|
||||||
try {
|
try {
|
||||||
loading.branches = true;
|
loading.branches = true;
|
||||||
|
publicRepositoryLink = publicRepositoryLink.trim();
|
||||||
const protocol = publicRepositoryLink.split(':')[0];
|
const protocol = publicRepositoryLink.split(':')[0];
|
||||||
const gitUrl = publicRepositoryLink.replace('http://', '').replace('https://', '');
|
const gitUrl = publicRepositoryLink.replace('http://', '').replace('https://', '');
|
||||||
|
|
||||||
@@ -164,7 +163,6 @@
|
|||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
<input
|
<input
|
||||||
placeholder="eg: https://github.com/coollabsio/nodejs-example/tree/main"
|
placeholder="eg: https://github.com/coollabsio/nodejs-example/tree/main"
|
||||||
class="text-xs"
|
|
||||||
bind:value={publicRepositoryLink}
|
bind:value={publicRepositoryLink}
|
||||||
/>
|
/>
|
||||||
{#if branchSelectOptions.length > 0}
|
{#if branchSelectOptions.length > 0}
|
||||||
@@ -193,7 +191,5 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Explainer
|
|
||||||
text="Examples:<br><br>https://github.com/coollabsio/nodejs-example<br>https://github.com/coollabsio/nodejs-example/tree/main<br>https://gitlab.com/aleveha/fastify-example<br>https://gitlab.com/aleveha/fastify-example/-/tree/master<br><br>Only works with Github.com and Gitlab.com."
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,162 @@
|
|||||||
|
<script context="module" lang="ts">
|
||||||
|
import type { Load } from '@sveltejs/kit';
|
||||||
|
export const load: Load = async () => {
|
||||||
|
try {
|
||||||
|
const response = await get(`/databases`);
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
...response
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} catch (error: any) {
|
||||||
|
return {
|
||||||
|
status: 500,
|
||||||
|
error: new Error(error)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export let databases: any = [];
|
||||||
|
import { get, post } from '$lib/api';
|
||||||
|
import { t } from '$lib/translations';
|
||||||
|
import { appSession } from '$lib/store';
|
||||||
|
import DatabaseIcons from '$lib/components/svg/databases/DatabaseIcons.svelte';
|
||||||
|
import { errorNotification } from '$lib/common';
|
||||||
|
import { page } from '$app/stores';
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
|
||||||
|
const from = $page.url.searchParams.get('from');
|
||||||
|
|
||||||
|
let remoteDatabase = {
|
||||||
|
name: null,
|
||||||
|
type: null,
|
||||||
|
host: null,
|
||||||
|
port: null,
|
||||||
|
user: null,
|
||||||
|
password: null,
|
||||||
|
database: null
|
||||||
|
};
|
||||||
|
|
||||||
|
const ownDatabases = databases.filter((database: any) => {
|
||||||
|
if (database.teams[0].id === $appSession.teamId) {
|
||||||
|
return database;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const otherDatabases = databases.filter((database: any) => {
|
||||||
|
if (database.teams[0].id !== $appSession.teamId) {
|
||||||
|
return database;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
async function addCoolifyDatabase(database: any) {
|
||||||
|
try {
|
||||||
|
await post(`/applications/${$page.params.id}/configuration/database`, {
|
||||||
|
databaseId: database.id,
|
||||||
|
type: database.type
|
||||||
|
});
|
||||||
|
return window.location.assign(from || `/applications/${$page.params.id}/`);
|
||||||
|
} catch (error) {
|
||||||
|
return errorNotification(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="flex space-x-1 p-6 font-bold">
|
||||||
|
<div class="mr-4 text-2xl tracking-tight">Select a Database</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex-col justify-center mt-10 pb-12 sm:pb-16">
|
||||||
|
{#if !databases || ownDatabases.length === 0}
|
||||||
|
<div class="flex-col">
|
||||||
|
<div class="text-center text-xl font-bold">{$t('database.no_databases_found')}</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{#if ownDatabases.length > 0 || otherDatabases.length > 0}
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<div class="flex flex-col flex-wrap justify-center px-2 md:flex-row">
|
||||||
|
{#each ownDatabases as database}
|
||||||
|
<button on:click={() => addCoolifyDatabase(database)} class="p-2 no-underline">
|
||||||
|
<div class="box-selection group relative hover:bg-purple-600">
|
||||||
|
<DatabaseIcons type={database.type} isAbsolute={true} />
|
||||||
|
<div class="truncate text-center text-xl font-bold">
|
||||||
|
{database.name}
|
||||||
|
</div>
|
||||||
|
{#if $appSession.teamId === '0' && otherDatabases.length > 0}
|
||||||
|
<div class="truncate text-center">{database.teams[0].name}</div>
|
||||||
|
{/if}
|
||||||
|
{#if database.destinationDocker?.name}
|
||||||
|
<div class="truncate text-center">{database.destinationDocker.name}</div>
|
||||||
|
{/if}
|
||||||
|
{#if !database.type}
|
||||||
|
<div class="truncate text-center font-bold text-red-500 group-hover:text-white">
|
||||||
|
{$t('application.configuration.configuration_missing')}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{#if otherDatabases.length > 0 && $appSession.teamId === '0'}
|
||||||
|
<div class="px-6 pb-5 pt-10 text-2xl font-bold text-center">Other Databases</div>
|
||||||
|
<div class="flex flex-col flex-wrap justify-center px-2 md:flex-row">
|
||||||
|
{#each otherDatabases as database}
|
||||||
|
<a href="/databases/{database.id}" class="p-2 no-underline">
|
||||||
|
<div class="box-selection group relative hover:bg-purple-600">
|
||||||
|
<DatabaseIcons type={database.type} isAbsolute={true} />
|
||||||
|
<div class="truncate text-center text-xl font-bold">
|
||||||
|
{database.name}
|
||||||
|
</div>
|
||||||
|
{#if $appSession.teamId === '0'}
|
||||||
|
<div class="truncate text-center">{database.teams[0].name}</div>
|
||||||
|
{/if}
|
||||||
|
{#if !database.type}
|
||||||
|
<div class="truncate text-center font-bold text-red-500 group-hover:text-white">
|
||||||
|
Configuration missing
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<div class="text-center truncate">{database.type}</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div class="mx-auto max-w-4xl p-6">
|
||||||
|
<div class="grid grid-flow-row gap-2 px-10">
|
||||||
|
<div class="font-bold text-xl tracking-tight">Connect a Hosted / Remote Database</div>
|
||||||
|
<div class="mt-2 grid grid-cols-2 items-center px-4">
|
||||||
|
<label for="name" class="text-base font-bold text-stone-100">Name</label>
|
||||||
|
<input name="name" id="name" required bind:value={remoteDatabase.name} />
|
||||||
|
</div>
|
||||||
|
<div class="mt-2 grid grid-cols-2 items-center px-4">
|
||||||
|
<label for="type" class="text-base font-bold text-stone-100">Type</label>
|
||||||
|
<input name="type" id="type" required bind:value={remoteDatabase.type} />
|
||||||
|
</div>
|
||||||
|
<div class="mt-2 grid grid-cols-2 items-center px-4">
|
||||||
|
<label for="host" class="text-base font-bold text-stone-100">Host</label>
|
||||||
|
<input name="host" id="host" required bind:value={remoteDatabase.host} />
|
||||||
|
</div>
|
||||||
|
<div class="mt-2 grid grid-cols-2 items-center px-4">
|
||||||
|
<label for="port" class="text-base font-bold text-stone-100">Port</label>
|
||||||
|
<input name="port" id="port" required bind:value={remoteDatabase.port} />
|
||||||
|
</div>
|
||||||
|
<div class="mt-2 grid grid-cols-2 items-center px-4">
|
||||||
|
<label for="user" class="text-base font-bold text-stone-100">User</label>
|
||||||
|
<input name="user" id="user" required bind:value={remoteDatabase.user} />
|
||||||
|
</div>
|
||||||
|
<div class="mt-2 grid grid-cols-2 items-center px-4">
|
||||||
|
<label for="password" class="text-base font-bold text-stone-100">Password</label>
|
||||||
|
<input name="password" id="password" required bind:value={remoteDatabase.password} />
|
||||||
|
</div>
|
||||||
|
<div class="mt-2 grid grid-cols-2 items-center px-4">
|
||||||
|
<label for="database" class="text-base font-bold text-stone-100">Database Name</label>
|
||||||
|
<input name="database" id="database" required bind:value={remoteDatabase.database} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
import { errorNotification } from '$lib/common';
|
import { errorNotification } from '$lib/common';
|
||||||
import { appSession } from '$lib/store';
|
import { appSession } from '$lib/store';
|
||||||
import PublicRepository from './_PublicRepository.svelte';
|
import PublicRepository from './_PublicRepository.svelte';
|
||||||
import Explainer from '$lib/components/Explainer.svelte';
|
import DocLink from '$lib/components/DocLink.svelte';
|
||||||
|
|
||||||
const { id } = $page.params;
|
const { id } = $page.params;
|
||||||
const from = $page.url.searchParams.get('from');
|
const from = $page.url.searchParams.get('from');
|
||||||
@@ -192,7 +192,9 @@ import Explainer from '$lib/components/Explainer.svelte';
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="title py-4">Public Repository</div>
|
<div class="flex items-center">
|
||||||
|
<div class="title py-4">Public Repository</div>
|
||||||
<PublicRepository />
|
<DocLink url="https://docs.coollabs.io/coolify/applications/#public-repository" />
|
||||||
|
</div>
|
||||||
|
<PublicRepository />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user