mirror of
https://github.com/ershisan99/coolify.git
synced 2025-12-18 20:59:24 +00:00
Compare commits
249 Commits
v4.0.0-bet
...
v4.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a50e1e2f0c | ||
|
|
1093294f06 | ||
|
|
c023be2348 | ||
|
|
deece51e83 | ||
|
|
e2ab569244 | ||
|
|
93b202bde4 | ||
|
|
6bb6de188c | ||
|
|
61f58fa30f | ||
|
|
026f3fd72d | ||
|
|
9a706d55b4 | ||
|
|
9646969107 | ||
|
|
df433efe62 | ||
|
|
efa7cab3e2 | ||
|
|
a386a1bde5 | ||
|
|
cc1bf023be | ||
|
|
edb06fa233 | ||
|
|
abdb8074b1 | ||
|
|
157da798dd | ||
|
|
9c5501326e | ||
|
|
3ea462efc9 | ||
|
|
f77df5b732 | ||
|
|
b77074fe4e | ||
|
|
a7b7d3fa32 | ||
|
|
f4f3034389 | ||
|
|
4b2ffb456f | ||
|
|
e17ff99c5b | ||
|
|
1cf036bbc6 | ||
|
|
da4c2ee60f | ||
|
|
fcf7c5ddd5 | ||
|
|
27926322e1 | ||
|
|
c735ff545e | ||
|
|
b4f048b028 | ||
|
|
54a57d217f | ||
|
|
cf28490acc | ||
|
|
019670d5d1 | ||
|
|
b07cc500e7 | ||
|
|
82c235d5af | ||
|
|
307e4a6990 | ||
|
|
ddb7af63a6 | ||
|
|
7a429ee5bb | ||
|
|
bb591604ac | ||
|
|
81f7a65dd5 | ||
|
|
4b313bb1c6 | ||
|
|
aba0b2f13c | ||
|
|
9a284e47da | ||
|
|
9f2fbc661a | ||
|
|
949407368e | ||
|
|
93c65f6a79 | ||
|
|
d9fe16a3ee | ||
|
|
adaca4d4e3 | ||
|
|
a6d5f3038c | ||
|
|
4d49132821 | ||
|
|
c287276d0e | ||
|
|
e89868c692 | ||
|
|
f93317cd2e | ||
|
|
8412802f4d | ||
|
|
53c20e1e99 | ||
|
|
3c8c8e20b1 | ||
|
|
49f8abcd79 | ||
|
|
4a4d73b87b | ||
|
|
046eab3776 | ||
|
|
17c0e91a0d | ||
|
|
fe4a0ae166 | ||
|
|
52c84f8d22 | ||
|
|
b22fecb615 | ||
|
|
23b7fc3c54 | ||
|
|
1efb1235b4 | ||
|
|
0924070a13 | ||
|
|
12fc5a8f91 | ||
|
|
9eba058cf7 | ||
|
|
fa4f5fea8c | ||
|
|
898563fe7c | ||
|
|
c418a17161 | ||
|
|
cd0da04ea2 | ||
|
|
01e942c6a0 | ||
|
|
bb9abafa82 | ||
|
|
d0cd926517 | ||
|
|
9baf0161c7 | ||
|
|
8ba18b2ce1 | ||
|
|
ab021ee535 | ||
|
|
c76a1b1ba5 | ||
|
|
6266a5e500 | ||
|
|
5d27e89bfa | ||
|
|
6da4e78374 | ||
|
|
be30651172 | ||
|
|
95764c2b76 | ||
|
|
92a75685b5 | ||
|
|
a1592373aa | ||
|
|
5747a87f66 | ||
|
|
9cda671aef | ||
|
|
2c9983046c | ||
|
|
11d33f328e | ||
|
|
f79c741d95 | ||
|
|
8a39a4469a | ||
|
|
42daae10c6 | ||
|
|
64a65e2018 | ||
|
|
16c71f3647 | ||
|
|
363f525ad1 | ||
|
|
f4fb519d55 | ||
|
|
b7786504b8 | ||
|
|
f0adf10e6a | ||
|
|
cc8c6c5d16 | ||
|
|
4782446f42 | ||
|
|
230155312f | ||
|
|
3ab4365fca | ||
|
|
7349068b95 | ||
|
|
da6cc151d1 | ||
|
|
50527cf0a3 | ||
|
|
26f490bb00 | ||
|
|
dc4f412227 | ||
|
|
ec4234e243 | ||
|
|
f47fcb01ce | ||
|
|
02f6673345 | ||
|
|
e6cd8702b5 | ||
|
|
fda4ea8cca | ||
|
|
655d004ce7 | ||
|
|
56981d134c | ||
|
|
b9d49d2951 | ||
|
|
0c1e7c499e | ||
|
|
32fead5753 | ||
|
|
e5e9faba35 | ||
|
|
2852630d6c | ||
|
|
a4cc406114 | ||
|
|
53b15a5762 | ||
|
|
929a4e6474 | ||
|
|
45b597bbab | ||
|
|
0d1a2aa5d1 | ||
|
|
b82353d5e2 | ||
|
|
b17c09f7a7 | ||
|
|
f6c3fe7888 | ||
|
|
2e855e030f | ||
|
|
49f86621f4 | ||
|
|
03d9f93397 | ||
|
|
c472042a94 | ||
|
|
9f4356f67d | ||
|
|
a50317cc76 | ||
|
|
8afa98a1ca | ||
|
|
f6737f21dd | ||
|
|
e4a51cc116 | ||
|
|
acd78ae196 | ||
|
|
953bcfb5bb | ||
|
|
dacfab8b29 | ||
|
|
48b3e99939 | ||
|
|
41ad67c7c9 | ||
|
|
b49725cb1c | ||
|
|
75e674a966 | ||
|
|
9d826d9fb4 | ||
|
|
0af221f9fc | ||
|
|
9066c9bf90 | ||
|
|
77e3208f00 | ||
|
|
db5ecf07bd | ||
|
|
7f28aa6985 | ||
|
|
9d53e04ce9 | ||
|
|
3db9a1dd6e | ||
|
|
38f9761b67 | ||
|
|
7117ecf634 | ||
|
|
522e20f10a | ||
|
|
ebbce2396c | ||
|
|
f9a2ff6d90 | ||
|
|
df1b9e7319 | ||
|
|
e7c0c26b32 | ||
|
|
0dbb8b4420 | ||
|
|
a4b44bacc1 | ||
|
|
1338e68b8c | ||
|
|
f6f4cdde24 | ||
|
|
3daadf13c6 | ||
|
|
cbd5fab2e7 | ||
|
|
48ccb508f9 | ||
|
|
67edce0612 | ||
|
|
e8a41d7e6e | ||
|
|
be1dad03bd | ||
|
|
31db1db636 | ||
|
|
dca332a688 | ||
|
|
35f19ed53f | ||
|
|
a5c45ffe90 | ||
|
|
b6c3a65d2d | ||
|
|
220c8211fd | ||
|
|
ffbd04df29 | ||
|
|
73c59be865 | ||
|
|
3966abaf80 | ||
|
|
759517316a | ||
|
|
3e3024d47e | ||
|
|
517cb77637 | ||
|
|
14bd89a991 | ||
|
|
304de29924 | ||
|
|
ab3055150f | ||
|
|
6b9c7aa9c5 | ||
|
|
040f47b59c | ||
|
|
eac7834083 | ||
|
|
135a298080 | ||
|
|
0065a86371 | ||
|
|
2a842a2f50 | ||
|
|
231c02e00e | ||
|
|
4de4587ea6 | ||
|
|
8675e1d13f | ||
|
|
6ceacc68cc | ||
|
|
4aacf134b7 | ||
|
|
0605772715 | ||
|
|
3fa53556f4 | ||
|
|
76510b8971 | ||
|
|
66162966b9 | ||
|
|
71e1571c39 | ||
|
|
806b761e74 | ||
|
|
0176b38958 | ||
|
|
7a180c7310 | ||
|
|
3e1120182c | ||
|
|
8e86ce671c | ||
|
|
f75a324030 | ||
|
|
3fabff93f6 | ||
|
|
e74efc4e76 | ||
|
|
472ed0753d | ||
|
|
67538ff60c | ||
|
|
ae8bd69106 | ||
|
|
2538890b52 | ||
|
|
87dd819ae4 | ||
|
|
7ec560d4a2 | ||
|
|
6f9cd6a16b | ||
|
|
923af88336 | ||
|
|
5b6667c461 | ||
|
|
6f00740f67 | ||
|
|
248863cf16 | ||
|
|
97d48823dd | ||
|
|
5eb41e1a15 | ||
|
|
4a4837d9f5 | ||
|
|
4ad72fab7b | ||
|
|
fe68e45609 | ||
|
|
291b9a84ef | ||
|
|
2f9b7b188a | ||
|
|
d04d41bc23 | ||
|
|
6cb3d7167f | ||
|
|
90b1659a18 | ||
|
|
1aaf44f9b0 | ||
|
|
d7cfb84351 | ||
|
|
d28cf0b76d | ||
|
|
b4a3236284 | ||
|
|
556168892d | ||
|
|
77667be570 | ||
|
|
f48a912287 | ||
|
|
af30d0831d | ||
|
|
5989eb8f6e | ||
|
|
2bb778834b | ||
|
|
a5ce191e4d | ||
|
|
7617756576 | ||
|
|
0dfd3a5b0e | ||
|
|
61a54f48c5 | ||
|
|
5ca0237e34 | ||
|
|
ab1207e461 | ||
|
|
75fea4f7c0 | ||
|
|
fb34eb5394 |
@@ -6,6 +6,7 @@
|
|||||||
USERID=
|
USERID=
|
||||||
GROUPID=
|
GROUPID=
|
||||||
############################################################################################################
|
############################################################################################################
|
||||||
|
APP_NAME=Coolify-localhost
|
||||||
APP_ID=development
|
APP_ID=development
|
||||||
APP_ENV=local
|
APP_ENV=local
|
||||||
APP_KEY=
|
APP_KEY=
|
||||||
|
|||||||
26
.github/ISSUE_TEMPLATE/BUG_REPORT.yml
vendored
Normal file
26
.github/ISSUE_TEMPLATE/BUG_REPORT.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
name: Bug report
|
||||||
|
description: Create a new bug report
|
||||||
|
title: '[Bug]: '
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Description
|
||||||
|
description: A clear and concise description of the problem
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Minimal Reproduction (if possible, example repository)
|
||||||
|
description: Please provide a step by step guide to reproduce the issue
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Exception or Error
|
||||||
|
description: Please provide error logs if possible.
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: Version
|
||||||
|
description: Coolify's version (see bottom left corner).
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
8
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
8
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: 🤔 Community Support (Chat)
|
||||||
|
url: https://coollabs.io/discord
|
||||||
|
about: Reach out to us on Discord.
|
||||||
|
- name: 🙋♂️ Feature Requests
|
||||||
|
url: https://github.com/coollabsio/coolify/discussions/categories/feature-requests-ideas
|
||||||
|
about: All feature requests will be discussed here.
|
||||||
84
.github/workflows/coolify-helper-next.yml
vendored
Normal file
84
.github/workflows/coolify-helper-next.yml
vendored
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
name: Coolify Helper Image Development (v4)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "next" ]
|
||||||
|
paths:
|
||||||
|
- .github/workflows/coolify-helper.yml
|
||||||
|
- docker/coolify-helper/Dockerfile
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: "coollabsio/coolify-helper"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
amd64:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Login to ghcr.io
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Build image and push to registry
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
no-cache: true
|
||||||
|
context: .
|
||||||
|
file: docker/coolify-helper/Dockerfile
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: true
|
||||||
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:next
|
||||||
|
aarch64:
|
||||||
|
runs-on: [ self-hosted, arm64 ]
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Login to ghcr.io
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Build image and push to registry
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
no-cache: true
|
||||||
|
context: .
|
||||||
|
file: docker/coolify-helper/Dockerfile
|
||||||
|
platforms: linux/aarch64
|
||||||
|
push: true
|
||||||
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:next-aarch64
|
||||||
|
merge-manifest:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
needs: [ amd64, aarch64 ]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
- name: Login to ghcr.io
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Create & publish manifest
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools create --append ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:next-aarch64 --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:next
|
||||||
|
- uses: sarisia/actions-status-discord@v1
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
webhook: ${{ secrets.DISCORD_WEBHOOK_DEV_RELEASE_CHANNEL }}
|
||||||
8
.github/workflows/coolify-helper.yml
vendored
8
.github/workflows/coolify-helper.yml
vendored
@@ -2,7 +2,7 @@ name: Coolify Helper Image (v4)
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main", "next" ]
|
branches: [ "main" ]
|
||||||
paths:
|
paths:
|
||||||
- .github/workflows/coolify-helper.yml
|
- .github/workflows/coolify-helper.yml
|
||||||
- docker/coolify-helper/Dockerfile
|
- docker/coolify-helper/Dockerfile
|
||||||
@@ -55,7 +55,7 @@ jobs:
|
|||||||
file: docker/coolify-helper/Dockerfile
|
file: docker/coolify-helper/Dockerfile
|
||||||
platforms: linux/aarch64
|
platforms: linux/aarch64
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:aarch64
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-aarch64
|
||||||
merge-manifest:
|
merge-manifest:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
@@ -78,3 +78,7 @@ jobs:
|
|||||||
- name: Create & publish manifest
|
- name: Create & publish manifest
|
||||||
run: |
|
run: |
|
||||||
docker buildx imagetools create --append ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:aarch64 --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
docker buildx imagetools create --append ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:aarch64 --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||||
|
- uses: sarisia/actions-status-discord@v1
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
webhook: ${{ secrets.DISCORD_WEBHOOK_PROD_RELEASE_CHANNEL }}
|
||||||
|
|||||||
7
.github/workflows/development-build.yml
vendored
7
.github/workflows/development-build.yml
vendored
@@ -3,6 +3,9 @@ name: Development Build (v4)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: ["next"]
|
branches: ["next"]
|
||||||
|
paths-ignore:
|
||||||
|
- .github/workflows/coolify-helper.yml
|
||||||
|
- docker/coolify-helper/Dockerfile
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
@@ -10,7 +13,7 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
amd64:
|
amd64:
|
||||||
runs-on: ubuntu-latest
|
runs-on: [self-hosted, x64]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Login to ghcr.io
|
- name: Login to ghcr.io
|
||||||
@@ -73,4 +76,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_RELEASE_CHANNEL }}
|
webhook: ${{ secrets.DISCORD_WEBHOOK_DEV_RELEASE_CHANNEL }}
|
||||||
|
|||||||
2
.github/workflows/production-build.yml
vendored
2
.github/workflows/production-build.yml
vendored
@@ -10,7 +10,7 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
amd64:
|
amd64:
|
||||||
runs-on: ubuntu-latest
|
runs-on: [self-hosted, x64]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Login to ghcr.io
|
- name: Login to ghcr.io
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -31,3 +31,4 @@ _ide_helper.php
|
|||||||
_ide_helper_models.php
|
_ide_helper_models.php
|
||||||
.rnd
|
.rnd
|
||||||
/.ssh
|
/.ssh
|
||||||
|
scripts/load-test/*
|
||||||
|
|||||||
52
README.md
52
README.md
@@ -1,20 +1,30 @@
|
|||||||
# Coolify v4 Beta
|
# About the Project
|
||||||
|
|
||||||
An open-source & self-hostable Heroku / Netlify alternative.
|
Coolify is an open-source & self-hostable alternative to Heroku / Netlify / Vercel / etc.
|
||||||
|
|
||||||
|
It helps you to manage your servers, applications, databases on your own hardware, all you need is SSH connection. You can manage VPS, Bare Metal, Raspberry PI's anything.
|
||||||
|
|
||||||
|
Image if you could have the ease of a cloud but with your own servers. That is **Coolify**.
|
||||||
|
|
||||||
|
No vendor lock-in, which means that all the configuration for your applications/databases/etc are saved to your server. So if you decide to stop using Coolify (oh nooo), you could still manage your running resources. You just lose the automations and all the magic. 🪄️
|
||||||
|
|
||||||
|
For more information, take a look at our landing page [here](https://coolify.io).
|
||||||
|
|
||||||
|
> If you are looking for previous (v3) version, it is [here](https://github.com/coollabsio/coolify/tree/v3).
|
||||||
|
|
||||||
|
# Cloud
|
||||||
|
|
||||||
|
If you do not want to self-host Coolify, there is a paid cloud version available: https://app.coolify.io
|
||||||
|
|
||||||
|
You can easily attach your own servers, get all the automations, free email notifications, etc.
|
||||||
|
|
||||||
|
For more information & pricing, take a look at our landing page [here](https://coolify.io).
|
||||||
|
|
||||||
# Beta
|
# Beta
|
||||||
|
|
||||||
You are checking the next-gen of Coolify, aka v4. Hi 👋
|
The latest version (v4) is still in beta. That does not mean it is unstable. All the features that are available are stable enough be usable in real-life.
|
||||||
|
|
||||||
It is still in beta, lots of improvements will come every day. Things could break, but we are working hard to make it stable as soon as possible. If you find any bugs, please report them.
|
There are hundreds of people using it for managing their client's applications, freelancers, hobbyists, businesses.
|
||||||
|
|
||||||
Automatic updates are available, so you will receive the latest version as soon as it is released.
|
|
||||||
|
|
||||||
If you are looking for v3, check out the [v3 branch](https://github.com/coollabsio/coolify/tree/v3).
|
|
||||||
|
|
||||||
## What's new?
|
|
||||||
|
|
||||||
Well, the whole tech stack changed, core is different, so yeah, a lot (documentation incoming).
|
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
@@ -26,13 +36,19 @@ You can find the installation script [here](./scripts/install.sh).
|
|||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
- Twitter: [@heyandras](https://twitter.com/heyandras)
|
Contact us [here](https://docs.coollabs.io/contact).
|
||||||
- Mastodon: [@andrasbacsai@fosstodon.org](https://fosstodon.org/@andrasbacsai)
|
|
||||||
- Email: [andras@coollabs.io](mailto:andras@coollabs.io)
|
|
||||||
- Discord: [Invitation](https://coollabs.io/discord)
|
|
||||||
- Telegram: [@andrasbacsai](https://t.me/andrasbacsai)
|
|
||||||
|
|
||||||
---
|
## Recognitions
|
||||||
|
|
||||||
|
<a href="https://news.ycombinator.com/item?id=26624341">
|
||||||
|
<img
|
||||||
|
style="width: 250px; height: 54px;" width="250" height="54"
|
||||||
|
alt="Featured on Hacker News"
|
||||||
|
src="https://hackernews-badge.vercel.app/api?id=26624341"
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="https://www.producthunt.com/posts/coolify?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-coolify" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=338273&theme=light" alt="Coolify - An open-source & self-hostable Heroku, Netlify alternative | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
||||||
|
|
||||||
## 💰 Financial Contributors
|
## 💰 Financial Contributors
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,12 @@ namespace App\Actions\CoolifyTask;
|
|||||||
use App\Enums\ActivityTypes;
|
use App\Enums\ActivityTypes;
|
||||||
use App\Enums\ProcessStatus;
|
use App\Enums\ProcessStatus;
|
||||||
use App\Jobs\ApplicationDeploymentJob;
|
use App\Jobs\ApplicationDeploymentJob;
|
||||||
|
use App\Models\Server;
|
||||||
use Illuminate\Process\ProcessResult;
|
use Illuminate\Process\ProcessResult;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Process;
|
use Illuminate\Support\Facades\Process;
|
||||||
use Spatie\Activitylog\Models\Activity;
|
use Spatie\Activitylog\Models\Activity;
|
||||||
|
|
||||||
const TIMEOUT = 3600;
|
|
||||||
const IDLE_TIMEOUT = 3600;
|
|
||||||
|
|
||||||
class RunRemoteProcess
|
class RunRemoteProcess
|
||||||
{
|
{
|
||||||
public Activity $activity;
|
public Activity $activity;
|
||||||
@@ -76,8 +74,7 @@ class RunRemoteProcess
|
|||||||
$this->time_start = hrtime(true);
|
$this->time_start = hrtime(true);
|
||||||
|
|
||||||
$status = ProcessStatus::IN_PROGRESS;
|
$status = ProcessStatus::IN_PROGRESS;
|
||||||
|
$processResult = Process::forever()->run($this->getCommand(), $this->handleOutput(...));
|
||||||
$processResult = Process::timeout(TIMEOUT)->idleTimeout(IDLE_TIMEOUT)->run($this->getCommand(), $this->handleOutput(...));
|
|
||||||
|
|
||||||
if ($this->activity->properties->get('status') === ProcessStatus::ERROR->value) {
|
if ($this->activity->properties->get('status') === ProcessStatus::ERROR->value) {
|
||||||
$status = ProcessStatus::ERROR;
|
$status = ProcessStatus::ERROR;
|
||||||
@@ -97,9 +94,8 @@ class RunRemoteProcess
|
|||||||
'status' => $status->value,
|
'status' => $status->value,
|
||||||
]);
|
]);
|
||||||
$this->activity->save();
|
$this->activity->save();
|
||||||
|
|
||||||
if ($processResult->exitCode() != 0 && !$this->ignore_errors) {
|
if ($processResult->exitCode() != 0 && !$this->ignore_errors) {
|
||||||
throw new \RuntimeException($processResult->errorOutput());
|
throw new \RuntimeException($processResult->errorOutput(), $processResult->exitCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $processResult;
|
return $processResult;
|
||||||
@@ -107,13 +103,11 @@ class RunRemoteProcess
|
|||||||
|
|
||||||
protected function getCommand(): string
|
protected function getCommand(): string
|
||||||
{
|
{
|
||||||
$user = $this->activity->getExtraProperty('user');
|
$server_uuid = $this->activity->getExtraProperty('server_uuid');
|
||||||
$server_ip = $this->activity->getExtraProperty('server_ip');
|
|
||||||
$private_key_location = $this->activity->getExtraProperty('private_key_location');
|
|
||||||
$port = $this->activity->getExtraProperty('port');
|
|
||||||
$command = $this->activity->getExtraProperty('command');
|
$command = $this->activity->getExtraProperty('command');
|
||||||
|
$server = Server::whereUuid($server_uuid)->firstOrFail();
|
||||||
|
|
||||||
return generate_ssh_command($private_key_location, $server_ip, $user, $port, $command);
|
return generateSshCommand($server, $command);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function handleOutput(string $type, string $output)
|
protected function handleOutput(string $type, string $output)
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class StartPostgresql
|
|||||||
],
|
],
|
||||||
'networks' => [
|
'networks' => [
|
||||||
$this->database->destination->network => [
|
$this->database->destination->network => [
|
||||||
'external' => false,
|
'external' => true,
|
||||||
'name' => $this->database->destination->network,
|
'name' => $this->database->destination->network,
|
||||||
'attachable' => true,
|
'attachable' => true,
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -57,13 +57,13 @@ class CheckResaleLicense
|
|||||||
throw new \Exception('Invalid license key.');
|
throw new \Exception('Invalid license key.');
|
||||||
}
|
}
|
||||||
throw new \Exception('Cannot activate license key.');
|
throw new \Exception('Cannot activate license key.');
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $e) {
|
||||||
ray($th);
|
ray($e);
|
||||||
$settings->update([
|
$settings->update([
|
||||||
'resale_license' => null,
|
'resale_license' => null,
|
||||||
'is_resale_license_active' => false,
|
'is_resale_license_active' => false,
|
||||||
]);
|
]);
|
||||||
throw $th;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Actions\Proxy;
|
namespace App\Actions\Proxy;
|
||||||
|
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class CheckConfigurationSync
|
class CheckConfiguration
|
||||||
{
|
{
|
||||||
public function __invoke(Server $server, bool $reset = false)
|
use AsAction;
|
||||||
|
public function handle(Server $server, bool $reset = false)
|
||||||
{
|
{
|
||||||
$proxy_path = get_proxy_path();
|
$proxy_path = get_proxy_path();
|
||||||
$proxy_configuration = instant_remote_process([
|
$proxy_configuration = instant_remote_process([
|
||||||
@@ -16,10 +18,7 @@ class CheckConfigurationSync
|
|||||||
|
|
||||||
if ($reset || is_null($proxy_configuration)) {
|
if ($reset || is_null($proxy_configuration)) {
|
||||||
$proxy_configuration = Str::of(generate_default_proxy_configuration($server))->trim()->value;
|
$proxy_configuration = Str::of(generate_default_proxy_configuration($server))->trim()->value;
|
||||||
resolve(SaveConfigurationSync::class)($server, $proxy_configuration);
|
|
||||||
return $proxy_configuration;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $proxy_configuration;
|
return $proxy_configuration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,18 +4,22 @@ namespace App\Actions\Proxy;
|
|||||||
|
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
class SaveConfigurationSync
|
class SaveConfiguration
|
||||||
{
|
{
|
||||||
public function __invoke(Server $server, string $configuration)
|
use AsAction;
|
||||||
|
|
||||||
|
public function handle(Server $server)
|
||||||
{
|
{
|
||||||
|
$proxy_settings = CheckConfiguration::run($server, true);
|
||||||
$proxy_path = get_proxy_path();
|
$proxy_path = get_proxy_path();
|
||||||
$docker_compose_yml_base64 = base64_encode($configuration);
|
$docker_compose_yml_base64 = base64_encode($proxy_settings);
|
||||||
|
|
||||||
$server->proxy->last_saved_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;
|
$server->proxy->last_saved_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;
|
||||||
$server->save();
|
$server->save();
|
||||||
|
|
||||||
instant_remote_process([
|
return instant_remote_process([
|
||||||
"mkdir -p $proxy_path",
|
"mkdir -p $proxy_path",
|
||||||
"echo '$docker_compose_yml_base64' | base64 -d > $proxy_path/docker-compose.yml",
|
"echo '$docker_compose_yml_base64' | base64 -d > $proxy_path/docker-compose.yml",
|
||||||
], $server);
|
], $server);
|
||||||
@@ -6,14 +6,19 @@ use App\Enums\ProxyStatus;
|
|||||||
use App\Enums\ProxyTypes;
|
use App\Enums\ProxyTypes;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
use Spatie\Activitylog\Models\Activity;
|
use Spatie\Activitylog\Models\Activity;
|
||||||
|
|
||||||
class StartProxy
|
class StartProxy
|
||||||
{
|
{
|
||||||
public function __invoke(Server $server): Activity
|
use AsAction;
|
||||||
|
public function handle(Server $server, bool $async = true): Activity|string
|
||||||
{
|
{
|
||||||
// TODO: check for other proxies
|
$proxyType = data_get($server,'proxy.type');
|
||||||
if (is_null(data_get($server, 'proxy.type'))) {
|
if ($proxyType === 'none') {
|
||||||
|
return 'OK';
|
||||||
|
}
|
||||||
|
if (is_null($proxyType)) {
|
||||||
$server->proxy->type = ProxyTypes::TRAEFIK_V2->value;
|
$server->proxy->type = ProxyTypes::TRAEFIK_V2->value;
|
||||||
$server->proxy->status = ProxyStatus::EXITED->value;
|
$server->proxy->status = ProxyStatus::EXITED->value;
|
||||||
$server->save();
|
$server->save();
|
||||||
@@ -29,28 +34,44 @@ class StartProxy
|
|||||||
return "docker network ls --format '{{.Name}}' | grep '^$network$' >/dev/null 2>&1 || docker network create --attachable $network > /dev/null 2>&1";
|
return "docker network ls --format '{{.Name}}' | grep '^$network$' >/dev/null 2>&1 || docker network create --attachable $network > /dev/null 2>&1";
|
||||||
});
|
});
|
||||||
|
|
||||||
$configuration = resolve(CheckConfigurationSync::class)($server);
|
$configuration = CheckConfiguration::run($server);
|
||||||
|
if (!$configuration) {
|
||||||
|
throw new \Exception("Configuration is not synced");
|
||||||
|
}
|
||||||
$docker_compose_yml_base64 = base64_encode($configuration);
|
$docker_compose_yml_base64 = base64_encode($configuration);
|
||||||
$server->proxy->last_applied_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;
|
$server->proxy->last_applied_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;
|
||||||
$server->save();
|
$server->save();
|
||||||
|
$commands = [
|
||||||
$activity = remote_process([
|
"command -v lsof >/dev/null || echo '####### Installing lsof...'",
|
||||||
"echo 'Creating required Docker networks...'",
|
"command -v lsof >/dev/null || apt-get update",
|
||||||
|
"command -v lsof >/dev/null || apt install -y lsof",
|
||||||
|
"command -v lsof >/dev/null || command -v fuser >/dev/null || apt install -y psmisc",
|
||||||
|
"echo '####### Creating required Docker networks...'",
|
||||||
...$create_networks_command,
|
...$create_networks_command,
|
||||||
"cd $proxy_path",
|
"cd $proxy_path",
|
||||||
"echo 'Creating Docker Compose file...'",
|
"echo '####### Creating Docker Compose file...'",
|
||||||
"echo 'Pulling docker image...'",
|
"echo '####### Pulling docker image...'",
|
||||||
'docker compose pull -q',
|
'docker compose pull',
|
||||||
"echo 'Stopping existing proxy...'",
|
"echo '####### Stopping existing coolify-proxy...'",
|
||||||
'docker compose down -v --remove-orphans',
|
"docker compose down -v --remove-orphans > /dev/null 2>&1 || true",
|
||||||
"lsof -nt -i:80 | xargs -r kill -9",
|
"command -v fuser >/dev/null || command -v lsof >/dev/null || echo '####### Could not kill existing processes listening on port 80 & 443. Please stop the process holding these ports...'",
|
||||||
"lsof -nt -i:443 | xargs -r kill -9",
|
"command -v lsof >/dev/null && lsof -nt -i:80 | xargs -r kill -9 || true",
|
||||||
"echo 'Starting proxy...'",
|
"command -v lsof >/dev/null && lsof -nt -i:443 | xargs -r kill -9 || true",
|
||||||
|
"command -v fuser >/dev/null && fuser -k 80/tcp || true",
|
||||||
|
"command -v fuser >/dev/null && fuser -k 443/tcp || true",
|
||||||
|
"systemctl disable nginx > /dev/null 2>&1 || true",
|
||||||
|
"systemctl disable apache2 > /dev/null 2>&1 || true",
|
||||||
|
"systemctl disable apache > /dev/null 2>&1 || true",
|
||||||
|
"echo '####### Starting coolify-proxy...'",
|
||||||
'docker compose up -d --remove-orphans',
|
'docker compose up -d --remove-orphans',
|
||||||
"echo 'Proxy installed successfully...'"
|
"echo '####### Proxy installed successfully...'"
|
||||||
], $server);
|
];
|
||||||
|
if (!$async) {
|
||||||
return $activity;
|
instant_remote_process($commands, $server);
|
||||||
|
return 'OK';
|
||||||
|
} else {
|
||||||
|
$activity = remote_process($commands, $server);
|
||||||
|
return $activity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,39 +4,21 @@ namespace App\Actions\Server;
|
|||||||
|
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\StandaloneDocker;
|
use App\Models\StandaloneDocker;
|
||||||
use App\Models\Team;
|
|
||||||
|
|
||||||
class InstallDocker
|
class InstallDocker
|
||||||
{
|
{
|
||||||
public function __invoke(Server $server, Team $team)
|
public function __invoke(Server $server, bool $instant = false)
|
||||||
{
|
{
|
||||||
$dockerVersion = '23.0';
|
$dockerVersion = '24.0';
|
||||||
$config = base64_encode('{ "live-restore": true }');
|
$config = base64_encode('{
|
||||||
if (isDev()) {
|
"log-driver": "json-file",
|
||||||
$activity = remote_process([
|
"log-opts": {
|
||||||
"echo ####### Installing Prerequisites...",
|
"max-size": "10m",
|
||||||
"echo ####### Installing/updating Docker Engine...",
|
"max-file": "3"
|
||||||
"echo ####### Configuring Docker Engine (merging existing configuration with the required)...",
|
}
|
||||||
"echo ####### Restarting Docker Engine...",
|
}');
|
||||||
], $server);
|
$found = StandaloneDocker::where('server_id', $server->id);
|
||||||
} else {
|
if ($found->count() == 0 && $server->id) {
|
||||||
$activity = remote_process([
|
|
||||||
"echo ####### Installing Prerequisites...",
|
|
||||||
"command -v jq >/dev/null || apt-get update",
|
|
||||||
"command -v jq >/dev/null || apt install -y jq",
|
|
||||||
"echo ####### Installing/updating Docker Engine...",
|
|
||||||
"curl https://releases.rancher.com/install-docker/{$dockerVersion}.sh | sh",
|
|
||||||
"echo ####### Configuring Docker Engine (merging existing configuration with the required)...",
|
|
||||||
"test -s /etc/docker/daemon.json && cp /etc/docker/daemon.json \"/etc/docker/daemon.json.original-`date +\"%Y%m%d-%H%M%S\"`\" || echo '{$config}' | base64 -d > /etc/docker/daemon.json",
|
|
||||||
"echo '{$config}' | base64 -d > /etc/docker/daemon.json.coolify",
|
|
||||||
"cat <<< $(jq . /etc/docker/daemon.json.coolify) > /etc/docker/daemon.json.coolify",
|
|
||||||
"cat <<< $(jq -s '.[0] * .[1]' /etc/docker/daemon.json /etc/docker/daemon.json.coolify) > /etc/docker/daemon.json",
|
|
||||||
"echo ####### Restarting Docker Engine...",
|
|
||||||
"systemctl restart docker",
|
|
||||||
"echo ####### Creating default network...",
|
|
||||||
"docker network create --attachable coolify",
|
|
||||||
"echo ####### Done!"
|
|
||||||
], $server);
|
|
||||||
StandaloneDocker::create([
|
StandaloneDocker::create([
|
||||||
'name' => 'coolify',
|
'name' => 'coolify',
|
||||||
'network' => 'coolify',
|
'network' => 'coolify',
|
||||||
@@ -44,7 +26,38 @@ class InstallDocker
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isDev() && $server->id === 0) {
|
||||||
return $activity;
|
$command = [
|
||||||
|
"echo '####### Installing Prerequisites...'",
|
||||||
|
"sleep 1",
|
||||||
|
"echo '####### Installing/updating Docker Engine...'",
|
||||||
|
"echo '####### Configuring Docker Engine (merging existing configuration with the required)...'",
|
||||||
|
"sleep 4",
|
||||||
|
"echo '####### Restarting Docker Engine...'",
|
||||||
|
"ls -l /tmp"
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$command = [
|
||||||
|
"echo '####### Installing Prerequisites...'",
|
||||||
|
"command -v jq >/dev/null || apt-get update",
|
||||||
|
"command -v jq >/dev/null || apt install -y jq",
|
||||||
|
"echo '####### Installing/updating Docker Engine...'",
|
||||||
|
"curl https://releases.rancher.com/install-docker/{$dockerVersion}.sh | sh",
|
||||||
|
"echo '####### Configuring Docker Engine (merging existing configuration with the required)...'",
|
||||||
|
"test -s /etc/docker/daemon.json && cp /etc/docker/daemon.json \"/etc/docker/daemon.json.original-`date +\"%Y%m%d-%H%M%S\"`\" || echo '{$config}' | base64 -d > /etc/docker/daemon.json",
|
||||||
|
"echo '{$config}' | base64 -d > /etc/docker/daemon.json.coolify",
|
||||||
|
"cat <<< $(jq . /etc/docker/daemon.json.coolify) > /etc/docker/daemon.json.coolify",
|
||||||
|
"cat <<< $(jq -s '.[0] * .[1]' /etc/docker/daemon.json /etc/docker/daemon.json.coolify) > /etc/docker/daemon.json",
|
||||||
|
"echo '####### Restarting Docker Engine...'",
|
||||||
|
"systemctl restart docker",
|
||||||
|
"echo '####### Creating default Docker network (coolify)...'",
|
||||||
|
"docker network create --attachable coolify >/dev/null 2>&1 || true",
|
||||||
|
"echo '####### Done!'"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if ($instant) {
|
||||||
|
return instant_remote_process($command, $server);
|
||||||
|
}
|
||||||
|
return remote_process($command, $server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ use App\Models\Server;
|
|||||||
|
|
||||||
class UpdateCoolify
|
class UpdateCoolify
|
||||||
{
|
{
|
||||||
public Server $server;
|
public ?Server $server = null;
|
||||||
public string $latest_version;
|
public ?string $latestVersion = null;
|
||||||
public string $current_version;
|
public ?string $currentVersion = null;
|
||||||
|
|
||||||
public function __invoke(bool $force)
|
public function __invoke(bool $force)
|
||||||
{
|
{
|
||||||
@@ -17,13 +17,16 @@ class UpdateCoolify
|
|||||||
$settings = InstanceSettings::get();
|
$settings = InstanceSettings::get();
|
||||||
ray('Running InstanceAutoUpdateJob');
|
ray('Running InstanceAutoUpdateJob');
|
||||||
$localhost_name = 'localhost';
|
$localhost_name = 'localhost';
|
||||||
$this->server = Server::where('name', $localhost_name)->firstOrFail();
|
$this->server = Server::where('name', $localhost_name)->first();
|
||||||
$this->latest_version = get_latest_version_of_coolify();
|
if (!$this->server) {
|
||||||
$this->current_version = config('version');
|
return;
|
||||||
ray('latest version:' . $this->latest_version . " current version: " . $this->current_version . ' force: ' . $force);
|
}
|
||||||
|
$this->latestVersion = get_latest_version_of_coolify();
|
||||||
|
$this->currentVersion = config('version');
|
||||||
|
ray('latest version:' . $this->latestVersion . " current version: " . $this->currentVersion . ' force: ' . $force);
|
||||||
if ($settings->next_channel) {
|
if ($settings->next_channel) {
|
||||||
ray('next channel enabled');
|
ray('next channel enabled');
|
||||||
$this->latest_version = 'next';
|
$this->latestVersion = 'next';
|
||||||
}
|
}
|
||||||
if ($force) {
|
if ($force) {
|
||||||
$this->update();
|
$this->update();
|
||||||
@@ -31,27 +34,27 @@ class UpdateCoolify
|
|||||||
if (!$settings->is_auto_update_enabled) {
|
if (!$settings->is_auto_update_enabled) {
|
||||||
return 'Auto update is disabled';
|
return 'Auto update is disabled';
|
||||||
}
|
}
|
||||||
if ($this->latest_version === $this->current_version) {
|
if ($this->latestVersion === $this->currentVersion) {
|
||||||
return 'Already on latest version';
|
return 'Already on latest version';
|
||||||
}
|
}
|
||||||
if (version_compare($this->latest_version, $this->current_version, '<')) {
|
if (version_compare($this->latestVersion, $this->currentVersion, '<')) {
|
||||||
return 'Latest version is lower than current version?!';
|
return 'Latest version is lower than current version?!';
|
||||||
}
|
}
|
||||||
$this->update();
|
$this->update();
|
||||||
}
|
}
|
||||||
send_internal_notification('InstanceAutoUpdateJob done to version: ' . $this->latest_version . ' from version: ' . $this->current_version);
|
send_internal_notification('InstanceAutoUpdateJob done to version: ' . $this->latestVersion . ' from version: ' . $this->currentVersion);
|
||||||
} catch (\Exception $th) {
|
} catch (\Throwable $e) {
|
||||||
ray('InstanceAutoUpdateJob failed');
|
ray('InstanceAutoUpdateJob failed');
|
||||||
ray($th->getMessage());
|
ray($e->getMessage());
|
||||||
send_internal_notification('InstanceAutoUpdateJob failed: ' . $th->getMessage());
|
send_internal_notification('InstanceAutoUpdateJob failed: ' . $e->getMessage());
|
||||||
throw $th;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function update()
|
private function update()
|
||||||
{
|
{
|
||||||
if (isDev()) {
|
if (isDev()) {
|
||||||
ray("Running update on local docker container. Updating to $this->latest_version");
|
ray("Running update on local docker container. Updating to $this->latestVersion");
|
||||||
remote_process([
|
remote_process([
|
||||||
"sleep 10"
|
"sleep 10"
|
||||||
], $this->server);
|
], $this->server);
|
||||||
@@ -61,7 +64,7 @@ class UpdateCoolify
|
|||||||
ray('Running update on production server');
|
ray('Running update on production server');
|
||||||
remote_process([
|
remote_process([
|
||||||
"curl -fsSL https://cdn.coollabs.io/coolify/upgrade.sh -o /data/coolify/source/upgrade.sh",
|
"curl -fsSL https://cdn.coollabs.io/coolify/upgrade.sh -o /data/coolify/source/upgrade.sh",
|
||||||
"bash /data/coolify/source/upgrade.sh $this->latest_version"
|
"bash /data/coolify/source/upgrade.sh $this->latestVersion"
|
||||||
], $this->server);
|
], $this->server);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
247
app/Console/Commands/Emails.php
Normal file
247
app/Console/Commands/Emails.php
Normal file
@@ -0,0 +1,247 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Jobs\SendConfirmationForWaitlistJob;
|
||||||
|
use App\Models\Application;
|
||||||
|
use App\Models\ApplicationPreview;
|
||||||
|
use App\Models\ScheduledDatabaseBackup;
|
||||||
|
use App\Models\Server;
|
||||||
|
use App\Models\StandalonePostgresql;
|
||||||
|
use App\Models\Team;
|
||||||
|
use App\Models\TeamInvitation;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Waitlist;
|
||||||
|
use App\Notifications\Application\DeploymentFailed;
|
||||||
|
use App\Notifications\Application\DeploymentSuccess;
|
||||||
|
use App\Notifications\Application\StatusChanged;
|
||||||
|
use App\Notifications\Database\BackupFailed;
|
||||||
|
use App\Notifications\Database\BackupSuccess;
|
||||||
|
use App\Notifications\Test;
|
||||||
|
use App\Notifications\TransactionalEmails\InvitationLink;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Mail\Message;
|
||||||
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
use Mail;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
use function Laravel\Prompts\confirm;
|
||||||
|
use function Laravel\Prompts\select;
|
||||||
|
use function Laravel\Prompts\text;
|
||||||
|
|
||||||
|
class Emails extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'emails';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Send out test / prod emails';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
private ?MailMessage $mail = null;
|
||||||
|
private ?string $email = null;
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$type = select(
|
||||||
|
'Which Email should be sent?',
|
||||||
|
options: [
|
||||||
|
'emails-test' => 'Test',
|
||||||
|
'application-deployment-success' => 'Application - Deployment Success',
|
||||||
|
'application-deployment-failed' => 'Application - Deployment Failed',
|
||||||
|
'application-status-changed' => 'Application - Status Changed',
|
||||||
|
'backup-success' => 'Database - Backup Success',
|
||||||
|
'backup-failed' => 'Database - Backup Failed',
|
||||||
|
// 'invitation-link' => 'Invitation Link',
|
||||||
|
'waitlist-invitation-link' => 'Waitlist Invitation Link',
|
||||||
|
'waitlist-confirmation' => 'Waitlist Confirmation',
|
||||||
|
'realusers-before-trial' => 'REAL - Registered Users Before Trial without Subscription',
|
||||||
|
'realusers-server-lost-connection' => 'REAL - Server Lost Connection',
|
||||||
|
],
|
||||||
|
);
|
||||||
|
$emailsGathered = ['realusers-before-trial','realusers-server-lost-connection'];
|
||||||
|
if (!in_array($type, $emailsGathered)) {
|
||||||
|
$this->email = text('Email Address to send to');
|
||||||
|
}
|
||||||
|
set_transanctional_email_settings();
|
||||||
|
|
||||||
|
$this->mail = new MailMessage();
|
||||||
|
$this->mail->subject("Test Email");
|
||||||
|
switch ($type) {
|
||||||
|
case 'emails-test':
|
||||||
|
$this->mail = (new Test())->toMail();
|
||||||
|
$this->sendEmail();
|
||||||
|
break;
|
||||||
|
case 'application-deployment-success':
|
||||||
|
$application = Application::all()->first();
|
||||||
|
$this->mail = (new DeploymentSuccess($application, 'test'))->toMail();
|
||||||
|
$this->sendEmail();
|
||||||
|
break;
|
||||||
|
case 'application-deployment-failed':
|
||||||
|
$application = Application::all()->first();
|
||||||
|
$preview = ApplicationPreview::all()->first();
|
||||||
|
if (!$preview) {
|
||||||
|
$preview = ApplicationPreview::create([
|
||||||
|
'application_id' => $application->id,
|
||||||
|
'pull_request_id' => 1,
|
||||||
|
'pull_request_html_url' => 'http://example.com',
|
||||||
|
'fqdn' => $application->fqdn,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$this->mail = (new DeploymentFailed($application, 'test'))->toMail();
|
||||||
|
$this->sendEmail();
|
||||||
|
$this->mail = (new DeploymentFailed($application, 'test', $preview))->toMail();
|
||||||
|
$this->sendEmail();
|
||||||
|
break;
|
||||||
|
case 'application-status-changed':
|
||||||
|
$application = Application::all()->first();
|
||||||
|
$this->mail = (new StatusChanged($application))->toMail();
|
||||||
|
$this->sendEmail();
|
||||||
|
break;
|
||||||
|
case 'backup-failed':
|
||||||
|
$backup = ScheduledDatabaseBackup::all()->first();
|
||||||
|
$db = StandalonePostgresql::all()->first();
|
||||||
|
if (!$backup) {
|
||||||
|
$backup = ScheduledDatabaseBackup::create([
|
||||||
|
'enabled' => true,
|
||||||
|
'frequency' => 'daily',
|
||||||
|
'save_s3' => false,
|
||||||
|
'database_id' => $db->id,
|
||||||
|
'database_type' => $db->getMorphClass(),
|
||||||
|
'team_id' => 0,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$output = 'Because of an error, the backup of the database ' . $db->name . ' failed.';
|
||||||
|
$this->mail = (new BackupFailed($backup, $db, $output))->toMail();
|
||||||
|
$this->sendEmail();
|
||||||
|
break;
|
||||||
|
case 'backup-success':
|
||||||
|
$backup = ScheduledDatabaseBackup::all()->first();
|
||||||
|
$db = StandalonePostgresql::all()->first();
|
||||||
|
if (!$backup) {
|
||||||
|
$backup = ScheduledDatabaseBackup::create([
|
||||||
|
'enabled' => true,
|
||||||
|
'frequency' => 'daily',
|
||||||
|
'save_s3' => false,
|
||||||
|
'database_id' => $db->id,
|
||||||
|
'database_type' => $db->getMorphClass(),
|
||||||
|
'team_id' => 0,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$this->mail = (new BackupSuccess($backup, $db))->toMail();
|
||||||
|
$this->sendEmail();
|
||||||
|
break;
|
||||||
|
// case 'invitation-link':
|
||||||
|
// $user = User::all()->first();
|
||||||
|
// $invitation = TeamInvitation::whereEmail($user->email)->first();
|
||||||
|
// if (!$invitation) {
|
||||||
|
// $invitation = TeamInvitation::create([
|
||||||
|
// 'uuid' => Str::uuid(),
|
||||||
|
// 'email' => $user->email,
|
||||||
|
// 'team_id' => 1,
|
||||||
|
// 'link' => 'http://example.com',
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
// $this->mail = (new InvitationLink($user))->toMail();
|
||||||
|
// $this->sendEmail();
|
||||||
|
// break;
|
||||||
|
case 'waitlist-invitation-link':
|
||||||
|
$this->mail = new MailMessage();
|
||||||
|
$this->mail->view('emails.waitlist-invitation', [
|
||||||
|
'loginLink' => 'https://coolify.io',
|
||||||
|
]);
|
||||||
|
$this->mail->subject('Congratulations! You are invited to join Coolify Cloud.');
|
||||||
|
$this->sendEmail();
|
||||||
|
break;
|
||||||
|
case 'waitlist-confirmation':
|
||||||
|
$found = Waitlist::where('email', $this->email)->first();
|
||||||
|
if ($found) {
|
||||||
|
SendConfirmationForWaitlistJob::dispatch($this->email, $found->uuid);
|
||||||
|
} else {
|
||||||
|
throw new Exception('Waitlist not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'realusers-before-trial':
|
||||||
|
$this->mail = new MailMessage();
|
||||||
|
$this->mail->view('emails.before-trial-conversion');
|
||||||
|
$this->mail->subject('Trial period has been added for all subscription plans.');
|
||||||
|
$teams = Team::doesntHave('subscription')->where('id', '!=', 0)->get();
|
||||||
|
if (!$teams || $teams->isEmpty()) {
|
||||||
|
echo 'No teams found.' . PHP_EOL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$emails = [];
|
||||||
|
foreach ($teams as $team) {
|
||||||
|
foreach ($team->members as $member) {
|
||||||
|
if ($member->email) {
|
||||||
|
$emails[] = $member->email;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$emails = array_unique($emails);
|
||||||
|
$this->info("Sending to " . count($emails) . " emails.");
|
||||||
|
foreach ($emails as $email) {
|
||||||
|
$this->info($email);
|
||||||
|
}
|
||||||
|
$confirmed = confirm('Are you sure?');
|
||||||
|
if ($confirmed) {
|
||||||
|
foreach ($emails as $email) {
|
||||||
|
$this->sendEmail($email);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'realusers-server-lost-connection':
|
||||||
|
$serverId = text('Server Id');
|
||||||
|
$server = Server::find($serverId);
|
||||||
|
if (!$server) {
|
||||||
|
throw new Exception('Server not found');
|
||||||
|
}
|
||||||
|
$admins = [];
|
||||||
|
$members = $server->team->members;
|
||||||
|
foreach ($members as $member) {
|
||||||
|
if ($member->isAdmin()) {
|
||||||
|
$admins[] = $member->email;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->info('Sending to ' . count($admins) . ' admins.');
|
||||||
|
foreach ($admins as $admin) {
|
||||||
|
$this->info($admin);
|
||||||
|
}
|
||||||
|
$this->mail = new MailMessage();
|
||||||
|
$this->mail->view('emails.server-lost-connection', [
|
||||||
|
'name' => $server->name,
|
||||||
|
]);
|
||||||
|
$this->mail->subject('Action required: Server ' . $server->name . ' lost connection.');
|
||||||
|
foreach ($admins as $email) {
|
||||||
|
$this->sendEmail($email);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private function sendEmail(string $email = null)
|
||||||
|
{
|
||||||
|
if ($email) {
|
||||||
|
$this->email = $email;
|
||||||
|
}
|
||||||
|
Mail::send(
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
fn (Message $message) => $message
|
||||||
|
->to($this->email)
|
||||||
|
->subject($this->mail->subject)
|
||||||
|
->html((string)$this->mail->render())
|
||||||
|
);
|
||||||
|
$this->info("Email sent to $this->email successfully. 📧");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,7 +26,7 @@ class Init extends Command
|
|||||||
$deployment->status = ApplicationDeploymentStatus::FAILED->value;
|
$deployment->status = ApplicationDeploymentStatus::FAILED->value;
|
||||||
$deployment->save();
|
$deployment->save();
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
echo "Error: {$e->getMessage()}\n";
|
echo "Error: {$e->getMessage()}\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class SyncBunny extends Command
|
|||||||
$pool->purge("$bunny_cdn/$bunny_cdn_path/$versions"),
|
$pool->purge("$bunny_cdn/$bunny_cdn_path/$versions"),
|
||||||
]);
|
]);
|
||||||
echo "All files uploaded & purged...\n";
|
echo "All files uploaded & purged...\n";
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,20 +6,20 @@ use App\Models\User;
|
|||||||
use App\Models\Waitlist;
|
use App\Models\Waitlist;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class InviteFromWaitlist extends Command
|
class WaitlistInvite extends Command
|
||||||
{
|
{
|
||||||
public Waitlist|null $next_patient = null;
|
public Waitlist|User|null $next_patient = null;
|
||||||
public User|null $new_user = null;
|
|
||||||
public string|null $password = null;
|
public string|null $password = null;
|
||||||
/**
|
/**
|
||||||
* The name and signature of the console command.
|
* The name and signature of the console command.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'app:invite-from-waitlist {email?}';
|
protected $signature = 'waitlist:invite {--people=1} {--only-email} {email?}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
@@ -33,8 +33,23 @@ class InviteFromWaitlist extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
$people = $this->option('people');
|
||||||
|
for ($i = 0; $i < $people; $i++) {
|
||||||
|
$this->main();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private function main() {
|
||||||
if ($this->argument('email')) {
|
if ($this->argument('email')) {
|
||||||
$this->next_patient = Waitlist::where('email', $this->argument('email'))->first();
|
if ($this->option('only-email')) {
|
||||||
|
$this->next_patient = User::whereEmail($this->argument('email'))->first();
|
||||||
|
$this->password = Str::password();
|
||||||
|
$this->next_patient->update([
|
||||||
|
'password' => Hash::make($this->password),
|
||||||
|
'force_password_reset' => true,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$this->next_patient = Waitlist::where('email', $this->argument('email'))->first();
|
||||||
|
}
|
||||||
if (!$this->next_patient) {
|
if (!$this->next_patient) {
|
||||||
$this->error("{$this->argument('email')} not found in the waitlist.");
|
$this->error("{$this->argument('email')} not found in the waitlist.");
|
||||||
return;
|
return;
|
||||||
@@ -43,6 +58,10 @@ class InviteFromWaitlist extends Command
|
|||||||
$this->next_patient = Waitlist::orderBy('created_at', 'asc')->where('verified', true)->first();
|
$this->next_patient = Waitlist::orderBy('created_at', 'asc')->where('verified', true)->first();
|
||||||
}
|
}
|
||||||
if ($this->next_patient) {
|
if ($this->next_patient) {
|
||||||
|
if ($this->option('only-email')) {
|
||||||
|
$this->send_email();
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->register_user();
|
$this->register_user();
|
||||||
$this->remove_from_waitlist();
|
$this->remove_from_waitlist();
|
||||||
$this->send_email();
|
$this->send_email();
|
||||||
@@ -55,7 +74,7 @@ class InviteFromWaitlist extends Command
|
|||||||
$already_registered = User::whereEmail($this->next_patient->email)->first();
|
$already_registered = User::whereEmail($this->next_patient->email)->first();
|
||||||
if (!$already_registered) {
|
if (!$already_registered) {
|
||||||
$this->password = Str::password();
|
$this->password = Str::password();
|
||||||
$this->new_user = User::create([
|
User::create([
|
||||||
'name' => Str::of($this->next_patient->email)->before('@'),
|
'name' => Str::of($this->next_patient->email)->before('@'),
|
||||||
'email' => $this->next_patient->email,
|
'email' => $this->next_patient->email,
|
||||||
'password' => Hash::make($this->password),
|
'password' => Hash::make($this->password),
|
||||||
@@ -73,10 +92,11 @@ class InviteFromWaitlist extends Command
|
|||||||
}
|
}
|
||||||
private function send_email()
|
private function send_email()
|
||||||
{
|
{
|
||||||
|
$token = Crypt::encryptString("{$this->next_patient->email}@@@$this->password");
|
||||||
|
$loginLink = route('auth.link', ['token' => $token]);
|
||||||
$mail = new MailMessage();
|
$mail = new MailMessage();
|
||||||
$mail->view('emails.waitlist-invitation', [
|
$mail->view('emails.waitlist-invitation', [
|
||||||
'email' => $this->next_patient->email,
|
'loginLink' => $loginLink,
|
||||||
'password' => $this->password,
|
|
||||||
]);
|
]);
|
||||||
$mail->subject('Congratulations! You are invited to join Coolify Cloud.');
|
$mail->subject('Congratulations! You are invited to join Coolify Cloud.');
|
||||||
send_user_an_email($mail, $this->next_patient->email);
|
send_user_an_email($mail, $this->next_patient->email);
|
||||||
@@ -7,9 +7,10 @@ use App\Jobs\CleanupInstanceStuffsJob;
|
|||||||
use App\Jobs\DatabaseBackupJob;
|
use App\Jobs\DatabaseBackupJob;
|
||||||
use App\Jobs\DockerCleanupJob;
|
use App\Jobs\DockerCleanupJob;
|
||||||
use App\Jobs\InstanceAutoUpdateJob;
|
use App\Jobs\InstanceAutoUpdateJob;
|
||||||
use App\Jobs\ProxyCheckJob;
|
use App\Jobs\ContainerStatusJob;
|
||||||
use App\Jobs\ResourceStatusJob;
|
use App\Models\InstanceSettings;
|
||||||
use App\Models\ScheduledDatabaseBackup;
|
use App\Models\ScheduledDatabaseBackup;
|
||||||
|
use App\Models\Server;
|
||||||
use Illuminate\Console\Scheduling\Schedule;
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
|
||||||
@@ -17,28 +18,44 @@ class Kernel extends ConsoleKernel
|
|||||||
{
|
{
|
||||||
protected function schedule(Schedule $schedule): void
|
protected function schedule(Schedule $schedule): void
|
||||||
{
|
{
|
||||||
// $schedule->call(fn() => $this->check_scheduled_backups($schedule))->everyTenSeconds();
|
|
||||||
if (isDev()) {
|
if (isDev()) {
|
||||||
$schedule->command('horizon:snapshot')->everyMinute();
|
// $schedule->job(new ContainerStatusJob(Server::find(0)))->everyTenMinutes()->onOneServer();
|
||||||
$schedule->job(new ResourceStatusJob)->everyMinute();
|
// $schedule->command('horizon:snapshot')->everyMinute();
|
||||||
$schedule->job(new ProxyCheckJob)->everyFiveMinutes();
|
$schedule->job(new CleanupInstanceStuffsJob)->everyMinute()->onOneServer();
|
||||||
$schedule->job(new CleanupInstanceStuffsJob)->everyMinute();
|
|
||||||
|
|
||||||
// $schedule->job(new CheckResaleLicenseJob)->hourly();
|
// $schedule->job(new CheckResaleLicenseJob)->hourly();
|
||||||
// $schedule->job(new DockerCleanupJob)->everyOddHour();
|
// $schedule->job(new DockerCleanupJob)->everyOddHour();
|
||||||
// $schedule->job(new InstanceAutoUpdateJob(true))->everyMinute();
|
// $this->instance_auto_update($schedule);
|
||||||
|
// $this->check_scheduled_backups($schedule);
|
||||||
|
$this->check_resources($schedule);
|
||||||
} else {
|
} else {
|
||||||
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||||
$schedule->job(new CleanupInstanceStuffsJob)->everyMinute();
|
$schedule->job(new CleanupInstanceStuffsJob)->everyTwoMinutes()->onOneServer();
|
||||||
$schedule->job(new ResourceStatusJob)->everyMinute();
|
$schedule->job(new CheckResaleLicenseJob)->hourly()->onOneServer();
|
||||||
$schedule->job(new CheckResaleLicenseJob)->hourly();
|
$schedule->job(new DockerCleanupJob)->everyTenMinutes()->onOneServer();
|
||||||
$schedule->job(new ProxyCheckJob)->everyFiveMinutes();
|
$this->instance_auto_update($schedule);
|
||||||
$schedule->job(new DockerCleanupJob)->everyTenMinutes();
|
$this->check_scheduled_backups($schedule);
|
||||||
$schedule->job(new InstanceAutoUpdateJob)->everyTenMinutes();
|
$this->check_resources($schedule);
|
||||||
}
|
}
|
||||||
$this->check_scheduled_backups($schedule);
|
|
||||||
}
|
}
|
||||||
|
private function check_resources($schedule)
|
||||||
|
{
|
||||||
|
$servers = Server::all()->where('settings.is_usable', true)->where('settings.is_reachable', true);
|
||||||
|
ray($servers);
|
||||||
|
|
||||||
|
foreach ($servers as $server) {
|
||||||
|
$schedule->job(new ContainerStatusJob($server))->everyMinute()->onOneServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private function instance_auto_update($schedule)
|
||||||
|
{
|
||||||
|
if (isDev()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$settings = InstanceSettings::get();
|
||||||
|
if ($settings->is_auto_update_enabled) {
|
||||||
|
$schedule->job(new InstanceAutoUpdateJob)->everyTenMinutes()->onOneServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
private function check_scheduled_backups($schedule)
|
private function check_scheduled_backups($schedule)
|
||||||
{
|
{
|
||||||
ray('check_scheduled_backups');
|
ray('check_scheduled_backups');
|
||||||
@@ -51,13 +68,18 @@ class Kernel extends ConsoleKernel
|
|||||||
if (!$scheduled_backup->enabled) {
|
if (!$scheduled_backup->enabled) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (is_null(data_get($scheduled_backup, 'database'))) {
|
||||||
|
ray('database not found');
|
||||||
|
$scheduled_backup->delete();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset(VALID_CRON_STRINGS[$scheduled_backup->frequency])) {
|
if (isset(VALID_CRON_STRINGS[$scheduled_backup->frequency])) {
|
||||||
$scheduled_backup->frequency = VALID_CRON_STRINGS[$scheduled_backup->frequency];
|
$scheduled_backup->frequency = VALID_CRON_STRINGS[$scheduled_backup->frequency];
|
||||||
}
|
}
|
||||||
$schedule->job(new DatabaseBackupJob(
|
$schedule->job(new DatabaseBackupJob(
|
||||||
backup: $scheduled_backup
|
backup: $scheduled_backup
|
||||||
))->cron($scheduled_backup->frequency);
|
))->cron($scheduled_backup->frequency)->onOneServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,8 @@ use Spatie\LaravelData\Data;
|
|||||||
class CoolifyTaskArgs extends Data
|
class CoolifyTaskArgs extends Data
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public string $server_ip,
|
public string $server_uuid,
|
||||||
public string $private_key_location,
|
|
||||||
public string $command,
|
public string $command,
|
||||||
public int $port,
|
|
||||||
public string $user,
|
|
||||||
public string $type,
|
public string $type,
|
||||||
public ?string $type_uuid = null,
|
public ?string $type_uuid = null,
|
||||||
public ?Model $model = null,
|
public ?Model $model = null,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Enums;
|
|||||||
|
|
||||||
enum ProxyTypes: string
|
enum ProxyTypes: string
|
||||||
{
|
{
|
||||||
|
case NONE = 'NONE';
|
||||||
case TRAEFIK_V2 = 'TRAEFIK_V2';
|
case TRAEFIK_V2 = 'TRAEFIK_V2';
|
||||||
case NGINX = 'NGINX';
|
case NGINX = 'NGINX';
|
||||||
case CADDY = 'CADDY';
|
case CADDY = 'CADDY';
|
||||||
|
|||||||
@@ -3,8 +3,10 @@
|
|||||||
namespace App\Exceptions;
|
namespace App\Exceptions;
|
||||||
|
|
||||||
use App\Models\InstanceSettings;
|
use App\Models\InstanceSettings;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
use Sentry\Laravel\Integration;
|
use Sentry\Laravel\Integration;
|
||||||
|
use Sentry\State\Scope;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
@@ -24,7 +26,7 @@ class Handler extends ExceptionHandler
|
|||||||
* @var array<int, class-string<\Throwable>>
|
* @var array<int, class-string<\Throwable>>
|
||||||
*/
|
*/
|
||||||
protected $dontReport = [
|
protected $dontReport = [
|
||||||
//
|
ProcessException::class
|
||||||
];
|
];
|
||||||
/**
|
/**
|
||||||
* A list of the inputs that are never flashed to the session on validation exceptions.
|
* A list of the inputs that are never flashed to the session on validation exceptions.
|
||||||
@@ -44,10 +46,23 @@ class Handler extends ExceptionHandler
|
|||||||
public function register(): void
|
public function register(): void
|
||||||
{
|
{
|
||||||
$this->reportable(function (Throwable $e) {
|
$this->reportable(function (Throwable $e) {
|
||||||
$this->settings = InstanceSettings::get();
|
if (isDev()) {
|
||||||
if ($this->settings->do_not_track || isDev()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$this->settings = InstanceSettings::get();
|
||||||
|
if ($this->settings->do_not_track) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
app('sentry')->configureScope(
|
||||||
|
function (Scope $scope) {
|
||||||
|
$scope->setUser(
|
||||||
|
[
|
||||||
|
'email' => auth()->user()->email,
|
||||||
|
'instanceAdmin' => User::find(0)->email
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
Integration::captureUnhandledException($e);
|
Integration::captureUnhandledException($e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
10
app/Exceptions/ProcessException.php
Normal file
10
app/Exceptions/ProcessException.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class ProcessException extends Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,41 +3,62 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\InstanceSettings;
|
use App\Models\InstanceSettings;
|
||||||
use App\Models\Project;
|
|
||||||
use App\Models\S3Storage;
|
use App\Models\S3Storage;
|
||||||
use App\Models\Server;
|
|
||||||
use App\Models\StandalonePostgresql;
|
use App\Models\StandalonePostgresql;
|
||||||
use App\Models\TeamInvitation;
|
use App\Models\TeamInvitation;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Waitlist;
|
|
||||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
use Illuminate\Routing\Controller as BaseController;
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
use Throwable;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class Controller extends BaseController
|
class Controller extends BaseController
|
||||||
{
|
{
|
||||||
use AuthorizesRequests, ValidatesRequests;
|
use AuthorizesRequests, ValidatesRequests;
|
||||||
|
|
||||||
public function waitlist() {
|
public function link()
|
||||||
$waiting_in_line = Waitlist::whereVerified(true)->count();
|
{
|
||||||
return view('auth.waitlist', [
|
$token = request()->get('token');
|
||||||
'waiting_in_line' => $waiting_in_line,
|
if ($token) {
|
||||||
]);
|
$decrypted = Crypt::decryptString($token);
|
||||||
|
$email = Str::of($decrypted)->before('@@@');
|
||||||
|
$password = Str::of($decrypted)->after('@@@');
|
||||||
|
$user = User::whereEmail($email)->first();
|
||||||
|
if (!$user) {
|
||||||
|
return redirect()->route('login');
|
||||||
|
}
|
||||||
|
if (Hash::check($password, $user->password)) {
|
||||||
|
$invitation = TeamInvitation::whereEmail($email);
|
||||||
|
if ($invitation->exists()) {
|
||||||
|
$team = $invitation->first()->team;
|
||||||
|
$user->teams()->attach($team->id, ['role' => $invitation->first()->role]);
|
||||||
|
$invitation->delete();
|
||||||
|
} else {
|
||||||
|
$team = $user->teams()->first();
|
||||||
|
}
|
||||||
|
Auth::login($user);
|
||||||
|
session(['currentTeam' => $team]);
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return redirect()->route('login')->with('error', 'Invalid credentials.');
|
||||||
}
|
}
|
||||||
public function subscription()
|
public function subscription()
|
||||||
{
|
{
|
||||||
if (!is_cloud()) {
|
if (!isCloud()) {
|
||||||
abort(404);
|
abort(404);
|
||||||
}
|
}
|
||||||
return view('subscription.show', [
|
return view('subscription.index', [
|
||||||
'settings' => InstanceSettings::get(),
|
'settings' => InstanceSettings::get(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function license()
|
public function license()
|
||||||
{
|
{
|
||||||
if (!is_cloud()) {
|
if (!isCloud()) {
|
||||||
abort(404);
|
abort(404);
|
||||||
}
|
}
|
||||||
return view('settings.license', [
|
return view('settings.license', [
|
||||||
@@ -45,27 +66,12 @@ class Controller extends BaseController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function force_passoword_reset() {
|
public function force_passoword_reset()
|
||||||
|
{
|
||||||
return view('auth.force-password-reset');
|
return view('auth.force-password-reset');
|
||||||
}
|
}
|
||||||
public function dashboard()
|
public function boarding()
|
||||||
{
|
{
|
||||||
$projects = Project::ownedByCurrentTeam()->get();
|
|
||||||
$servers = Server::ownedByCurrentTeam()->get();
|
|
||||||
$s3s = S3Storage::ownedByCurrentTeam()->get();
|
|
||||||
$resources = 0;
|
|
||||||
foreach ($projects as $project) {
|
|
||||||
$resources += $project->applications->count();
|
|
||||||
$resources += $project->postgresqls->count();
|
|
||||||
}
|
|
||||||
return view('dashboard', [
|
|
||||||
'servers' => $servers->count(),
|
|
||||||
'projects' => $projects->count(),
|
|
||||||
'resources' => $resources,
|
|
||||||
's3s' => $s3s,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
public function boarding() {
|
|
||||||
if (currentTeam()->boarding || isDev()) {
|
if (currentTeam()->boarding || isDev()) {
|
||||||
return view('boarding');
|
return view('boarding');
|
||||||
} else {
|
} else {
|
||||||
@@ -97,7 +103,7 @@ class Controller extends BaseController
|
|||||||
if (auth()->user()->isAdminFromSession()) {
|
if (auth()->user()->isAdminFromSession()) {
|
||||||
$invitations = TeamInvitation::whereTeamId(currentTeam()->id)->get();
|
$invitations = TeamInvitation::whereTeamId(currentTeam()->id)->get();
|
||||||
}
|
}
|
||||||
return view('team.show', [
|
return view('team.index', [
|
||||||
'invitations' => $invitations,
|
'invitations' => $invitations,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -134,25 +140,21 @@ class Controller extends BaseController
|
|||||||
try {
|
try {
|
||||||
$invitation = TeamInvitation::whereUuid(request()->route('uuid'))->firstOrFail();
|
$invitation = TeamInvitation::whereUuid(request()->route('uuid'))->firstOrFail();
|
||||||
$user = User::whereEmail($invitation->email)->firstOrFail();
|
$user = User::whereEmail($invitation->email)->firstOrFail();
|
||||||
if (is_null(auth()->user())) {
|
|
||||||
return redirect()->route('login');
|
|
||||||
}
|
|
||||||
if (auth()->user()->id !== $user->id) {
|
if (auth()->user()->id !== $user->id) {
|
||||||
abort(401);
|
abort(401);
|
||||||
}
|
}
|
||||||
|
$invitationValid = $invitation->isValid();
|
||||||
$createdAt = $invitation->created_at;
|
if ($invitationValid) {
|
||||||
$diff = $createdAt->diffInMinutes(now());
|
|
||||||
if ($diff <= config('constants.invitation.link.expiration')) {
|
|
||||||
$user->teams()->attach($invitation->team->id, ['role' => $invitation->role]);
|
$user->teams()->attach($invitation->team->id, ['role' => $invitation->role]);
|
||||||
|
refreshSession($invitation->team);
|
||||||
$invitation->delete();
|
$invitation->delete();
|
||||||
return redirect()->route('team.show');
|
return redirect()->route('team.index');
|
||||||
} else {
|
} else {
|
||||||
$invitation->delete();
|
|
||||||
abort(401);
|
abort(401);
|
||||||
}
|
}
|
||||||
} catch (Throwable $th) {
|
} catch (\Throwable $e) {
|
||||||
throw $th;
|
ray($e->getMessage());
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,9 +170,9 @@ class Controller extends BaseController
|
|||||||
abort(401);
|
abort(401);
|
||||||
}
|
}
|
||||||
$invitation->delete();
|
$invitation->delete();
|
||||||
return redirect()->route('team.show');
|
return redirect()->route('team.index');
|
||||||
} catch (Throwable $th) {
|
} catch (\Throwable $e) {
|
||||||
throw $th;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class ProjectController extends Controller
|
|||||||
{
|
{
|
||||||
$type = request()->query('type');
|
$type = request()->query('type');
|
||||||
$destination_uuid = request()->query('destination');
|
$destination_uuid = request()->query('destination');
|
||||||
|
$server = requesT()->query('server');
|
||||||
|
|
||||||
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||||
if (!$project) {
|
if (!$project) {
|
||||||
|
|||||||
@@ -12,20 +12,21 @@ class ServerController extends Controller
|
|||||||
|
|
||||||
public function new_server()
|
public function new_server()
|
||||||
{
|
{
|
||||||
if (!is_cloud() || isInstanceAdmin()) {
|
$privateKeys = PrivateKey::ownedByCurrentTeam()->get();
|
||||||
|
if (!isCloud()) {
|
||||||
return view('server.create', [
|
return view('server.create', [
|
||||||
'limit_reached' => false,
|
'limit_reached' => false,
|
||||||
'private_keys' => PrivateKey::ownedByCurrentTeam()->get(),
|
'private_keys' => $privateKeys,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$servers = currentTeam()->servers->count();
|
$team = currentTeam();
|
||||||
$subscription = currentTeam()?->subscription->type();
|
$servers = $team->servers->count();
|
||||||
$your_limit = config('constants.limits.server')[strtolower($subscription)];
|
['serverLimit' => $serverLimit] = $team->limits;
|
||||||
$limit_reached = $servers >= $your_limit;
|
$limit_reached = $servers >= $serverLimit;
|
||||||
|
|
||||||
return view('server.create', [
|
return view('server.create', [
|
||||||
'limit_reached' => $limit_reached,
|
'limit_reached' => $limit_reached,
|
||||||
'private_keys' => PrivateKey::ownedByCurrentTeam()->get(),
|
'private_keys' => $privateKeys,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class Kernel extends HttpKernel
|
|||||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
\App\Http\Middleware\CheckForcePasswordReset::class,
|
\App\Http\Middleware\CheckForcePasswordReset::class,
|
||||||
\App\Http\Middleware\SubscriptionValid::class,
|
\App\Http\Middleware\IsSubscriptionValid::class,
|
||||||
\App\Http\Middleware\IsBoardingFlow::class,
|
\App\Http\Middleware\IsBoardingFlow::class,
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,181 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Livewire;
|
|
||||||
|
|
||||||
use App\Actions\Server\InstallDocker;
|
|
||||||
use App\Models\PrivateKey;
|
|
||||||
use App\Models\Project;
|
|
||||||
use App\Models\Server;
|
|
||||||
use Livewire\Component;
|
|
||||||
|
|
||||||
class Boarding extends Component
|
|
||||||
{
|
|
||||||
public string $currentState = 'welcome';
|
|
||||||
|
|
||||||
public ?string $privateKeyType = null;
|
|
||||||
public ?string $privateKey = null;
|
|
||||||
public ?string $publicKey = null;
|
|
||||||
public ?string $privateKeyName = null;
|
|
||||||
public ?string $privateKeyDescription = null;
|
|
||||||
public ?PrivateKey $createdPrivateKey = null;
|
|
||||||
|
|
||||||
public ?string $remoteServerName = null;
|
|
||||||
public ?string $remoteServerDescription = null;
|
|
||||||
public ?string $remoteServerHost = null;
|
|
||||||
public ?int $remoteServerPort = 22;
|
|
||||||
public ?string $remoteServerUser = 'root';
|
|
||||||
public ?Server $createdServer = null;
|
|
||||||
|
|
||||||
public ?Project $createdProject = null;
|
|
||||||
|
|
||||||
public function mount()
|
|
||||||
{
|
|
||||||
$this->privateKeyName = generate_random_name();
|
|
||||||
$this->remoteServerName = generate_random_name();
|
|
||||||
if (isDev()) {
|
|
||||||
$this->privateKey = '-----BEGIN OPENSSH PRIVATE KEY-----
|
|
||||||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
|
||||||
QyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevAAAAJi/QySHv0Mk
|
|
||||||
hwAAAAtzc2gtZWQyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevA
|
|
||||||
AAAECBQw4jg1WRT2IGHMncCiZhURCts2s24HoDS0thHnnRKVuGmoeGq/pojrsyP1pszcNV
|
|
||||||
uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
|
|
||||||
-----END OPENSSH PRIVATE KEY-----';
|
|
||||||
$this->privateKeyDescription = 'Created by Coolify';
|
|
||||||
$this->remoteServerDescription = 'Created by Coolify';
|
|
||||||
$this->remoteServerHost = 'coolify-testing-host';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public function restartBoarding()
|
|
||||||
{
|
|
||||||
if ($this->createdServer) {
|
|
||||||
$this->createdServer->delete();
|
|
||||||
}
|
|
||||||
if ($this->createdPrivateKey) {
|
|
||||||
$this->createdPrivateKey->delete();
|
|
||||||
}
|
|
||||||
return redirect()->route('boarding');
|
|
||||||
}
|
|
||||||
public function skipBoarding()
|
|
||||||
{
|
|
||||||
currentTeam()->update([
|
|
||||||
'show_boarding' => false
|
|
||||||
]);
|
|
||||||
refreshSession();
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
public function setServer(string $type)
|
|
||||||
{
|
|
||||||
if ($type === 'localhost') {
|
|
||||||
$this->createdServer = Server::find(0);
|
|
||||||
if (!$this->createdServer) {
|
|
||||||
return $this->emit('error', 'Localhost server is not found. Something went wrong during installation. Please try to reinstall or contact support.');
|
|
||||||
}
|
|
||||||
$this->currentState = 'select-proxy';
|
|
||||||
} elseif ($type === 'remote') {
|
|
||||||
$this->currentState = 'private-key';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public function setPrivateKey(string $type)
|
|
||||||
{
|
|
||||||
$this->privateKeyType = $type;
|
|
||||||
if ($type === 'create' && !isDev()) {
|
|
||||||
$this->createNewPrivateKey();
|
|
||||||
}
|
|
||||||
$this->currentState = 'create-private-key';
|
|
||||||
}
|
|
||||||
public function savePrivateKey()
|
|
||||||
{
|
|
||||||
$this->validate([
|
|
||||||
'privateKeyName' => 'required',
|
|
||||||
'privateKey' => 'required',
|
|
||||||
]);
|
|
||||||
$this->currentState = 'create-server';
|
|
||||||
}
|
|
||||||
public function saveServer()
|
|
||||||
{
|
|
||||||
$this->validate([
|
|
||||||
'remoteServerName' => 'required',
|
|
||||||
'remoteServerHost' => 'required',
|
|
||||||
'remoteServerPort' => 'required',
|
|
||||||
'remoteServerUser' => 'required',
|
|
||||||
]);
|
|
||||||
$this->privateKey = formatPrivateKey($this->privateKey);
|
|
||||||
$this->createdPrivateKey = PrivateKey::create([
|
|
||||||
'name' => $this->privateKeyName,
|
|
||||||
'description' => $this->privateKeyDescription,
|
|
||||||
'private_key' => $this->privateKey,
|
|
||||||
'team_id' => currentTeam()->id
|
|
||||||
]);
|
|
||||||
$this->createdServer = Server::create([
|
|
||||||
'name' => $this->remoteServerName,
|
|
||||||
'ip' => $this->remoteServerHost,
|
|
||||||
'port' => $this->remoteServerPort,
|
|
||||||
'user' => $this->remoteServerUser,
|
|
||||||
'description' => $this->remoteServerDescription,
|
|
||||||
'private_key_id' => $this->createdPrivateKey->id,
|
|
||||||
'team_id' => currentTeam()->id
|
|
||||||
]);
|
|
||||||
try {
|
|
||||||
['uptime' => $uptime, 'dockerVersion' => $dockerVersion] = validateServer($this->createdServer);
|
|
||||||
if (!$uptime) {
|
|
||||||
$this->createdServer->delete();
|
|
||||||
$this->createdPrivateKey->delete();
|
|
||||||
throw new \Exception('Server is not reachable.');
|
|
||||||
} else {
|
|
||||||
$this->createdServer->settings->update([
|
|
||||||
'is_reachable' => true,
|
|
||||||
]);
|
|
||||||
$this->emit('success', 'Server is reachable.');
|
|
||||||
}
|
|
||||||
if ($dockerVersion) {
|
|
||||||
$this->emit('error', 'Docker is not installed on the server.');
|
|
||||||
$this->currentState = 'install-docker';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return general_error_handler(customErrorMessage: "Server is not reachable. Reason: {$e->getMessage()}", that: $this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public function installDocker()
|
|
||||||
{
|
|
||||||
$activity = resolve(InstallDocker::class)($this->createdServer, currentTeam());
|
|
||||||
$this->emit('newMonitorActivity', $activity->id);
|
|
||||||
$this->currentState = 'select-proxy';
|
|
||||||
}
|
|
||||||
public function selectProxy(string|null $proxyType = null)
|
|
||||||
{
|
|
||||||
if (!$proxyType) {
|
|
||||||
return $this->currentState = 'create-project';
|
|
||||||
}
|
|
||||||
$this->createdServer->proxy->type = $proxyType;
|
|
||||||
$this->createdServer->proxy->status = 'exited';
|
|
||||||
$this->createdServer->save();
|
|
||||||
$this->currentState = 'create-project';
|
|
||||||
}
|
|
||||||
public function createNewProject()
|
|
||||||
{
|
|
||||||
$this->createdProject = Project::create([
|
|
||||||
'name' => "My first project",
|
|
||||||
'team_id' => currentTeam()->id
|
|
||||||
]);
|
|
||||||
$this->currentState = 'create-resource';
|
|
||||||
}
|
|
||||||
public function showNewResource()
|
|
||||||
{
|
|
||||||
$this->skipBoarding();
|
|
||||||
return redirect()->route(
|
|
||||||
'project.resources.new',
|
|
||||||
[
|
|
||||||
'project_uuid' => $this->createdProject->uuid,
|
|
||||||
'environment_name' => 'production',
|
|
||||||
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
private function createNewPrivateKey()
|
|
||||||
{
|
|
||||||
$this->privateKeyName = generate_random_name();
|
|
||||||
$this->privateKeyDescription = 'Created by Coolify';
|
|
||||||
['private' => $this->privateKey, 'public'=> $this->publicKey] = generateSSHKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
291
app/Http/Livewire/Boarding/Index.php
Normal file
291
app/Http/Livewire/Boarding/Index.php
Normal file
@@ -0,0 +1,291 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Livewire\Boarding;
|
||||||
|
|
||||||
|
use App\Actions\Server\InstallDocker;
|
||||||
|
use App\Models\PrivateKey;
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\Server;
|
||||||
|
use App\Models\Team;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Livewire\Component;
|
||||||
|
use Visus\Cuid2\Cuid2;
|
||||||
|
|
||||||
|
class Index extends Component
|
||||||
|
{
|
||||||
|
public string $currentState = 'welcome';
|
||||||
|
|
||||||
|
public ?string $selectedServerType = null;
|
||||||
|
public ?Collection $privateKeys = null;
|
||||||
|
public ?int $selectedExistingPrivateKey = null;
|
||||||
|
public ?string $privateKeyType = null;
|
||||||
|
public ?string $privateKey = null;
|
||||||
|
public ?string $publicKey = null;
|
||||||
|
public ?string $privateKeyName = null;
|
||||||
|
public ?string $privateKeyDescription = null;
|
||||||
|
public ?PrivateKey $createdPrivateKey = null;
|
||||||
|
|
||||||
|
public ?Collection $servers = null;
|
||||||
|
public ?int $selectedExistingServer = null;
|
||||||
|
public ?string $remoteServerName = null;
|
||||||
|
public ?string $remoteServerDescription = null;
|
||||||
|
public ?string $remoteServerHost = null;
|
||||||
|
public ?int $remoteServerPort = 22;
|
||||||
|
public ?string $remoteServerUser = 'root';
|
||||||
|
public ?Server $createdServer = null;
|
||||||
|
|
||||||
|
public Collection|array $projects = [];
|
||||||
|
public ?int $selectedExistingProject = null;
|
||||||
|
public ?Project $createdProject = null;
|
||||||
|
|
||||||
|
public bool $dockerInstallationStarted = false;
|
||||||
|
|
||||||
|
public string $localhostPublicKey;
|
||||||
|
public bool $localhostReachable = true;
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->privateKeyName = generate_random_name();
|
||||||
|
$this->remoteServerName = generate_random_name();
|
||||||
|
if (isDev()) {
|
||||||
|
$this->privateKey = '-----BEGIN OPENSSH PRIVATE KEY-----
|
||||||
|
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||||
|
QyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevAAAAJi/QySHv0Mk
|
||||||
|
hwAAAAtzc2gtZWQyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevA
|
||||||
|
AAAECBQw4jg1WRT2IGHMncCiZhURCts2s24HoDS0thHnnRKVuGmoeGq/pojrsyP1pszcNV
|
||||||
|
uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
|
||||||
|
-----END OPENSSH PRIVATE KEY-----';
|
||||||
|
$this->privateKeyDescription = 'Created by Coolify';
|
||||||
|
$this->remoteServerDescription = 'Created by Coolify';
|
||||||
|
$this->remoteServerHost = 'coolify-testing-host';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function explanation()
|
||||||
|
{
|
||||||
|
if (isCloud()) {
|
||||||
|
return $this->setServerType('remote');
|
||||||
|
}
|
||||||
|
$this->currentState = 'select-server-type';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function restartBoarding()
|
||||||
|
{
|
||||||
|
// if ($this->selectedServerType !== 'localhost') {
|
||||||
|
// if ($this->createdServer) {
|
||||||
|
// $this->createdServer->delete();
|
||||||
|
// }
|
||||||
|
// if ($this->createdPrivateKey) {
|
||||||
|
// $this->createdPrivateKey->delete();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
return redirect()->route('boarding');
|
||||||
|
}
|
||||||
|
public function skipBoarding()
|
||||||
|
{
|
||||||
|
Team::find(currentTeam()->id)->update([
|
||||||
|
'show_boarding' => false
|
||||||
|
]);
|
||||||
|
ray(currentTeam());
|
||||||
|
refreshSession();
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setServerType(string $type)
|
||||||
|
{
|
||||||
|
$this->selectedServerType = $type;
|
||||||
|
if ($this->selectedServerType === 'localhost') {
|
||||||
|
$this->createdServer = Server::find(0);
|
||||||
|
if (!$this->createdServer) {
|
||||||
|
return $this->emit('error', 'Localhost server is not found. Something went wrong during installation. Please try to reinstall or contact support.');
|
||||||
|
}
|
||||||
|
$this->localhostPublicKey = $this->createdServer->privateKey->publicKey();
|
||||||
|
return $this->validateServer('localhost');
|
||||||
|
} elseif ($this->selectedServerType === 'remote') {
|
||||||
|
$this->privateKeys = PrivateKey::ownedByCurrentTeam(['name'])->where('id', '!=', 0)->get();
|
||||||
|
if ($this->privateKeys->count() > 0) {
|
||||||
|
$this->selectedExistingPrivateKey = $this->privateKeys->first()->id;
|
||||||
|
}
|
||||||
|
$this->servers = Server::ownedByCurrentTeam(['name'])->where('id', '!=', 0)->get();
|
||||||
|
if ($this->servers->count() > 0) {
|
||||||
|
$this->selectedExistingServer = $this->servers->first()->id;
|
||||||
|
$this->currentState = 'select-existing-server';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->currentState = 'private-key';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function selectExistingServer()
|
||||||
|
{
|
||||||
|
$this->createdServer = Server::find($this->selectedExistingServer);
|
||||||
|
if (!$this->createdServer) {
|
||||||
|
$this->emit('error', 'Server is not found.');
|
||||||
|
$this->currentState = 'private-key';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->selectedExistingPrivateKey = $this->createdServer->privateKey->id;
|
||||||
|
$this->validateServer();
|
||||||
|
}
|
||||||
|
public function getProxyType()
|
||||||
|
{
|
||||||
|
$proxyTypeSet = $this->createdServer->proxy->type;
|
||||||
|
if (!$proxyTypeSet) {
|
||||||
|
$this->currentState = 'select-proxy';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->getProjects();
|
||||||
|
}
|
||||||
|
public function selectExistingPrivateKey()
|
||||||
|
{
|
||||||
|
$this->createdPrivateKey = PrivateKey::find($this->selectedExistingPrivateKey);
|
||||||
|
$this->currentState = 'create-server';
|
||||||
|
}
|
||||||
|
public function createNewServer()
|
||||||
|
{
|
||||||
|
$this->selectedExistingServer = null;
|
||||||
|
$this->currentState = 'private-key';
|
||||||
|
}
|
||||||
|
public function setPrivateKey(string $type)
|
||||||
|
{
|
||||||
|
$this->selectedExistingPrivateKey = null;
|
||||||
|
$this->privateKeyType = $type;
|
||||||
|
if ($type === 'create') {
|
||||||
|
$this->createNewPrivateKey();
|
||||||
|
}
|
||||||
|
$this->currentState = 'create-private-key';
|
||||||
|
}
|
||||||
|
public function savePrivateKey()
|
||||||
|
{
|
||||||
|
$this->validate([
|
||||||
|
'privateKeyName' => 'required',
|
||||||
|
'privateKey' => 'required',
|
||||||
|
]);
|
||||||
|
$this->createdPrivateKey = PrivateKey::create([
|
||||||
|
'name' => $this->privateKeyName,
|
||||||
|
'description' => $this->privateKeyDescription,
|
||||||
|
'private_key' => $this->privateKey,
|
||||||
|
'team_id' => currentTeam()->id
|
||||||
|
]);
|
||||||
|
$this->createdPrivateKey->save();
|
||||||
|
$this->currentState = 'create-server';
|
||||||
|
}
|
||||||
|
public function saveServer()
|
||||||
|
{
|
||||||
|
$this->validate([
|
||||||
|
'remoteServerName' => 'required',
|
||||||
|
'remoteServerHost' => 'required',
|
||||||
|
'remoteServerPort' => 'required|integer',
|
||||||
|
'remoteServerUser' => 'required',
|
||||||
|
]);
|
||||||
|
$this->privateKey = formatPrivateKey($this->privateKey);
|
||||||
|
$foundServer = Server::whereIp($this->remoteServerHost)->first();
|
||||||
|
if ($foundServer) {
|
||||||
|
return $this->emit('error', 'IP address is already in use by another team.');
|
||||||
|
}
|
||||||
|
$this->createdServer = Server::create([
|
||||||
|
'name' => $this->remoteServerName,
|
||||||
|
'ip' => $this->remoteServerHost,
|
||||||
|
'port' => $this->remoteServerPort,
|
||||||
|
'user' => $this->remoteServerUser,
|
||||||
|
'description' => $this->remoteServerDescription,
|
||||||
|
'private_key_id' => $this->createdPrivateKey->id,
|
||||||
|
'team_id' => currentTeam()->id,
|
||||||
|
]);
|
||||||
|
$this->createdServer->save();
|
||||||
|
$this->validateServer();
|
||||||
|
}
|
||||||
|
public function validateServer()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$customErrorMessage = "Server is not reachable:";
|
||||||
|
config()->set('coolify.mux_enabled', false);
|
||||||
|
|
||||||
|
instant_remote_process(['uptime'], $this->createdServer, true);
|
||||||
|
|
||||||
|
$this->createdServer->settings->update([
|
||||||
|
'is_reachable' => true,
|
||||||
|
]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->localhostReachable = false;
|
||||||
|
return handleError(error: $e, customErrorMessage: $customErrorMessage, livewire: $this);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dockerVersion = instant_remote_process(["docker version|head -2|grep -i version| awk '{print $2}'"], $this->createdServer, true);
|
||||||
|
$dockerVersion = checkMinimumDockerEngineVersion($dockerVersion);
|
||||||
|
if (is_null($dockerVersion)) {
|
||||||
|
$this->currentState = 'install-docker';
|
||||||
|
throw new \Exception('Docker version is not supported or not installed.');
|
||||||
|
}
|
||||||
|
$this->dockerInstalledOrSkipped();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError(error: $e, customErrorMessage: $customErrorMessage, livewire: $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function installDocker()
|
||||||
|
{
|
||||||
|
$this->dockerInstallationStarted = true;
|
||||||
|
$activity = resolve(InstallDocker::class)($this->createdServer);
|
||||||
|
$this->emit('newMonitorActivity', $activity->id);
|
||||||
|
}
|
||||||
|
public function dockerInstalledOrSkipped()
|
||||||
|
{
|
||||||
|
$this->createdServer->settings->update([
|
||||||
|
'is_usable' => true,
|
||||||
|
]);
|
||||||
|
$this->getProxyType();
|
||||||
|
}
|
||||||
|
public function selectProxy(string|null $proxyType = null)
|
||||||
|
{
|
||||||
|
if (!$proxyType) {
|
||||||
|
return $this->getProjects();
|
||||||
|
}
|
||||||
|
$this->createdServer->proxy->type = $proxyType;
|
||||||
|
$this->createdServer->proxy->status = 'exited';
|
||||||
|
$this->createdServer->save();
|
||||||
|
$this->getProjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProjects()
|
||||||
|
{
|
||||||
|
$this->projects = Project::ownedByCurrentTeam(['name'])->get();
|
||||||
|
if ($this->projects->count() > 0) {
|
||||||
|
$this->selectedExistingProject = $this->projects->first()->id;
|
||||||
|
}
|
||||||
|
$this->currentState = 'create-project';
|
||||||
|
}
|
||||||
|
public function selectExistingProject()
|
||||||
|
{
|
||||||
|
$this->createdProject = Project::find($this->selectedExistingProject);
|
||||||
|
$this->currentState = 'create-resource';
|
||||||
|
}
|
||||||
|
public function createNewProject()
|
||||||
|
{
|
||||||
|
$this->createdProject = Project::create([
|
||||||
|
'name' => "My first project",
|
||||||
|
'team_id' => currentTeam()->id
|
||||||
|
]);
|
||||||
|
$this->currentState = 'create-resource';
|
||||||
|
}
|
||||||
|
public function showNewResource()
|
||||||
|
{
|
||||||
|
$this->skipBoarding();
|
||||||
|
return redirect()->route(
|
||||||
|
'project.resources.new',
|
||||||
|
[
|
||||||
|
'project_uuid' => $this->createdProject->uuid,
|
||||||
|
'environment_name' => 'production',
|
||||||
|
'server' => $this->createdServer->id,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
private function createNewPrivateKey()
|
||||||
|
{
|
||||||
|
$this->privateKeyName = generate_random_name();
|
||||||
|
$this->privateKeyDescription = 'Created by Coolify';
|
||||||
|
['private' => $this->privateKey, 'public' => $this->publicKey] = generateSSHKey();
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.boarding.index')->layout('layouts.boarding');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,9 +34,9 @@ class CheckLicense extends Component
|
|||||||
try {
|
try {
|
||||||
resolve(CheckResaleLicense::class)();
|
resolve(CheckResaleLicense::class)();
|
||||||
$this->emit('reloadWindow');
|
$this->emit('reloadWindow');
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $e) {
|
||||||
session()->flash('error', 'Something went wrong. Please contact support. <br>Error: ' . $th->getMessage());
|
session()->flash('error', 'Something went wrong. Please contact support. <br>Error: ' . $e->getMessage());
|
||||||
ray($th->getMessage());
|
ray($e->getMessage());
|
||||||
return redirect()->to('/settings/license');
|
return redirect()->to('/settings/license');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
41
app/Http/Livewire/Dashboard.php
Normal file
41
app/Http/Livewire/Dashboard.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Livewire;
|
||||||
|
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\S3Storage;
|
||||||
|
use App\Models\Server;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Dashboard extends Component
|
||||||
|
{
|
||||||
|
public int $projects = 0;
|
||||||
|
public int $servers = 0;
|
||||||
|
public int $s3s = 0;
|
||||||
|
public int $resources = 0;
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->servers = Server::ownedByCurrentTeam()->get()->count();
|
||||||
|
$this->s3s = S3Storage::ownedByCurrentTeam()->get()->count();
|
||||||
|
$projects = Project::ownedByCurrentTeam()->get();
|
||||||
|
foreach ($projects as $project) {
|
||||||
|
$this->resources += $project->applications->count();
|
||||||
|
$this->resources += $project->postgresqls->count();
|
||||||
|
}
|
||||||
|
$this->projects = $projects->count();
|
||||||
|
}
|
||||||
|
// public function getIptables()
|
||||||
|
// {
|
||||||
|
// $servers = Server::ownedByCurrentTeam()->get();
|
||||||
|
// foreach ($servers as $server) {
|
||||||
|
// checkRequiredCommands($server);
|
||||||
|
// $iptables = instant_remote_process(['docker run --privileged --net=host --pid=host --ipc=host --volume /:/host busybox chroot /host bash -c "iptables -L -n | jc --iptables"'], $server);
|
||||||
|
// ray($iptables);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.dashboard');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,8 +37,8 @@ class Form extends Component
|
|||||||
}
|
}
|
||||||
$this->destination->delete();
|
$this->destination->delete();
|
||||||
return redirect()->route('dashboard');
|
return redirect()->route('dashboard');
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e);
|
return handleError($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ class StandaloneDocker extends Component
|
|||||||
}
|
}
|
||||||
$this->createNetworkAndAttachToProxy();
|
$this->createNetworkAndAttachToProxy();
|
||||||
return redirect()->route('destination.show', $docker->uuid);
|
return redirect()->route('destination.show', $docker->uuid);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Livewire\Dev;
|
|
||||||
|
|
||||||
use App\Models\S3Storage;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use Livewire\Component;
|
|
||||||
use Livewire\WithFileUploads;
|
|
||||||
|
|
||||||
class S3Test extends Component
|
|
||||||
{
|
|
||||||
use WithFileUploads;
|
|
||||||
|
|
||||||
public $s3;
|
|
||||||
public $file;
|
|
||||||
|
|
||||||
public function mount()
|
|
||||||
{
|
|
||||||
$this->s3 = S3Storage::first();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$this->validate([
|
|
||||||
'file' => 'required|max:150', // 1MB Max
|
|
||||||
]);
|
|
||||||
set_s3_target($this->s3);
|
|
||||||
$this->file->storeAs('files', $this->file->getClientOriginalName(), 'custom-s3');
|
|
||||||
$this->emit('success', 'File uploaded successfully.');
|
|
||||||
} catch (\Throwable $th) {
|
|
||||||
return general_error_handler($th, $this, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get_files()
|
|
||||||
{
|
|
||||||
set_s3_target($this->s3);
|
|
||||||
dd(Storage::disk('custom-s3')->files('files'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,22 +18,26 @@ class ForcePasswordReset extends Component
|
|||||||
'password' => 'required|min:8',
|
'password' => 'required|min:8',
|
||||||
'password_confirmation' => 'required|same:password',
|
'password_confirmation' => 'required|same:password',
|
||||||
];
|
];
|
||||||
public function mount() {
|
public function mount()
|
||||||
|
{
|
||||||
$this->email = auth()->user()->email;
|
$this->email = auth()->user()->email;
|
||||||
}
|
}
|
||||||
public function submit() {
|
public function submit()
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
$this->rateLimit(10);
|
$this->rateLimit(10);
|
||||||
$this->validate();
|
$this->validate();
|
||||||
|
$firstLogin = auth()->user()->created_at == auth()->user()->updated_at;
|
||||||
auth()->user()->forceFill([
|
auth()->user()->forceFill([
|
||||||
'password' => Hash::make($this->password),
|
'password' => Hash::make($this->password),
|
||||||
'force_password_reset' => false,
|
'force_password_reset' => false,
|
||||||
])->save();
|
])->save();
|
||||||
auth()->logout();
|
if ($firstLogin) {
|
||||||
return redirect()->route('login')->with('status', 'Your initial password has been set.');
|
send_internal_notification('First login for ' . auth()->user()->email);
|
||||||
} catch(\Exception $e) {
|
}
|
||||||
return general_error_handler(err:$e, that:$this);
|
return redirect()->route('dashboard');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
54
app/Http/Livewire/Help.php
Normal file
54
app/Http/Livewire/Help.php
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Livewire;
|
||||||
|
|
||||||
|
use DanHarrin\LivewireRateLimiting\WithRateLimiting;
|
||||||
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
use Livewire\Component;
|
||||||
|
use Route;
|
||||||
|
|
||||||
|
class Help extends Component
|
||||||
|
{
|
||||||
|
use WithRateLimiting;
|
||||||
|
public string $description;
|
||||||
|
public string $subject;
|
||||||
|
public ?string $path = null;
|
||||||
|
protected $rules = [
|
||||||
|
'description' => 'required|min:10',
|
||||||
|
'subject' => 'required|min:3'
|
||||||
|
];
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->path = Route::current()?->uri() ?? null;
|
||||||
|
if (isDev()) {
|
||||||
|
$this->description = "I'm having trouble with {$this->path}";
|
||||||
|
$this->subject = "Help with {$this->path}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function submit()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->rateLimit(1, 60);
|
||||||
|
$this->validate();
|
||||||
|
$subscriptionType = auth()->user()?->subscription?->type() ?? 'Free';
|
||||||
|
$debug = "Route: {$this->path}";
|
||||||
|
$mail = new MailMessage();
|
||||||
|
$mail->view(
|
||||||
|
'emails.help',
|
||||||
|
[
|
||||||
|
'description' => $this->description,
|
||||||
|
'debug' => $debug
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$mail->subject("[HELP - {$subscriptionType}]: {$this->subject}");
|
||||||
|
send_user_an_email($mail, auth()->user()?->email, 'hi@coollabs.io');
|
||||||
|
$this->emit('success', 'Your message has been sent successfully. We will get in touch with you as soon as possible.');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.help')->layout('layouts.app');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,26 +8,30 @@ use Livewire\Component;
|
|||||||
|
|
||||||
class DiscordSettings extends Component
|
class DiscordSettings extends Component
|
||||||
{
|
{
|
||||||
public Team $model;
|
public Team $team;
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'model.discord_enabled' => 'nullable|boolean',
|
'team.discord_enabled' => 'nullable|boolean',
|
||||||
'model.discord_webhook_url' => 'required|url',
|
'team.discord_webhook_url' => 'required|url',
|
||||||
'model.discord_notifications_test' => 'nullable|boolean',
|
'team.discord_notifications_test' => 'nullable|boolean',
|
||||||
'model.discord_notifications_deployments' => 'nullable|boolean',
|
'team.discord_notifications_deployments' => 'nullable|boolean',
|
||||||
'model.discord_notifications_status_changes' => 'nullable|boolean',
|
'team.discord_notifications_status_changes' => 'nullable|boolean',
|
||||||
'model.discord_notifications_database_backups' => 'nullable|boolean',
|
'team.discord_notifications_database_backups' => 'nullable|boolean',
|
||||||
];
|
];
|
||||||
protected $validationAttributes = [
|
protected $validationAttributes = [
|
||||||
'model.discord_webhook_url' => 'Discord Webhook',
|
'team.discord_webhook_url' => 'Discord Webhook',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->team = auth()->user()->currentTeam();
|
||||||
|
}
|
||||||
public function instantSave()
|
public function instantSave()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->submit();
|
$this->submit();
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
ray($e->getMessage());
|
ray($e->getMessage());
|
||||||
$this->model->discord_enabled = false;
|
$this->team->discord_enabled = false;
|
||||||
$this->validate();
|
$this->validate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,16 +45,14 @@ class DiscordSettings extends Component
|
|||||||
|
|
||||||
public function saveModel()
|
public function saveModel()
|
||||||
{
|
{
|
||||||
$this->model->save();
|
$this->team->save();
|
||||||
if (is_a($this->model, Team::class)) {
|
refreshSession();
|
||||||
refreshSession();
|
|
||||||
}
|
|
||||||
$this->emit('success', 'Settings saved.');
|
$this->emit('success', 'Settings saved.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendTestNotification()
|
public function sendTestNotification()
|
||||||
{
|
{
|
||||||
$this->model->notify(new Test);
|
$this->team->notify(new Test());
|
||||||
$this->emit('success', 'Test notification sent.');
|
$this->emit('success', 'Test notification sent.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,55 +6,154 @@ use App\Models\InstanceSettings;
|
|||||||
use App\Models\Team;
|
use App\Models\Team;
|
||||||
use App\Notifications\Test;
|
use App\Notifications\Test;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
use Log;
|
||||||
|
|
||||||
class EmailSettings extends Component
|
class EmailSettings extends Component
|
||||||
{
|
{
|
||||||
public Team $model;
|
public Team $team;
|
||||||
public string $emails;
|
public string $emails;
|
||||||
|
public bool $sharedEmailEnabled = false;
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'model.smtp_enabled' => 'nullable|boolean',
|
'team.smtp_enabled' => 'nullable|boolean',
|
||||||
'model.smtp_from_address' => 'required|email',
|
'team.smtp_from_address' => 'required|email',
|
||||||
'model.smtp_from_name' => 'required',
|
'team.smtp_from_name' => 'required',
|
||||||
'model.smtp_recipients' => 'nullable',
|
'team.smtp_recipients' => 'nullable',
|
||||||
'model.smtp_host' => 'required',
|
'team.smtp_host' => 'required',
|
||||||
'model.smtp_port' => 'required',
|
'team.smtp_port' => 'required',
|
||||||
'model.smtp_encryption' => 'nullable',
|
'team.smtp_encryption' => 'nullable',
|
||||||
'model.smtp_username' => 'nullable',
|
'team.smtp_username' => 'nullable',
|
||||||
'model.smtp_password' => 'nullable',
|
'team.smtp_password' => 'nullable',
|
||||||
'model.smtp_timeout' => 'nullable',
|
'team.smtp_timeout' => 'nullable',
|
||||||
'model.smtp_notifications_test' => 'nullable|boolean',
|
'team.smtp_notifications_test' => 'nullable|boolean',
|
||||||
'model.smtp_notifications_deployments' => 'nullable|boolean',
|
'team.smtp_notifications_deployments' => 'nullable|boolean',
|
||||||
'model.smtp_notifications_status_changes' => 'nullable|boolean',
|
'team.smtp_notifications_status_changes' => 'nullable|boolean',
|
||||||
'model.smtp_notifications_database_backups' => 'nullable|boolean',
|
'team.smtp_notifications_database_backups' => 'nullable|boolean',
|
||||||
|
'team.use_instance_email_settings' => 'boolean',
|
||||||
|
'team.resend_enabled' => 'nullable|boolean',
|
||||||
|
'team.resend_api_key' => 'nullable',
|
||||||
];
|
];
|
||||||
protected $validationAttributes = [
|
protected $validationAttributes = [
|
||||||
'model.smtp_from_address' => 'From Address',
|
'team.smtp_from_address' => 'From Address',
|
||||||
'model.smtp_from_name' => 'From Name',
|
'team.smtp_from_name' => 'From Name',
|
||||||
'model.smtp_recipients' => 'Recipients',
|
'team.smtp_recipients' => 'Recipients',
|
||||||
'model.smtp_host' => 'Host',
|
'team.smtp_host' => 'Host',
|
||||||
'model.smtp_port' => 'Port',
|
'team.smtp_port' => 'Port',
|
||||||
'model.smtp_encryption' => 'Encryption',
|
'team.smtp_encryption' => 'Encryption',
|
||||||
'model.smtp_username' => 'Username',
|
'team.smtp_username' => 'Username',
|
||||||
'model.smtp_password' => 'Password',
|
'team.smtp_password' => 'Password',
|
||||||
|
'team.smtp_timeout' => 'Timeout',
|
||||||
|
'team.resend_enabled' => 'Resend Enabled',
|
||||||
|
'team.resend_api_key' => 'Resend API Key',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$this->decrypt();
|
$this->team = auth()->user()->currentTeam();
|
||||||
|
['sharedEmailEnabled' => $this->sharedEmailEnabled] = $this->team->limits;
|
||||||
$this->emails = auth()->user()->email;
|
$this->emails = auth()->user()->email;
|
||||||
}
|
}
|
||||||
|
public function submitFromFields()
|
||||||
private function decrypt()
|
|
||||||
{
|
{
|
||||||
if (data_get($this->model, 'smtp_password')) {
|
try {
|
||||||
try {
|
$this->resetErrorBag();
|
||||||
$this->model->smtp_password = decrypt($this->model->smtp_password);
|
$this->validate([
|
||||||
} catch (\Exception $e) {
|
'team.smtp_from_address' => 'required|email',
|
||||||
|
'team.smtp_from_name' => 'required',
|
||||||
|
]);
|
||||||
|
$this->team->save();
|
||||||
|
refreshSession();
|
||||||
|
$this->emit('success', 'Settings saved successfully.');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function sendTestNotification()
|
||||||
|
{
|
||||||
|
$this->team->notify(new Test($this->emails));
|
||||||
|
$this->emit('success', 'Test Email sent successfully.');
|
||||||
|
}
|
||||||
|
public function instantSaveInstance()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (!$this->sharedEmailEnabled) {
|
||||||
|
throw new \Exception('Not allowed to change settings. Please upgrade your subscription.');
|
||||||
}
|
}
|
||||||
|
$this->team->smtp_enabled = false;
|
||||||
|
$this->team->resend_enabled = false;
|
||||||
|
$this->team->save();
|
||||||
|
refreshSession();
|
||||||
|
$this->emit('success', 'Settings saved successfully.');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function instantSaveResend()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->team->smtp_enabled = false;
|
||||||
|
$this->submitResend();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->team->smtp_enabled = false;
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function instantSave()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->team->resend_enabled = false;
|
||||||
|
$this->submit();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->team->smtp_enabled = false;
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function saveModel()
|
||||||
|
{
|
||||||
|
$this->team->save();
|
||||||
|
refreshSession();
|
||||||
|
$this->emit('success', 'Settings saved.');
|
||||||
|
}
|
||||||
|
public function submit()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->resetErrorBag();
|
||||||
|
$this->validate([
|
||||||
|
'team.smtp_from_address' => 'required|email',
|
||||||
|
'team.smtp_from_name' => 'required',
|
||||||
|
'team.smtp_host' => 'required',
|
||||||
|
'team.smtp_port' => 'required|numeric',
|
||||||
|
'team.smtp_encryption' => 'nullable',
|
||||||
|
'team.smtp_username' => 'nullable',
|
||||||
|
'team.smtp_password' => 'nullable',
|
||||||
|
'team.smtp_timeout' => 'nullable',
|
||||||
|
]);
|
||||||
|
$this->team->save();
|
||||||
|
refreshSession();
|
||||||
|
$this->emit('success', 'Settings saved successfully.');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->team->smtp_enabled = false;
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function submitResend()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->resetErrorBag();
|
||||||
|
$this->validate([
|
||||||
|
'team.smtp_from_address' => 'required|email',
|
||||||
|
'team.smtp_from_name' => 'required',
|
||||||
|
'team.resend_api_key' => 'required'
|
||||||
|
]);
|
||||||
|
$this->team->save();
|
||||||
|
refreshSession();
|
||||||
|
$this->emit('success', 'Settings saved successfully.');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->team->resend_enabled = false;
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
public function copyFromInstanceSettings()
|
public function copyFromInstanceSettings()
|
||||||
{
|
{
|
||||||
$settings = InstanceSettings::get();
|
$settings = InstanceSettings::get();
|
||||||
@@ -72,55 +171,22 @@ class EmailSettings extends Component
|
|||||||
'smtp_password' => $settings->smtp_password,
|
'smtp_password' => $settings->smtp_password,
|
||||||
'smtp_timeout' => $settings->smtp_timeout,
|
'smtp_timeout' => $settings->smtp_timeout,
|
||||||
]);
|
]);
|
||||||
$this->decrypt();
|
|
||||||
if (is_a($team, Team::class)) {
|
|
||||||
refreshSession();
|
|
||||||
}
|
|
||||||
$this->model = $team;
|
|
||||||
$this->emit('success', 'Settings saved.');
|
|
||||||
} else {
|
|
||||||
$this->emit('error', 'Instance SMTP settings are not enabled.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function sendTestNotification()
|
|
||||||
{
|
|
||||||
$this->model->notify(new Test($this->emails));
|
|
||||||
$this->emit('success', 'Test Email sent successfully.');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function instantSave()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$this->submit();
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->model->smtp_enabled = false;
|
|
||||||
$this->validate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function submit()
|
|
||||||
{
|
|
||||||
$this->resetErrorBag();
|
|
||||||
$this->validate();
|
|
||||||
|
|
||||||
if ($this->model->smtp_password) {
|
|
||||||
$this->model->smtp_password = encrypt($this->model->smtp_password);
|
|
||||||
} else {
|
|
||||||
$this->model->smtp_password = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->model->smtp_recipients = str_replace(' ', '', $this->model->smtp_recipients);
|
|
||||||
$this->saveModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function saveModel()
|
|
||||||
{
|
|
||||||
$this->model->save();
|
|
||||||
$this->decrypt();
|
|
||||||
if (is_a($this->model, Team::class)) {
|
|
||||||
refreshSession();
|
refreshSession();
|
||||||
|
$this->team = $team;
|
||||||
|
$this->emit('success', 'Settings saved.');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
$this->emit('success', 'Settings saved.');
|
if ($settings->resend_enabled) {
|
||||||
|
$team = currentTeam();
|
||||||
|
$team->update([
|
||||||
|
'resend_enabled' => $settings->resend_enabled,
|
||||||
|
'resend_api_key' => $settings->resend_api_key,
|
||||||
|
]);
|
||||||
|
refreshSession();
|
||||||
|
$this->team = $team;
|
||||||
|
$this->emit('success', 'Settings saved.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->emit('error', 'Instance SMTP/Resend settings are not enabled.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
64
app/Http/Livewire/Notifications/TelegramSettings.php
Normal file
64
app/Http/Livewire/Notifications/TelegramSettings.php
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Livewire\Notifications;
|
||||||
|
|
||||||
|
use App\Models\Team;
|
||||||
|
use App\Notifications\Test;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class TelegramSettings extends Component
|
||||||
|
{
|
||||||
|
public Team $team;
|
||||||
|
protected $rules = [
|
||||||
|
'team.telegram_enabled' => 'nullable|boolean',
|
||||||
|
'team.telegram_token' => 'required|string',
|
||||||
|
'team.telegram_chat_id' => 'required|string',
|
||||||
|
'team.telegram_notifications_test' => 'nullable|boolean',
|
||||||
|
'team.telegram_notifications_deployments' => 'nullable|boolean',
|
||||||
|
'team.telegram_notifications_status_changes' => 'nullable|boolean',
|
||||||
|
'team.telegram_notifications_database_backups' => 'nullable|boolean',
|
||||||
|
'team.telegram_notifications_test_message_thread_id' => 'nullable|string',
|
||||||
|
'team.telegram_notifications_deployments_message_thread_id' => 'nullable|string',
|
||||||
|
'team.telegram_notifications_status_changes_message_thread_id' => 'nullable|string',
|
||||||
|
'team.telegram_notifications_database_backups_message_thread_id' => 'nullable|string',
|
||||||
|
];
|
||||||
|
protected $validationAttributes = [
|
||||||
|
'team.telegram_token' => 'Token',
|
||||||
|
'team.telegram_chat_id' => 'Chat ID',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->team = auth()->user()->currentTeam();
|
||||||
|
}
|
||||||
|
public function instantSave()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->submit();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
ray($e->getMessage());
|
||||||
|
$this->team->telegram_enabled = false;
|
||||||
|
$this->validate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function submit()
|
||||||
|
{
|
||||||
|
$this->resetErrorBag();
|
||||||
|
$this->validate();
|
||||||
|
$this->saveModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveModel()
|
||||||
|
{
|
||||||
|
$this->team->save();
|
||||||
|
refreshSession();
|
||||||
|
$this->emit('success', 'Settings saved.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendTestNotification()
|
||||||
|
{
|
||||||
|
$this->team->notify(new Test());
|
||||||
|
$this->emit('success', 'Test notification sent.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ use Livewire\Component;
|
|||||||
class Change extends Component
|
class Change extends Component
|
||||||
{
|
{
|
||||||
public PrivateKey $private_key;
|
public PrivateKey $private_key;
|
||||||
|
public $public_key;
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'private_key.name' => 'required|string',
|
'private_key.name' => 'required|string',
|
||||||
'private_key.description' => 'nullable|string',
|
'private_key.description' => 'nullable|string',
|
||||||
@@ -21,17 +21,25 @@ class Change extends Component
|
|||||||
'private_key.private_key' => 'private key'
|
'private_key.private_key' => 'private key'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->public_key = $this->private_key->publicKey();
|
||||||
|
}catch(\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ($this->private_key->isEmpty()) {
|
if ($this->private_key->isEmpty()) {
|
||||||
$this->private_key->delete();
|
$this->private_key->delete();
|
||||||
currentTeam()->privateKeys = PrivateKey::where('team_id', currentTeam()->id)->get();
|
currentTeam()->privateKeys = PrivateKey::where('team_id', currentTeam()->id)->get();
|
||||||
return redirect()->route('private-key.all');
|
return redirect()->route('security.private-key.index');
|
||||||
}
|
}
|
||||||
$this->emit('error', 'This private key is in use and cannot be deleted. Please delete all servers, applications, and GitHub/GitLab apps that use this private key before deleting it.');
|
$this->emit('error', 'This private key is in use and cannot be deleted. Please delete all servers, applications, and GitHub/GitLab apps that use this private key before deleting it.');
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,8 +49,8 @@ class Change extends Component
|
|||||||
$this->private_key->private_key = formatPrivateKey($this->private_key->private_key);
|
$this->private_key->private_key = formatPrivateKey($this->private_key->private_key);
|
||||||
$this->private_key->save();
|
$this->private_key->save();
|
||||||
refresh_server_connection($this->private_key);
|
refresh_server_connection($this->private_key);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,20 @@
|
|||||||
namespace App\Http\Livewire\PrivateKey;
|
namespace App\Http\Livewire\PrivateKey;
|
||||||
|
|
||||||
use App\Models\PrivateKey;
|
use App\Models\PrivateKey;
|
||||||
|
use DanHarrin\LivewireRateLimiting\WithRateLimiting;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
use phpseclib3\Crypt\PublicKeyLoader;
|
||||||
|
|
||||||
class Create extends Component
|
class Create extends Component
|
||||||
{
|
{
|
||||||
public string|null $from = null;
|
use WithRateLimiting;
|
||||||
public string $name;
|
public string $name;
|
||||||
public string|null $description = null;
|
|
||||||
public string $value;
|
public string $value;
|
||||||
|
|
||||||
|
public ?string $from = null;
|
||||||
|
public ?string $description = null;
|
||||||
|
public ?string $publicKey = null;
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'name' => 'required|string',
|
'name' => 'required|string',
|
||||||
'value' => 'required|string',
|
'value' => 'required|string',
|
||||||
@@ -20,6 +26,32 @@ class Create extends Component
|
|||||||
'value' => 'private Key',
|
'value' => 'private Key',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function generateNewKey()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->rateLimit(10);
|
||||||
|
$this->name = generate_random_name();
|
||||||
|
$this->description = 'Created by Coolify';
|
||||||
|
['private' => $this->value, 'public' => $this->publicKey] = generateSSHKey();
|
||||||
|
} catch(\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function updated($updateProperty)
|
||||||
|
{
|
||||||
|
if ($updateProperty === 'value') {
|
||||||
|
try {
|
||||||
|
$this->publicKey = PublicKeyLoader::load($this->$updateProperty)->getPublicKey()->toString('OpenSSH',['comment' => '']);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
if ($this->$updateProperty === "") {
|
||||||
|
$this->publicKey = "";
|
||||||
|
} else {
|
||||||
|
$this->publicKey = "Invalid private key";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->validateOnly($updateProperty);
|
||||||
|
}
|
||||||
public function createPrivateKey()
|
public function createPrivateKey()
|
||||||
{
|
{
|
||||||
$this->validate();
|
$this->validate();
|
||||||
@@ -37,9 +69,9 @@ class Create extends Component
|
|||||||
if ($this->from === 'server') {
|
if ($this->from === 'server') {
|
||||||
return redirect()->route('server.create');
|
return redirect()->route('server.create');
|
||||||
}
|
}
|
||||||
return redirect()->route('private-key.show', ['private_key_uuid' => $private_key->uuid]);
|
return redirect()->route('security.private-key.show', ['private_key_uuid' => $private_key->uuid]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class Form extends Component
|
|||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
]);
|
]);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ class AddEmpty extends Component
|
|||||||
'team_id' => currentTeam()->id,
|
'team_id' => currentTeam()->id,
|
||||||
]);
|
]);
|
||||||
return redirect()->route('project.show', $project->uuid);
|
return redirect()->route('project.show', $project->uuid);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
general_error_handler($e, $this);
|
return handleError($e, $this);
|
||||||
} finally {
|
} finally {
|
||||||
$this->name = '';
|
$this->name = '';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ class AddEnvironment extends Component
|
|||||||
'project_uuid' => $this->project->uuid,
|
'project_uuid' => $this->project->uuid,
|
||||||
'environment_name' => $environment->name,
|
'environment_name' => $environment->name,
|
||||||
]);
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
general_error_handler($e, $this);
|
handleError($e, $this);
|
||||||
} finally {
|
} finally {
|
||||||
$this->name = '';
|
$this->name = '';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class DeploymentNavbar extends Component
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,8 +159,8 @@ class General extends Component
|
|||||||
}
|
}
|
||||||
$this->application->save();
|
$this->application->save();
|
||||||
$this->emit('success', 'Application settings updated!');
|
$this->emit('success', 'Application settings updated!');
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Http\Livewire\Project\Application;
|
namespace App\Http\Livewire\Project\Application;
|
||||||
|
|
||||||
use App\Jobs\ApplicationContainerStatusJob;
|
use App\Jobs\ContainerStatusJob;
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use App\Notifications\Application\StatusChanged;
|
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use Visus\Cuid2\Cuid2;
|
use Visus\Cuid2\Cuid2;
|
||||||
|
|
||||||
@@ -22,10 +21,11 @@ class Heading extends Component
|
|||||||
|
|
||||||
public function check_status()
|
public function check_status()
|
||||||
{
|
{
|
||||||
dispatch_sync(new ApplicationContainerStatusJob(
|
dispatch_sync(new ContainerStatusJob($this->application->destination->server));
|
||||||
application: $this->application,
|
|
||||||
));
|
|
||||||
$this->application->refresh();
|
$this->application->refresh();
|
||||||
|
$this->application->previews->each(function ($preview) {
|
||||||
|
$preview->refresh();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function force_deploy_without_cache()
|
public function force_deploy_without_cache()
|
||||||
@@ -68,10 +68,11 @@ class Heading extends Component
|
|||||||
["docker rm -f {$containerName}"],
|
["docker rm -f {$containerName}"],
|
||||||
$this->application->destination->server
|
$this->application->destination->server
|
||||||
);
|
);
|
||||||
$this->application->status = 'stopped';
|
$this->application->status = 'exited';
|
||||||
$this->application->save();
|
$this->application->save();
|
||||||
// $this->application->environment->project->team->notify(new StatusChanged($this->application));
|
// $this->application->environment->project->team->notify(new StatusChanged($this->application));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->application->refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Http\Livewire\Project\Application;
|
namespace App\Http\Livewire\Project\Application;
|
||||||
|
|
||||||
use App\Jobs\ApplicationContainerStatusJob;
|
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use App\Models\ApplicationPreview;
|
use App\Models\ApplicationPreview;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
@@ -23,14 +22,6 @@ class Previews extends Component
|
|||||||
$this->parameters = get_route_parameters();
|
$this->parameters = get_route_parameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadStatus($pull_request_id)
|
|
||||||
{
|
|
||||||
dispatch(new ApplicationContainerStatusJob(
|
|
||||||
application: $this->application,
|
|
||||||
pullRequestId: $pull_request_id
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function load_prs()
|
public function load_prs()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -39,7 +30,7 @@ class Previews extends Component
|
|||||||
$this->pull_requests = $data->sortBy('number')->values();
|
$this->pull_requests = $data->sortBy('number')->values();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$this->rate_limit_remaining = 0;
|
$this->rate_limit_remaining = 0;
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +59,7 @@ class Previews extends Component
|
|||||||
'environment_name' => $this->parameters['environment_name'],
|
'environment_name' => $this->parameters['environment_name'],
|
||||||
]);
|
]);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +79,7 @@ class Previews extends Component
|
|||||||
ApplicationPreview::where('application_id', $this->application->id)->where('pull_request_id', $pull_request_id)->delete();
|
ApplicationPreview::where('application_id', $this->application->id)->where('pull_request_id', $pull_request_id)->delete();
|
||||||
$this->application->refresh();
|
$this->application->refresh();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class Rollback extends Component
|
|||||||
];
|
];
|
||||||
})->toArray();
|
})->toArray();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class BackupEdit extends Component
|
|||||||
$this->backup->save();
|
$this->backup->save();
|
||||||
$this->backup->refresh();
|
$this->backup->refresh();
|
||||||
$this->emit('success', 'Backup updated successfully');
|
$this->emit('success', 'Backup updated successfully');
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
$this->emit('error', $e->getMessage());
|
$this->emit('error', $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ class BackupEdit extends Component
|
|||||||
$this->backup->save();
|
$this->backup->save();
|
||||||
$this->backup->refresh();
|
$this->backup->refresh();
|
||||||
$this->emit('success', 'Backup updated successfully');
|
$this->emit('success', 'Backup updated successfully');
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
$this->emit('error', $e->getMessage());
|
$this->emit('error', $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ class CreateScheduledBackup extends Component
|
|||||||
'team_id' => currentTeam()->id,
|
'team_id' => currentTeam()->id,
|
||||||
]);
|
]);
|
||||||
$this->emit('refreshScheduledBackups');
|
$this->emit('refreshScheduledBackups');
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
general_error_handler($e, $this);
|
handleError($e, $this);
|
||||||
} finally {
|
} finally {
|
||||||
$this->frequency = '';
|
$this->frequency = '';
|
||||||
$this->save_s3 = true;
|
$this->save_s3 = true;
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
namespace App\Http\Livewire\Project\Database;
|
namespace App\Http\Livewire\Project\Database;
|
||||||
|
|
||||||
use App\Actions\Database\StartPostgresql;
|
use App\Actions\Database\StartPostgresql;
|
||||||
use App\Jobs\DatabaseContainerStatusJob;
|
use App\Jobs\ContainerStatusJob;
|
||||||
use App\Notifications\Application\StatusChanged;
|
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class Heading extends Component
|
class Heading extends Component
|
||||||
@@ -25,9 +24,7 @@ class Heading extends Component
|
|||||||
|
|
||||||
public function check_status()
|
public function check_status()
|
||||||
{
|
{
|
||||||
dispatch_sync(new DatabaseContainerStatusJob(
|
dispatch_sync(new ContainerStatusJob($this->database->destination->server));
|
||||||
database: $this->database,
|
|
||||||
));
|
|
||||||
$this->database->refresh();
|
$this->database->refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,12 +35,17 @@ class Heading extends Component
|
|||||||
|
|
||||||
public function stop()
|
public function stop()
|
||||||
{
|
{
|
||||||
remote_process(
|
instant_remote_process(
|
||||||
["docker rm -f {$this->database->uuid}"],
|
["docker rm -f {$this->database->uuid}"],
|
||||||
$this->database->destination->server
|
$this->database->destination->server
|
||||||
);
|
);
|
||||||
$this->database->status = 'stopped';
|
if ($this->database->is_public) {
|
||||||
|
stopPostgresProxy($this->database);
|
||||||
|
$this->database->is_public = false;
|
||||||
|
}
|
||||||
|
$this->database->status = 'exited';
|
||||||
$this->database->save();
|
$this->database->save();
|
||||||
|
$this->check_status();
|
||||||
// $this->database->environment->project->team->notify(new StatusChanged($this->database));
|
// $this->database->environment->project->team->notify(new StatusChanged($this->database));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class InitScript extends Component
|
|||||||
$this->script['filename'] = $this->filename;
|
$this->script['filename'] = $this->filename;
|
||||||
$this->emitUp('save_init_script', $this->script);
|
$this->emitUp('save_init_script', $this->script);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Http\Livewire\Project\Database\Postgresql;
|
|||||||
use App\Models\StandalonePostgresql;
|
use App\Models\StandalonePostgresql;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
use function Aws\filter;
|
use function Aws\filter;
|
||||||
|
|
||||||
class General extends Component
|
class General extends Component
|
||||||
@@ -12,6 +13,7 @@ class General extends Component
|
|||||||
public StandalonePostgresql $database;
|
public StandalonePostgresql $database;
|
||||||
public string $new_filename;
|
public string $new_filename;
|
||||||
public string $new_content;
|
public string $new_content;
|
||||||
|
public string $db_url;
|
||||||
|
|
||||||
protected $listeners = ['refresh', 'save_init_script', 'delete_init_script'];
|
protected $listeners = ['refresh', 'save_init_script', 'delete_init_script'];
|
||||||
|
|
||||||
@@ -26,6 +28,8 @@ class General extends Component
|
|||||||
'database.init_scripts' => 'nullable',
|
'database.init_scripts' => 'nullable',
|
||||||
'database.image' => 'required',
|
'database.image' => 'required',
|
||||||
'database.ports_mappings' => 'nullable',
|
'database.ports_mappings' => 'nullable',
|
||||||
|
'database.is_public' => 'nullable|boolean',
|
||||||
|
'database.public_port' => 'nullable|integer',
|
||||||
];
|
];
|
||||||
protected $validationAttributes = [
|
protected $validationAttributes = [
|
||||||
'database.name' => 'Name',
|
'database.name' => 'Name',
|
||||||
@@ -38,8 +42,44 @@ class General extends Component
|
|||||||
'database.init_scripts' => 'Init Scripts',
|
'database.init_scripts' => 'Init Scripts',
|
||||||
'database.image' => 'Image',
|
'database.image' => 'Image',
|
||||||
'database.ports_mappings' => 'Port Mapping',
|
'database.ports_mappings' => 'Port Mapping',
|
||||||
|
'database.is_public' => 'Is Public',
|
||||||
|
'database.public_port' => 'Public Port',
|
||||||
];
|
];
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->getDbUrl();
|
||||||
|
}
|
||||||
|
public function getDbUrl() {
|
||||||
|
if ($this->database->is_public) {
|
||||||
|
$this->db_url = "postgres://{$this->database->postgres_user}:{$this->database->postgres_password}@{$this->database->destination->server->ip}:{$this->database->public_port}/{$this->database->postgres_db}";
|
||||||
|
} else {
|
||||||
|
$this->db_url = "postgres://{$this->database->postgres_user}:{$this->database->postgres_password}@{$this->database->uuid}:5432/{$this->database->postgres_db}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function instantSave()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if ($this->database->is_public && !$this->database->public_port) {
|
||||||
|
$this->emit('error', 'Public port is required.');
|
||||||
|
$this->database->is_public = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($this->database->is_public) {
|
||||||
|
$this->emit('success', 'Starting TCP proxy...');
|
||||||
|
startPostgresProxy($this->database);
|
||||||
|
$this->emit('success', 'Database is now publicly accessible.');
|
||||||
|
} else {
|
||||||
|
stopPostgresProxy($this->database);
|
||||||
|
$this->emit('success', 'Database is no longer publicly accessible.');
|
||||||
|
}
|
||||||
|
$this->getDbUrl();
|
||||||
|
$this->database->save();
|
||||||
|
} catch(\Throwable $e) {
|
||||||
|
$this->database->is_public = !$this->database->is_public;
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
public function save_init_script($script)
|
public function save_init_script($script)
|
||||||
{
|
{
|
||||||
$this->database->init_scripts = filter($this->database->init_scripts, fn ($s) => $s['filename'] !== $script['filename']);
|
$this->database->init_scripts = filter($this->database->init_scripts, fn ($s) => $s['filename'] !== $script['filename']);
|
||||||
@@ -101,7 +141,7 @@ class General extends Component
|
|||||||
$this->database->save();
|
$this->database->save();
|
||||||
$this->emit('success', 'Database updated successfully.');
|
$this->emit('success', 'Database updated successfully.');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ class Edit extends Component
|
|||||||
try {
|
try {
|
||||||
$this->project->save();
|
$this->project->save();
|
||||||
$this->emit('saved');
|
$this->emit('saved');
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler($e, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,15 +7,19 @@ use App\Models\GithubApp;
|
|||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\StandaloneDocker;
|
use App\Models\StandaloneDocker;
|
||||||
use App\Models\SwarmDocker;
|
use App\Models\SwarmDocker;
|
||||||
|
use App\Traits\SaveFromRedirect;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
use Route;
|
||||||
|
|
||||||
class GithubPrivateRepository extends Component
|
class GithubPrivateRepository extends Component
|
||||||
{
|
{
|
||||||
|
use SaveFromRedirect;
|
||||||
public $current_step = 'github_apps';
|
public $current_step = 'github_apps';
|
||||||
public $github_apps;
|
public $github_apps;
|
||||||
public GithubApp $github_app;
|
public GithubApp $github_app;
|
||||||
public $parameters;
|
public $parameters;
|
||||||
|
public $currentRoute;
|
||||||
public $query;
|
public $query;
|
||||||
public $type;
|
public $type;
|
||||||
|
|
||||||
@@ -36,14 +40,30 @@ class GithubPrivateRepository extends Component
|
|||||||
public string|null $publish_directory = null;
|
public string|null $publish_directory = null;
|
||||||
protected int $page = 1;
|
protected int $page = 1;
|
||||||
|
|
||||||
|
// public function saveFromRedirect(string $route, ?Collection $parameters = null){
|
||||||
|
// session()->forget('from');
|
||||||
|
// if (!$parameters || $parameters->count() === 0) {
|
||||||
|
// $parameters = $this->parameters;
|
||||||
|
// }
|
||||||
|
// $parameters = collect($parameters) ?? collect([]);
|
||||||
|
// $queries = collect($this->query) ?? collect([]);
|
||||||
|
// $parameters = $parameters->merge($queries);
|
||||||
|
// session(['from'=> [
|
||||||
|
// 'back'=> $this->currentRoute,
|
||||||
|
// 'route' => $route,
|
||||||
|
// 'parameters' => $parameters
|
||||||
|
// ]]);
|
||||||
|
// return redirect()->route($route);
|
||||||
|
// }
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
|
$this->currentRoute = Route::currentRouteName();
|
||||||
$this->parameters = get_route_parameters();
|
$this->parameters = get_route_parameters();
|
||||||
$this->query = request()->query();
|
$this->query = request()->query();
|
||||||
$this->repositories = $this->branches = collect();
|
$this->repositories = $this->branches = collect();
|
||||||
$this->github_apps = GithubApp::private();
|
$this->github_apps = GithubApp::private();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadRepositories($github_app_id)
|
public function loadRepositories($github_app_id)
|
||||||
{
|
{
|
||||||
$this->repositories = collect();
|
$this->repositories = collect();
|
||||||
@@ -144,8 +164,8 @@ class GithubPrivateRepository extends Component
|
|||||||
'environment_name' => $environment->name,
|
'environment_name' => $environment->name,
|
||||||
'project_uuid' => $project->uuid,
|
'project_uuid' => $project->uuid,
|
||||||
]);
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,8 +117,8 @@ class GithubPrivateRepositoryDeployKey extends Component
|
|||||||
'environment_name' => $environment->name,
|
'environment_name' => $environment->name,
|
||||||
'application_uuid' => $application->uuid,
|
'application_uuid' => $application->uuid,
|
||||||
]);
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class PublicGitRepository extends Component
|
|||||||
'publish_directory' => 'publish directory',
|
'publish_directory' => 'publish directory',
|
||||||
];
|
];
|
||||||
private object $repository_url_parsed;
|
private object $repository_url_parsed;
|
||||||
private GithubApp|GitlabApp $git_source;
|
private GithubApp|GitlabApp|null $git_source = null;
|
||||||
private string $git_host;
|
private string $git_host;
|
||||||
private string $git_repository;
|
private string $git_repository;
|
||||||
|
|
||||||
@@ -67,24 +67,23 @@ class PublicGitRepository extends Component
|
|||||||
|
|
||||||
public function load_branch()
|
public function load_branch()
|
||||||
{
|
{
|
||||||
$this->branch_found = false;
|
try {
|
||||||
|
$this->branch_found = false;
|
||||||
$this->validate([
|
$this->validate([
|
||||||
'repository_url' => 'required|url'
|
'repository_url' => 'required|url'
|
||||||
]);
|
]);
|
||||||
$this->get_git_source();
|
$this->get_git_source();
|
||||||
try {
|
$this->get_branch();
|
||||||
$this->get_branch();
|
$this->selected_branch = $this->git_branch;
|
||||||
$this->selected_branch = $this->git_branch;
|
} catch (\Throwable $e) {
|
||||||
} catch (\Exception $e) {
|
return handleError($e, $this);
|
||||||
return general_error_handler(err: $e, that: $this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->branch_found && $this->git_branch == 'main') {
|
if (!$this->branch_found && $this->git_branch == 'main') {
|
||||||
try {
|
try {
|
||||||
$this->git_branch = 'master';
|
$this->git_branch = 'master';
|
||||||
$this->get_branch();
|
$this->get_branch();
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,6 +102,9 @@ class PublicGitRepository extends Component
|
|||||||
} elseif ($this->git_host == 'bitbucket.org') {
|
} elseif ($this->git_host == 'bitbucket.org') {
|
||||||
// Not supported yet
|
// Not supported yet
|
||||||
}
|
}
|
||||||
|
if (is_null($this->git_source)) {
|
||||||
|
throw new \Exception('Git source not found. What?!');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function get_branch()
|
private function get_branch()
|
||||||
@@ -159,8 +161,8 @@ class PublicGitRepository extends Component
|
|||||||
'environment_name' => $environment->name,
|
'environment_name' => $environment->name,
|
||||||
'application_uuid' => $application->uuid,
|
'application_uuid' => $application->uuid,
|
||||||
]);
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,45 +3,79 @@
|
|||||||
namespace App\Http\Livewire\Project\New;
|
namespace App\Http\Livewire\Project\New;
|
||||||
|
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
|
use App\Models\StandaloneDocker;
|
||||||
|
use App\Models\SwarmDocker;
|
||||||
use Countable;
|
use Countable;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
use Route;
|
||||||
|
|
||||||
class Select extends Component
|
class Select extends Component
|
||||||
{
|
{
|
||||||
public $current_step = 'type';
|
public $current_step = 'type';
|
||||||
|
public ?int $server = null;
|
||||||
public string $type;
|
public string $type;
|
||||||
public string $server_id;
|
public string $server_id;
|
||||||
public string $destination_uuid;
|
public string $destination_uuid;
|
||||||
public Countable|array|Server $servers;
|
public Countable|array|Server $servers;
|
||||||
public $destinations = [];
|
public Collection|array $standaloneDockers = [];
|
||||||
|
public Collection|array $swarmDockers = [];
|
||||||
public array $parameters;
|
public array $parameters;
|
||||||
|
|
||||||
|
public ?string $existingPostgresqlUrl = null;
|
||||||
|
|
||||||
|
protected $queryString = [
|
||||||
|
'server',
|
||||||
|
];
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$this->parameters = get_route_parameters();
|
$this->parameters = get_route_parameters();
|
||||||
|
if (isDev()) {
|
||||||
|
$this->existingPostgresqlUrl = 'postgres://coolify:password@coolify-db:5432';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_type(string $type)
|
// public function addExistingPostgresql()
|
||||||
|
// {
|
||||||
|
// try {
|
||||||
|
// instantCommand("psql {$this->existingPostgresqlUrl} -c 'SELECT 1'");
|
||||||
|
// $this->emit('success', 'Successfully connected to the database.');
|
||||||
|
// } catch (\Throwable $e) {
|
||||||
|
// return handleError($e, $this);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
public function setType(string $type)
|
||||||
{
|
{
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
if ($type === "existing-postgresql") {
|
||||||
|
$this->current_step = $type;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (count($this->servers) === 1) {
|
if (count($this->servers) === 1) {
|
||||||
$server = $this->servers->first();
|
$server = $this->servers->first();
|
||||||
$this->set_server($server);
|
$this->setServer($server);
|
||||||
if (count($server->destinations()) === 1) {
|
if (count($server->destinations()) === 1) {
|
||||||
$this->set_destination($server->destinations()->first()->uuid);
|
$this->setDestination($server->destinations()->first()->uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!is_null($this->server)) {
|
||||||
|
$foundServer = $this->servers->where('id', $this->server)->first();
|
||||||
|
if ($foundServer) {
|
||||||
|
return $this->setServer($foundServer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->current_step = 'servers';
|
$this->current_step = 'servers';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_server(Server $server)
|
public function setServer(Server $server)
|
||||||
{
|
{
|
||||||
$this->server_id = $server->id;
|
$this->server_id = $server->id;
|
||||||
$this->destinations = $server->destinations();
|
$this->standaloneDockers = $server->standaloneDockers;
|
||||||
|
$this->swarmDockers = $server->swarmDockers;
|
||||||
$this->current_step = 'destinations';
|
$this->current_step = 'destinations';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_destination(string $destination_uuid)
|
public function setDestination(string $destination_uuid)
|
||||||
{
|
{
|
||||||
$this->destination_uuid = $destination_uuid;
|
$this->destination_uuid = $destination_uuid;
|
||||||
redirect()->route('project.resources.new', [
|
redirect()->route('project.resources.new', [
|
||||||
|
|||||||
@@ -5,21 +5,89 @@ namespace App\Http\Livewire\Project\Shared\EnvironmentVariable;
|
|||||||
use App\Models\EnvironmentVariable;
|
use App\Models\EnvironmentVariable;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use Visus\Cuid2\Cuid2;
|
use Visus\Cuid2\Cuid2;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class All extends Component
|
class All extends Component
|
||||||
{
|
{
|
||||||
public $resource;
|
public $resource;
|
||||||
|
public bool $showPreview = false;
|
||||||
public string|null $modalId = null;
|
public string|null $modalId = null;
|
||||||
|
public ?string $variables = null;
|
||||||
|
public ?string $variablesPreview = null;
|
||||||
|
public string $view = 'normal';
|
||||||
protected $listeners = ['refreshEnvs', 'submit'];
|
protected $listeners = ['refreshEnvs', 'submit'];
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
|
$resourceClass = get_class($this->resource);
|
||||||
|
$resourceWithPreviews = ['App\Models\Application'];
|
||||||
|
$simpleDockerfile = !is_null(data_get($this->resource, 'dockerfile'));
|
||||||
|
if (Str::of($resourceClass)->contains($resourceWithPreviews) && !$simpleDockerfile) {
|
||||||
|
$this->showPreview = true;
|
||||||
|
}
|
||||||
$this->modalId = new Cuid2(7);
|
$this->modalId = new Cuid2(7);
|
||||||
|
$this->getDevView();
|
||||||
|
}
|
||||||
|
public function getDevView()
|
||||||
|
{
|
||||||
|
$this->variables = $this->resource->environment_variables->map(function ($item) {
|
||||||
|
return "$item->key=$item->value";
|
||||||
|
})->sort()->join('
|
||||||
|
');
|
||||||
|
if ($this->showPreview) {
|
||||||
|
$this->variablesPreview = $this->resource->environment_variables_preview->map(function ($item) {
|
||||||
|
return "$item->key=$item->value";
|
||||||
|
})->sort()->join('
|
||||||
|
');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function switch()
|
||||||
|
{
|
||||||
|
$this->view = $this->view === 'normal' ? 'dev' : 'normal';
|
||||||
|
}
|
||||||
|
public function saveVariables($isPreview)
|
||||||
|
{
|
||||||
|
if ($isPreview) {
|
||||||
|
$variables = parseEnvFormatToArray($this->variablesPreview);
|
||||||
|
$existingVariables = $this->resource->environment_variables_preview();
|
||||||
|
$this->resource->environment_variables_preview()->delete();
|
||||||
|
} else {
|
||||||
|
$variables = parseEnvFormatToArray($this->variables);
|
||||||
|
$existingVariables = $this->resource->environment_variables();
|
||||||
|
$this->resource->environment_variables()->delete();
|
||||||
|
}
|
||||||
|
foreach ($variables as $key => $variable) {
|
||||||
|
$found = $existingVariables->where('key', $key)->first();
|
||||||
|
if ($found) {
|
||||||
|
$found->value = $variable;
|
||||||
|
$found->save();
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
$environment = new EnvironmentVariable();
|
||||||
|
$environment->key = $key;
|
||||||
|
$environment->value = $variable;
|
||||||
|
$environment->is_build_time = false;
|
||||||
|
$environment->is_preview = $isPreview ? true : false;
|
||||||
|
if ($this->resource->type() === 'application') {
|
||||||
|
$environment->application_id = $this->resource->id;
|
||||||
|
}
|
||||||
|
if ($this->resource->type() === 'standalone-postgresql') {
|
||||||
|
$environment->standalone_postgresql_id = $this->resource->id;
|
||||||
|
}
|
||||||
|
$environment->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($isPreview) {
|
||||||
|
$this->emit('success', 'Preview environment variables updated successfully.');
|
||||||
|
} else {
|
||||||
|
$this->emit('success', 'Environment variables updated successfully.');
|
||||||
|
}
|
||||||
|
$this->refreshEnvs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function refreshEnvs()
|
public function refreshEnvs()
|
||||||
{
|
{
|
||||||
$this->resource->refresh();
|
$this->resource->refresh();
|
||||||
|
$this->getDevView();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function submit($data)
|
public function submit($data)
|
||||||
@@ -43,10 +111,10 @@ class All extends Component
|
|||||||
$environment->standalone_postgresql_id = $this->resource->id;
|
$environment->standalone_postgresql_id = $this->resource->id;
|
||||||
}
|
}
|
||||||
$environment->save();
|
$environment->save();
|
||||||
$this->resource->refresh();
|
$this->refreshEnvs();
|
||||||
$this->emit('success', 'Environment variable added successfully.');
|
$this->emit('success', 'Environment variable added successfully.');
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ class ResourceLimits extends Component
|
|||||||
$this->validate();
|
$this->validate();
|
||||||
$this->resource->save();
|
$this->resource->save();
|
||||||
$this->emit('success', 'Resource limits updated successfully.');
|
$this->emit('success', 'Resource limits updated successfully.');
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ class All extends Component
|
|||||||
$this->resource->refresh();
|
$this->resource->refresh();
|
||||||
$this->emit('success', 'Storage added successfully');
|
$this->emit('success', 'Storage added successfully');
|
||||||
$this->emit('clearAddStorage');
|
$this->emit('clearAddStorage');
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ class RunCommand extends Component
|
|||||||
try {
|
try {
|
||||||
$activity = remote_process([$this->command], Server::where('uuid', $this->server)->first(), ignore_errors: true);
|
$activity = remote_process([$this->command], Server::where('uuid', $this->server)->first(), ignore_errors: true);
|
||||||
$this->emit('newMonitorActivity', $activity->id);
|
$this->emit('newMonitorActivity', $activity->id);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
20
app/Http/Livewire/Server/All.php
Normal file
20
app/Http/Livewire/Server/All.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Livewire\Server;
|
||||||
|
|
||||||
|
use App\Models\Server;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class All extends Component
|
||||||
|
{
|
||||||
|
public ?Collection $servers = null;
|
||||||
|
|
||||||
|
public function mount () {
|
||||||
|
$this->servers = Server::ownedByCurrentTeam()->get();
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.server.all');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,15 +4,18 @@ namespace App\Http\Livewire\Server;
|
|||||||
|
|
||||||
use App\Actions\Server\InstallDocker;
|
use App\Actions\Server\InstallDocker;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class Form extends Component
|
class Form extends Component
|
||||||
{
|
{
|
||||||
|
use AuthorizesRequests;
|
||||||
public Server $server;
|
public Server $server;
|
||||||
public $uptime;
|
public $uptime;
|
||||||
public $dockerVersion;
|
public $dockerVersion;
|
||||||
public string|null $wildcard_domain = null;
|
public string|null $wildcard_domain = null;
|
||||||
public int $cleanup_after_percentage;
|
public int $cleanup_after_percentage;
|
||||||
|
public bool $dockerInstallationStarted = false;
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'server.name' => 'required|min:6',
|
'server.name' => 'required|min:6',
|
||||||
@@ -42,50 +45,61 @@ class Form extends Component
|
|||||||
|
|
||||||
public function installDocker()
|
public function installDocker()
|
||||||
{
|
{
|
||||||
$activity = resolve(InstallDocker::class)($this->server, currentTeam());
|
$this->dockerInstallationStarted = true;
|
||||||
|
$activity = resolve(InstallDocker::class)($this->server);
|
||||||
$this->emit('newMonitorActivity', $activity->id);
|
$this->emit('newMonitorActivity', $activity->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateServer()
|
public function validateServer()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
['uptime' => $uptime, 'dockerVersion' => $dockerVersion] = validateServer($this->server);
|
['uptime' => $uptime, 'dockerVersion' => $dockerVersion] = validateServer($this->server, true);
|
||||||
if ($uptime) {
|
if ($uptime) {
|
||||||
$this->uptime = $uptime;
|
$this->uptime = $uptime;
|
||||||
|
$this->emit('success', 'Server is reachable.');
|
||||||
|
} else {
|
||||||
|
ray($this->uptime);
|
||||||
|
|
||||||
|
$this->emit('error', 'Server is not reachable.');
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if ($dockerVersion) {
|
if ($dockerVersion) {
|
||||||
$this->dockerVersion = $dockerVersion;
|
$this->dockerVersion = $dockerVersion;
|
||||||
$this->emit('proxyStatusUpdated');
|
$this->emit('proxyStatusUpdated');
|
||||||
|
$this->emit('success', 'Docker Engine 23+ is installed!');
|
||||||
|
} else {
|
||||||
|
$this->emit('error', 'No Docker Engine or older than 23 version installed.');
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(customErrorMessage: "Server is not reachable. Reason: {$e->getMessage()}", that: $this);
|
return handleError($e, $this, customErrorMessage: "Server is not reachable: ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
if (!$this->server->isEmpty()) {
|
try {
|
||||||
$this->emit('error', 'Server has defined resources. Please delete them first.');
|
$this->authorize('delete', $this->server);
|
||||||
return;
|
if (!$this->server->isEmpty()) {
|
||||||
|
$this->emit('error', 'Server has defined resources. Please delete them first.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->server->delete();
|
||||||
|
return redirect()->route('server.all');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
$this->server->delete();
|
|
||||||
redirect()->route('server.all');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function submit()
|
public function submit()
|
||||||
{
|
{
|
||||||
$this->validate();
|
$this->validate();
|
||||||
// $validation = Validator::make($this->server->toArray(), [
|
$uniqueIPs = Server::all()->reject(function (Server $server) {
|
||||||
// 'ip' => [
|
return $server->id === $this->server->id;
|
||||||
// 'ip'
|
})->pluck('ip')->toArray();
|
||||||
// ],
|
if (in_array($this->server->ip, $uniqueIPs)) {
|
||||||
// ]);
|
$this->emit('error', 'IP address is already in use by another team.');
|
||||||
// if ($validation->fails()) {
|
return;
|
||||||
// foreach ($validation->errors()->getMessages() as $key => $value) {
|
}
|
||||||
// $this->addError("server.{$key}", $value[0]);
|
|
||||||
// }
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
$this->server->settings->wildcard_domain = $this->wildcard_domain;
|
$this->server->settings->wildcard_domain = $this->wildcard_domain;
|
||||||
$this->server->settings->cleanup_after_percentage = $this->cleanup_after_percentage;
|
$this->server->settings->cleanup_after_percentage = $this->cleanup_after_percentage;
|
||||||
$this->server->settings->save();
|
$this->server->settings->save();
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Http\Livewire\Server\New;
|
namespace App\Http\Livewire\Server\New;
|
||||||
|
|
||||||
|
use App\Enums\ProxyStatus;
|
||||||
|
use App\Enums\ProxyTypes;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
@@ -24,7 +26,7 @@ class ByIp extends Component
|
|||||||
protected $rules = [
|
protected $rules = [
|
||||||
'name' => 'required|string',
|
'name' => 'required|string',
|
||||||
'description' => 'nullable|string',
|
'description' => 'nullable|string',
|
||||||
'ip' => 'required|ip',
|
'ip' => 'required',
|
||||||
'user' => 'required|string',
|
'user' => 'required|string',
|
||||||
'port' => 'required|integer',
|
'port' => 'required|integer',
|
||||||
];
|
];
|
||||||
@@ -56,7 +58,7 @@ class ByIp extends Component
|
|||||||
{
|
{
|
||||||
$this->validate();
|
$this->validate();
|
||||||
try {
|
try {
|
||||||
if (!$this->private_key_id) {
|
if (is_null($this->private_key_id)) {
|
||||||
return $this->emit('error', 'You must select a private key');
|
return $this->emit('error', 'You must select a private key');
|
||||||
}
|
}
|
||||||
$server = Server::create([
|
$server = Server::create([
|
||||||
@@ -67,12 +69,17 @@ class ByIp extends Component
|
|||||||
'port' => $this->port,
|
'port' => $this->port,
|
||||||
'team_id' => currentTeam()->id,
|
'team_id' => currentTeam()->id,
|
||||||
'private_key_id' => $this->private_key_id,
|
'private_key_id' => $this->private_key_id,
|
||||||
|
'proxy' => [
|
||||||
|
"type" => ProxyTypes::TRAEFIK_V2->value,
|
||||||
|
"status" => ProxyStatus::EXITED->value,
|
||||||
|
]
|
||||||
|
|
||||||
]);
|
]);
|
||||||
$server->settings->is_part_of_swarm = $this->is_part_of_swarm;
|
$server->settings->is_part_of_swarm = $this->is_part_of_swarm;
|
||||||
$server->settings->save();
|
$server->settings->save();
|
||||||
return redirect()->route('server.show', $server->uuid);
|
return redirect()->route('server.show', $server->uuid);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e);
|
return handleError($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Livewire\Server;
|
|
||||||
|
|
||||||
use App\Models\Server;
|
|
||||||
use Livewire\Component;
|
|
||||||
use Masmerise\Toaster\Toaster;
|
|
||||||
|
|
||||||
class PrivateKey extends Component
|
|
||||||
{
|
|
||||||
public Server $server;
|
|
||||||
public $privateKeys;
|
|
||||||
public $parameters;
|
|
||||||
|
|
||||||
public function setPrivateKey($private_key_id)
|
|
||||||
{
|
|
||||||
$this->server->update([
|
|
||||||
'private_key_id' => $private_key_id
|
|
||||||
]);
|
|
||||||
refresh_server_connection($this->server->privateKey);
|
|
||||||
$this->server->refresh();
|
|
||||||
$this->checkConnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function checkConnection()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
['uptime' => $uptime, 'dockerVersion' => $dockerVersion] = validateServer($this->server);
|
|
||||||
if ($uptime) {
|
|
||||||
Toaster::success('Server is reachable with this private key.');
|
|
||||||
}
|
|
||||||
if ($dockerVersion) {
|
|
||||||
Toaster::success('Server is usable for Coolify.');
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return general_error_handler(customErrorMessage: "Server is not reachable. Reason: {$e->getMessage()}", that: $this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function mount()
|
|
||||||
{
|
|
||||||
$this->parameters = get_route_parameters();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Http\Livewire\Server;
|
namespace App\Http\Livewire\Server;
|
||||||
|
|
||||||
use App\Actions\Proxy\CheckConfigurationSync;
|
use App\Actions\Proxy\CheckConfiguration;
|
||||||
use App\Actions\Proxy\SaveConfigurationSync;
|
use App\Actions\Proxy\SaveConfiguration;
|
||||||
use App\Enums\ProxyTypes;
|
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
@@ -12,15 +11,16 @@ class Proxy extends Component
|
|||||||
{
|
{
|
||||||
public Server $server;
|
public Server $server;
|
||||||
|
|
||||||
public ProxyTypes $selectedProxy = ProxyTypes::TRAEFIK_V2;
|
public ?string $selectedProxy = null;
|
||||||
public $proxy_settings = null;
|
public $proxy_settings = null;
|
||||||
public string|null $redirect_url = null;
|
public ?string $redirect_url = null;
|
||||||
|
|
||||||
protected $listeners = ['proxyStatusUpdated', 'saveConfiguration' => 'submit'];
|
protected $listeners = ['proxyStatusUpdated', 'saveConfiguration' => 'submit'];
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$this->redirect_url = $this->server->proxy->redirect_url;
|
$this->selectedProxy = data_get($this->server, 'proxy.type');
|
||||||
|
$this->redirect_url = data_get($this->server, 'proxy.redirect_url');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function proxyStatusUpdated()
|
public function proxyStatusUpdated()
|
||||||
@@ -35,44 +35,44 @@ class Proxy extends Component
|
|||||||
$this->emit('proxyStatusUpdated');
|
$this->emit('proxyStatusUpdated');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function select_proxy(ProxyTypes $proxy_type)
|
public function select_proxy($proxy_type)
|
||||||
{
|
{
|
||||||
$this->server->proxy->type = $proxy_type;
|
$this->server->proxy->type = $proxy_type;
|
||||||
$this->server->proxy->status = 'exited';
|
$this->server->proxy->status = 'exited';
|
||||||
$this->server->save();
|
$this->server->save();
|
||||||
|
$this->selectedProxy = $this->server->proxy->type;
|
||||||
$this->emit('proxyStatusUpdated');
|
$this->emit('proxyStatusUpdated');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function submit()
|
public function submit()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
resolve(SaveConfigurationSync::class)($this->server, $this->proxy_settings);
|
SaveConfiguration::run($this->server);
|
||||||
|
|
||||||
$this->server->proxy->redirect_url = $this->redirect_url;
|
$this->server->proxy->redirect_url = $this->redirect_url;
|
||||||
$this->server->save();
|
$this->server->save();
|
||||||
|
|
||||||
setup_default_redirect_404(redirect_url: $this->server->proxy->redirect_url, server: $this->server);
|
setup_default_redirect_404(redirect_url: $this->server->proxy->redirect_url, server: $this->server);
|
||||||
$this->emit('success', 'Proxy configuration saved.');
|
$this->emit('success', 'Proxy configuration saved.');
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e);
|
return handleError($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reset_proxy_configuration()
|
public function reset_proxy_configuration()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->proxy_settings = resolve(CheckConfigurationSync::class)($this->server, true);
|
$this->proxy_settings = CheckConfiguration::run($this->server, true);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e);
|
return handleError($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load_proxy_configuration()
|
public function loadProxyConfiguration()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->proxy_settings = resolve(CheckConfigurationSync::class)($this->server);
|
$this->proxy_settings = CheckConfiguration::run($this->server);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e);
|
return handleError($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Livewire\Server\Proxy;
|
namespace App\Http\Livewire\Server\Proxy;
|
||||||
|
|
||||||
|
use App\Actions\Proxy\SaveConfiguration;
|
||||||
use App\Actions\Proxy\StartProxy;
|
use App\Actions\Proxy\StartProxy;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
@@ -10,17 +11,27 @@ class Deploy extends Component
|
|||||||
{
|
{
|
||||||
public Server $server;
|
public Server $server;
|
||||||
public $proxy_settings = null;
|
public $proxy_settings = null;
|
||||||
|
protected $listeners = ['proxyStatusUpdated'];
|
||||||
|
|
||||||
public function start_proxy()
|
public function proxyStatusUpdated()
|
||||||
{
|
{
|
||||||
if (
|
$this->server->refresh();
|
||||||
$this->server->proxy->last_applied_settings &&
|
}
|
||||||
$this->server->proxy->last_saved_settings !== $this->server->proxy->last_applied_settings
|
public function startProxy()
|
||||||
) {
|
{
|
||||||
$this->emit('saveConfiguration', $this->server);
|
try {
|
||||||
|
if (
|
||||||
|
$this->server->proxy->last_applied_settings &&
|
||||||
|
$this->server->proxy->last_saved_settings !== $this->server->proxy->last_applied_settings
|
||||||
|
) {
|
||||||
|
SaveConfiguration::run($this->server);
|
||||||
|
}
|
||||||
|
|
||||||
|
$activity = StartProxy::run($this->server);
|
||||||
|
$this->emit('newMonitorActivity', $activity->id);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e);
|
||||||
}
|
}
|
||||||
$activity = resolve(StartProxy::class)($this->server);
|
|
||||||
$this->emit('newMonitorActivity', $activity->id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stop()
|
public function stop()
|
||||||
|
|||||||
16
app/Http/Livewire/Server/Proxy/Modal.php
Normal file
16
app/Http/Livewire/Server/Proxy/Modal.php
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Livewire\Server\Proxy;
|
||||||
|
|
||||||
|
use App\Models\Server;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Modal extends Component
|
||||||
|
{
|
||||||
|
public Server $server;
|
||||||
|
|
||||||
|
public function proxyStatusUpdated()
|
||||||
|
{
|
||||||
|
$this->emit('proxyStatusUpdated');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Livewire\Server\Proxy;
|
namespace App\Http\Livewire\Server\Proxy;
|
||||||
|
|
||||||
use App\Jobs\ProxyContainerStatusJob;
|
use App\Jobs\ContainerStatusJob;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
@@ -10,12 +10,25 @@ class Status extends Component
|
|||||||
{
|
{
|
||||||
public Server $server;
|
public Server $server;
|
||||||
|
|
||||||
public function get_status()
|
protected $listeners = ['proxyStatusUpdated'];
|
||||||
|
public function proxyStatusUpdated()
|
||||||
{
|
{
|
||||||
dispatch_sync(new ProxyContainerStatusJob(
|
|
||||||
server: $this->server
|
|
||||||
));
|
|
||||||
$this->server->refresh();
|
$this->server->refresh();
|
||||||
$this->emit('proxyStatusUpdated');
|
}
|
||||||
|
public function getProxyStatus()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if ($this->server->isFunctional()) {
|
||||||
|
dispatch_sync(new ContainerStatusJob($this->server));
|
||||||
|
$this->emit('proxyStatusUpdated');
|
||||||
|
}
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function getProxyStatusWithNoti()
|
||||||
|
{
|
||||||
|
$this->emit('success', 'Refreshed proxy status.');
|
||||||
|
$this->getProxyStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
28
app/Http/Livewire/Server/Show.php
Normal file
28
app/Http/Livewire/Server/Show.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Livewire\Server;
|
||||||
|
|
||||||
|
use App\Models\Server;
|
||||||
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Show extends Component
|
||||||
|
{
|
||||||
|
use AuthorizesRequests;
|
||||||
|
public ?Server $server = null;
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->server = Server::ownedByCurrentTeam(['name', 'description', 'ip', 'port', 'user', 'proxy'])->whereUuid(request()->server_uuid)->first();
|
||||||
|
if (is_null($this->server)) {
|
||||||
|
return redirect()->route('server.all');
|
||||||
|
}
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.server.show');
|
||||||
|
}
|
||||||
|
}
|
||||||
72
app/Http/Livewire/Server/ShowPrivateKey.php
Normal file
72
app/Http/Livewire/Server/ShowPrivateKey.php
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Livewire\Server;
|
||||||
|
|
||||||
|
use App\Models\Server;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class ShowPrivateKey extends Component
|
||||||
|
{
|
||||||
|
public Server $server;
|
||||||
|
public $privateKeys;
|
||||||
|
public $parameters;
|
||||||
|
|
||||||
|
public function setPrivateKey($newPrivateKeyId)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
refresh_server_connection($this->server->privateKey);
|
||||||
|
$oldPrivateKeyId = $this->server->private_key_id;
|
||||||
|
$this->server->update([
|
||||||
|
'private_key_id' => $newPrivateKeyId
|
||||||
|
]);
|
||||||
|
$this->server->refresh();
|
||||||
|
refresh_server_connection($this->server->privateKey);
|
||||||
|
$this->checkConnection();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->server->update([
|
||||||
|
'private_key_id' => $oldPrivateKeyId
|
||||||
|
]);
|
||||||
|
$this->server->refresh();
|
||||||
|
refresh_server_connection($this->server->privateKey);
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkConnection()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
['uptime' => $uptime, 'dockerVersion' => $dockerVersion] = validateServer($this->server, true);
|
||||||
|
if ($uptime) {
|
||||||
|
$this->server->settings->update([
|
||||||
|
'is_reachable' => true
|
||||||
|
]);
|
||||||
|
$this->emit('success', 'Server is reachable with this private key.');
|
||||||
|
} else {
|
||||||
|
$this->server->settings->update([
|
||||||
|
'is_reachable' => false,
|
||||||
|
'is_usable' => false
|
||||||
|
]);
|
||||||
|
$this->emit('error', 'Server is not reachable with this private key.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($dockerVersion) {
|
||||||
|
$this->server->settings->update([
|
||||||
|
'is_usable' => true
|
||||||
|
]);
|
||||||
|
$this->emit('success', 'Server is usable for Coolify.');
|
||||||
|
} else {
|
||||||
|
$this->server->settings->update([
|
||||||
|
'is_usable' => false
|
||||||
|
]);
|
||||||
|
$this->emit('error', 'Old (lower than 23) or no Docker version detected. Install Docker Engine on the General tab.');
|
||||||
|
}
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->parameters = get_route_parameters();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Livewire\Settings;
|
namespace App\Http\Livewire\Settings;
|
||||||
|
|
||||||
use App\Jobs\ProxyStartJob;
|
use App\Jobs\ContainerStatusJob;
|
||||||
use App\Models\InstanceSettings as ModelsInstanceSettings;
|
use App\Models\InstanceSettings as ModelsInstanceSettings;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
@@ -124,7 +124,7 @@ class Configuration extends Component
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
$this->save_configuration_to_disk($traefik_dynamic_conf, $file);
|
$this->save_configuration_to_disk($traefik_dynamic_conf, $file);
|
||||||
dispatch(new ProxyStartJob($this->server));
|
dispatch(new ContainerStatusJob($this->server));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ class Email extends Component
|
|||||||
'settings.smtp_timeout' => 'nullable',
|
'settings.smtp_timeout' => 'nullable',
|
||||||
'settings.smtp_from_address' => 'required|email',
|
'settings.smtp_from_address' => 'required|email',
|
||||||
'settings.smtp_from_name' => 'required',
|
'settings.smtp_from_name' => 'required',
|
||||||
|
'settings.resend_enabled' => 'nullable|boolean',
|
||||||
|
'settings.resend_api_key' => 'nullable'
|
||||||
|
|
||||||
];
|
];
|
||||||
protected $validationAttributes = [
|
protected $validationAttributes = [
|
||||||
'settings.smtp_from_address' => 'From Address',
|
'settings.smtp_from_address' => 'From Address',
|
||||||
@@ -30,48 +33,75 @@ class Email extends Component
|
|||||||
'settings.smtp_encryption' => 'Encryption',
|
'settings.smtp_encryption' => 'Encryption',
|
||||||
'settings.smtp_username' => 'Username',
|
'settings.smtp_username' => 'Username',
|
||||||
'settings.smtp_password' => 'Password',
|
'settings.smtp_password' => 'Password',
|
||||||
|
'settings.smtp_timeout' => 'Timeout',
|
||||||
|
'settings.resend_api_key' => 'Resend API Key'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$this->decrypt();
|
|
||||||
$this->emails = auth()->user()->email;
|
$this->emails = auth()->user()->email;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function decrypt()
|
public function submitFromFields() {
|
||||||
{
|
try {
|
||||||
if (data_get($this->settings, 'smtp_password')) {
|
$this->resetErrorBag();
|
||||||
try {
|
$this->validate([
|
||||||
$this->settings->smtp_password = decrypt($this->settings->smtp_password);
|
'settings.smtp_from_address' => 'required|email',
|
||||||
} catch (\Exception $e) {
|
'settings.smtp_from_name' => 'required',
|
||||||
}
|
]);
|
||||||
|
$this->settings->save();
|
||||||
|
$this->emit('success', 'Settings saved successfully.');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function submitResend() {
|
||||||
|
try {
|
||||||
|
$this->resetErrorBag();
|
||||||
|
$this->validate([
|
||||||
|
'settings.resend_api_key' => 'required'
|
||||||
|
]);
|
||||||
|
$this->settings->save();
|
||||||
|
$this->emit('success', 'Settings saved successfully.');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->settings->resend_enabled = false;
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function instantSaveResend() {
|
||||||
|
try {
|
||||||
|
$this->settings->smtp_enabled = false;
|
||||||
|
$this->submitResend();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function instantSave()
|
public function instantSave()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$this->settings->resend_enabled = false;
|
||||||
$this->submit();
|
$this->submit();
|
||||||
$this->emit('success', 'Settings saved successfully.');
|
} catch (\Throwable $e) {
|
||||||
} catch (\Exception $e) {
|
return handleError($e, $this);
|
||||||
$this->settings->smtp_enabled = false;
|
|
||||||
$this->validate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function submit()
|
public function submit()
|
||||||
{
|
{
|
||||||
$this->resetErrorBag();
|
try {
|
||||||
$this->validate();
|
$this->resetErrorBag();
|
||||||
if ($this->settings->smtp_password) {
|
$this->validate([
|
||||||
$this->settings->smtp_password = encrypt($this->settings->smtp_password);
|
'settings.smtp_host' => 'required',
|
||||||
} else {
|
'settings.smtp_port' => 'required|numeric',
|
||||||
$this->settings->smtp_password = null;
|
'settings.smtp_encryption' => 'nullable',
|
||||||
|
'settings.smtp_username' => 'nullable',
|
||||||
|
'settings.smtp_password' => 'nullable',
|
||||||
|
'settings.smtp_timeout' => 'nullable',
|
||||||
|
]);
|
||||||
|
$this->settings->save();
|
||||||
|
$this->emit('success', 'Settings saved successfully.');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->settings->save();
|
|
||||||
$this->emit('success', 'Transaction email settings updated successfully.');
|
|
||||||
$this->decrypt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendTestNotification()
|
public function sendTestNotification()
|
||||||
|
|||||||
@@ -37,9 +37,13 @@ class Change extends Component
|
|||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$this->webhook_endpoint = $this->ipv4;
|
if (isCloud() && !isDev()) {
|
||||||
|
$this->webhook_endpoint = config('app.url');
|
||||||
|
} else {
|
||||||
|
$this->webhook_endpoint = $this->ipv4;
|
||||||
|
$this->is_system_wide = $this->github_app->is_system_wide;
|
||||||
|
}
|
||||||
$this->parameters = get_route_parameters();
|
$this->parameters = get_route_parameters();
|
||||||
$this->is_system_wide = $this->github_app->is_system_wide;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function submit()
|
public function submit()
|
||||||
@@ -47,8 +51,8 @@ class Change extends Component
|
|||||||
try {
|
try {
|
||||||
$this->validate();
|
$this->validate();
|
||||||
$this->github_app->save();
|
$this->github_app->save();
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,8 +65,8 @@ class Change extends Component
|
|||||||
try {
|
try {
|
||||||
$this->github_app->delete();
|
$this->github_app->delete();
|
||||||
redirect()->route('source.all');
|
redirect()->route('source.all');
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,19 +32,25 @@ class Create extends Component
|
|||||||
"custom_port" => 'required|int',
|
"custom_port" => 'required|int',
|
||||||
"is_system_wide" => 'required|bool',
|
"is_system_wide" => 'required|bool',
|
||||||
]);
|
]);
|
||||||
$github_app = GithubApp::create([
|
$payload = [
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'organization' => $this->organization,
|
'organization' => $this->organization,
|
||||||
'api_url' => $this->api_url,
|
'api_url' => $this->api_url,
|
||||||
'html_url' => $this->html_url,
|
'html_url' => $this->html_url,
|
||||||
'custom_user' => $this->custom_user,
|
'custom_user' => $this->custom_user,
|
||||||
'custom_port' => $this->custom_port,
|
'custom_port' => $this->custom_port,
|
||||||
'is_system_wide' => $this->is_system_wide,
|
|
||||||
'team_id' => currentTeam()->id,
|
'team_id' => currentTeam()->id,
|
||||||
]);
|
];
|
||||||
|
if (isCloud()) {
|
||||||
|
$payload['is_system_wide'] = $this->is_system_wide;
|
||||||
|
}
|
||||||
|
$github_app = GithubApp::create($payload);
|
||||||
|
if (session('from')) {
|
||||||
|
session(['from' => session('from') + ['source_id' => $github_app->id]]);
|
||||||
|
}
|
||||||
redirect()->route('source.github.show', ['github_app_uuid' => $github_app->uuid]);
|
redirect()->route('source.github.show', ['github_app_uuid' => $github_app->uuid]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ class Actions extends Component
|
|||||||
$this->emit('success', 'Subscription cancelled successfully. Reloading in 5s.');
|
$this->emit('success', 'Subscription cancelled successfully. Reloading in 5s.');
|
||||||
$this->emit('reloadWindow', 5000);
|
$this->emit('reloadWindow', 5000);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler($e, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function resume()
|
public function resume()
|
||||||
@@ -65,8 +65,8 @@ class Actions extends Component
|
|||||||
$this->emit('success', 'Subscription resumed successfully. Reloading in 5s.');
|
$this->emit('success', 'Subscription resumed successfully. Reloading in 5s.');
|
||||||
$this->emit('reloadWindow', 5000);
|
$this->emit('reloadWindow', 5000);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler($e, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function stripeCustomerPortal() {
|
public function stripeCustomerPortal() {
|
||||||
|
|||||||
@@ -8,8 +8,13 @@ use Stripe\Checkout\Session;
|
|||||||
|
|
||||||
class PricingPlans extends Component
|
class PricingPlans extends Component
|
||||||
{
|
{
|
||||||
|
public bool $isTrial = false;
|
||||||
|
public function mount() {
|
||||||
|
$this->isTrial = !data_get(currentTeam(),'subscription.stripe_trial_already_ended');
|
||||||
|
}
|
||||||
public function subscribeStripe($type)
|
public function subscribeStripe($type)
|
||||||
{
|
{
|
||||||
|
$team = currentTeam();
|
||||||
Stripe::setApiKey(config('subscription.stripe_api_key'));
|
Stripe::setApiKey(config('subscription.stripe_api_key'));
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'basic-monthly':
|
case 'basic-monthly':
|
||||||
@@ -39,6 +44,7 @@ class PricingPlans extends Component
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$payload = [
|
$payload = [
|
||||||
|
'billing_address_collection' => 'required',
|
||||||
'client_reference_id' => auth()->user()->id . ':' . currentTeam()->id,
|
'client_reference_id' => auth()->user()->id . ':' . currentTeam()->id,
|
||||||
'line_items' => [[
|
'line_items' => [[
|
||||||
'price' => $priceId,
|
'price' => $priceId,
|
||||||
@@ -47,10 +53,26 @@ class PricingPlans extends Component
|
|||||||
'tax_id_collection' => [
|
'tax_id_collection' => [
|
||||||
'enabled' => true,
|
'enabled' => true,
|
||||||
],
|
],
|
||||||
|
'automatic_tax' => [
|
||||||
|
'enabled' => true,
|
||||||
|
],
|
||||||
|
|
||||||
'mode' => 'subscription',
|
'mode' => 'subscription',
|
||||||
'success_url' => route('subscription.success'),
|
'success_url' => route('dashboard', ['success' => true]),
|
||||||
'cancel_url' => route('subscription.show',['cancelled' => true]),
|
'cancel_url' => route('subscription.index', ['cancelled' => true]),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (!data_get($team,'subscription.stripe_trial_already_ended')) {
|
||||||
|
$payload['subscription_data'] = [
|
||||||
|
'trial_period_days' => config('constants.limits.trial_period'),
|
||||||
|
'trial_settings' => [
|
||||||
|
'end_behavior' => [
|
||||||
|
'missing_payment_method' => 'cancel',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
$payload['payment_method_collection'] = 'if_required';
|
||||||
|
}
|
||||||
$customer = currentTeam()->subscription?->stripe_customer_id ?? null;
|
$customer = currentTeam()->subscription?->stripe_customer_id ?? null;
|
||||||
if ($customer) {
|
if ($customer) {
|
||||||
$payload['customer'] = $customer;
|
$payload['customer'] = $customer;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class SwitchTeam extends Component
|
|||||||
if (!$team_to_switch_to) {
|
if (!$team_to_switch_to) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
session(['currentTeam' => $team_to_switch_to]);
|
refreshSession($team_to_switch_to);
|
||||||
return redirect(request()->header('Referer'));
|
return redirect(request()->header('Referer'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ class Create extends Component
|
|||||||
]);
|
]);
|
||||||
auth()->user()->teams()->attach($team, ['role' => 'admin']);
|
auth()->user()->teams()->attach($team, ['role' => 'admin']);
|
||||||
refreshSession();
|
refreshSession();
|
||||||
return redirect()->route('team.show');
|
return redirect()->route('team.index');
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler($th, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ class Delete extends Component
|
|||||||
$currentTeam = currentTeam();
|
$currentTeam = currentTeam();
|
||||||
$currentTeam->delete();
|
$currentTeam->delete();
|
||||||
|
|
||||||
$team = auth()->user()->teams()->first();
|
|
||||||
$currentTeam->members->each(function ($user) use ($currentTeam) {
|
$currentTeam->members->each(function ($user) use ($currentTeam) {
|
||||||
if ($user->id === auth()->user()->id) {
|
if ($user->id === auth()->user()->id) {
|
||||||
return;
|
return;
|
||||||
@@ -25,6 +24,6 @@ class Delete extends Component
|
|||||||
});
|
});
|
||||||
|
|
||||||
refreshSession();
|
refreshSession();
|
||||||
return redirect()->route('team.show');
|
return redirect()->route('team.index');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,8 @@ class Form extends Component
|
|||||||
try {
|
try {
|
||||||
$this->team->save();
|
$this->team->save();
|
||||||
refreshSession();
|
refreshSession();
|
||||||
$this->emit('reloadWindow');
|
} catch (\Throwable $e) {
|
||||||
} catch (\Throwable $th) {
|
return handleError($e, $this);
|
||||||
return general_error_handler($th, $this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class Invitations extends Component
|
|||||||
{
|
{
|
||||||
TeamInvitation::find($invitation_id)->delete();
|
TeamInvitation::find($invitation_id)->delete();
|
||||||
$this->refreshInvitations();
|
$this->refreshInvitations();
|
||||||
|
$this->emit('success', 'Invitation revoked.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function refreshInvitations()
|
public function refreshInvitations()
|
||||||
|
|||||||
@@ -4,9 +4,13 @@ namespace App\Http\Livewire\Team;
|
|||||||
|
|
||||||
use App\Models\TeamInvitation;
|
use App\Models\TeamInvitation;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Notifications\TransactionalEmails\InvitationLink;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use Visus\Cuid2\Cuid2;
|
use Visus\Cuid2\Cuid2;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class InviteLink extends Component
|
class InviteLink extends Component
|
||||||
{
|
{
|
||||||
@@ -20,64 +24,74 @@ class InviteLink extends Component
|
|||||||
|
|
||||||
public function viaEmail()
|
public function viaEmail()
|
||||||
{
|
{
|
||||||
$this->generate_invite_link(isEmail: true);
|
$this->generate_invite_link(sendEmail: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generate_invite_link(bool $isEmail = false)
|
public function viaLink()
|
||||||
|
{
|
||||||
|
$this->generate_invite_link(sendEmail: false);
|
||||||
|
}
|
||||||
|
private function generate_invite_link(bool $sendEmail = false)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$uuid = new Cuid2(32);
|
|
||||||
$link = url('/') . config('constants.invitation.link.base_url') . $uuid;
|
|
||||||
|
|
||||||
$user = User::whereEmail($this->email);
|
|
||||||
|
|
||||||
if (!$user->exists()) {
|
|
||||||
return general_error_handler(that: $this, customErrorMessage: "$this->email must be registered first (or activate transactional emails to invite via email).");
|
|
||||||
}
|
|
||||||
|
|
||||||
$member_emails = currentTeam()->members()->get()->pluck('email');
|
$member_emails = currentTeam()->members()->get()->pluck('email');
|
||||||
if ($member_emails->contains($this->email)) {
|
if ($member_emails->contains($this->email)) {
|
||||||
return general_error_handler(that: $this, customErrorMessage: "$this->email is already a member of " . currentTeam()->name . ".");
|
return handleError(livewire: $this, customErrorMessage: "$this->email is already a member of " . currentTeam()->name . ".");
|
||||||
}
|
}
|
||||||
|
$uuid = new Cuid2(32);
|
||||||
|
$link = url('/') . config('constants.invitation.link.base_url') . $uuid;
|
||||||
|
$user = User::whereEmail($this->email)->first();
|
||||||
|
|
||||||
$invitation = TeamInvitation::whereEmail($this->email);
|
if (is_null($user)) {
|
||||||
|
$password = Str::password();
|
||||||
if ($invitation->exists()) {
|
$user = User::create([
|
||||||
$created_at = $invitation->first()->created_at;
|
'name' => Str::of($this->email)->before('@'),
|
||||||
$diff = $created_at->diffInMinutes(now());
|
'email' => $this->email,
|
||||||
if ($diff <= config('constants.invitation.link.expiration')) {
|
'password' => Hash::make($password),
|
||||||
return general_error_handler(that: $this, customErrorMessage: "Invitation already sent to $this->email and waiting for action.");
|
'force_password_reset' => true,
|
||||||
|
]);
|
||||||
|
$token = Crypt::encryptString("{$user->email}@@@$password");
|
||||||
|
$link = route('auth.link', ['token' => $token]);
|
||||||
|
}
|
||||||
|
$invitation = TeamInvitation::whereEmail($this->email)->first();
|
||||||
|
if (!is_null($invitation)) {
|
||||||
|
$invitationValid = $invitation->isValid();
|
||||||
|
if ($invitationValid) {
|
||||||
|
return handleError(livewire: $this, customErrorMessage: "Pending invitation already exists for $this->email.");
|
||||||
} else {
|
} else {
|
||||||
$invitation->delete();
|
$invitation->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TeamInvitation::firstOrCreate([
|
$invitation = TeamInvitation::firstOrCreate([
|
||||||
'team_id' => currentTeam()->id,
|
'team_id' => currentTeam()->id,
|
||||||
'uuid' => $uuid,
|
'uuid' => $uuid,
|
||||||
'email' => $this->email,
|
'email' => $this->email,
|
||||||
'role' => $this->role,
|
'role' => $this->role,
|
||||||
'link' => $link,
|
'link' => $link,
|
||||||
'via' => $isEmail ? 'email' : 'link',
|
'via' => $sendEmail ? 'email' : 'link',
|
||||||
]);
|
]);
|
||||||
if ($isEmail) {
|
if ($sendEmail) {
|
||||||
$user->first()->notify(new InvitationLink);
|
$mail = new MailMessage();
|
||||||
|
$mail->view('emails.invitation-link', [
|
||||||
|
'team' => currentTeam()->name,
|
||||||
|
'invitation_link' => $link,
|
||||||
|
]);
|
||||||
|
$mail->subject('You have been invited to ' . currentTeam()->name . ' on ' . config('app.name') . '.');
|
||||||
|
send_user_an_email($mail, $this->email);
|
||||||
$this->emit('success', 'Invitation sent via email successfully.');
|
$this->emit('success', 'Invitation sent via email successfully.');
|
||||||
|
$this->emit('refreshInvitations');
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
$this->emit('success', 'Invitation link generated.');
|
$this->emit('success', 'Invitation link generated.');
|
||||||
|
$this->emit('refreshInvitations');
|
||||||
}
|
}
|
||||||
$this->emit('refreshInvitations');
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$error_message = $e->getMessage();
|
$error_message = $e->getMessage();
|
||||||
if ($e->getCode() === '23505') {
|
if ($e->getCode() === '23505') {
|
||||||
$error_message = 'Invitation already sent.';
|
$error_message = 'Invitation already sent.';
|
||||||
}
|
}
|
||||||
return general_error_handler(err: $e, that: $this, customErrorMessage: $error_message);
|
return handleError(error: $e, livewire: $this, customErrorMessage: $error_message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function viaLink()
|
|
||||||
{
|
|
||||||
$this->generate_invite_link();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Livewire\Team;
|
namespace App\Http\Livewire\Team;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class Member extends Component
|
class Member extends Component
|
||||||
@@ -24,6 +25,10 @@ class Member extends Component
|
|||||||
public function remove()
|
public function remove()
|
||||||
{
|
{
|
||||||
$this->member->teams()->detach(currentTeam());
|
$this->member->teams()->detach(currentTeam());
|
||||||
|
Cache::forget("team:{$this->member->id}");
|
||||||
|
Cache::remember('team:' . $this->member->id, 3600, function() {
|
||||||
|
return $this->member->teams()->first();
|
||||||
|
});
|
||||||
$this->emit('reloadWindow');
|
$this->emit('reloadWindow');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ class Create extends Component
|
|||||||
$this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');
|
$this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');
|
||||||
$this->storage->save();
|
$this->storage->save();
|
||||||
return redirect()->route('team.storages.show', $this->storage->uuid);
|
return redirect()->route('team.storages.show', $this->storage->uuid);
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler($th, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,8 +77,8 @@ class Create extends Component
|
|||||||
try {
|
try {
|
||||||
$this->storage->testConnection();
|
$this->storage->testConnection();
|
||||||
return $this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');
|
return $this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler($th, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ class Form extends Component
|
|||||||
try {
|
try {
|
||||||
$this->storage->testConnection();
|
$this->storage->testConnection();
|
||||||
return $this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');
|
return $this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler($th, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,8 +42,8 @@ class Form extends Component
|
|||||||
try {
|
try {
|
||||||
$this->storage->delete();
|
$this->storage->delete();
|
||||||
return redirect()->route('team.storages.all');
|
return redirect()->route('team.storages.all');
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler($th, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,8 +55,8 @@ class Form extends Component
|
|||||||
$this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');
|
$this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');
|
||||||
$this->storage->save();
|
$this->storage->save();
|
||||||
$this->emit('success', 'Storage settings saved.');
|
$this->emit('success', 'Storage settings saved.');
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler($th, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ class Upgrade extends Component
|
|||||||
}
|
}
|
||||||
$this->showProgress = true;
|
$this->showProgress = true;
|
||||||
resolve(UpdateCoolify::class)(true);
|
resolve(UpdateCoolify::class)(true);
|
||||||
Toaster::success("Upgrading to {$this->latestVersion} version...");
|
$this->emit('success', "Upgrading to {$this->latestVersion} version...");
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Livewire;
|
namespace App\Http\Livewire\Waitlist;
|
||||||
|
|
||||||
use App\Jobs\SendConfirmationForWaitlistJob;
|
use App\Jobs\SendConfirmationForWaitlistJob;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Waitlist as ModelsWaitlist;
|
use App\Models\Waitlist;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class Waitlist extends Component
|
class Index extends Component
|
||||||
{
|
{
|
||||||
public string $email;
|
public string $email;
|
||||||
public int $waiting_in_line = 0;
|
public int $users = 0;
|
||||||
|
public int $waitingInLine = 0;
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'email' => 'required|email',
|
'email' => 'required|email',
|
||||||
];
|
];
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.waitlist.index')->layout('layouts.simple');
|
||||||
|
}
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
|
$this->waitingInLine = Waitlist::whereVerified(true)->count();
|
||||||
|
$this->users = User::count();
|
||||||
if (isDev()) {
|
if (isDev()) {
|
||||||
$this->email = 'waitlist@example.com';
|
$this->email = 'waitlist@example.com';
|
||||||
}
|
}
|
||||||
@@ -29,7 +37,7 @@ class Waitlist extends Component
|
|||||||
if ($already_registered) {
|
if ($already_registered) {
|
||||||
throw new \Exception('You are already on the waitlist or registered. <br>Please check your email to verify your email address or contact support.');
|
throw new \Exception('You are already on the waitlist or registered. <br>Please check your email to verify your email address or contact support.');
|
||||||
}
|
}
|
||||||
$found = ModelsWaitlist::where('email', $this->email)->first();
|
$found = Waitlist::where('email', $this->email)->first();
|
||||||
if ($found) {
|
if ($found) {
|
||||||
if (!$found->verified) {
|
if (!$found->verified) {
|
||||||
$this->emit('error', 'You are already on the waitlist. <br>Please check your email to verify your email address.');
|
$this->emit('error', 'You are already on the waitlist. <br>Please check your email to verify your email address.');
|
||||||
@@ -38,15 +46,15 @@ class Waitlist extends Component
|
|||||||
$this->emit('error', 'You are already on the waitlist. <br>You will be notified when your turn comes. <br>Thank you.');
|
$this->emit('error', 'You are already on the waitlist. <br>You will be notified when your turn comes. <br>Thank you.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$waitlist = ModelsWaitlist::create([
|
$waitlist = Waitlist::create([
|
||||||
'email' => $this->email,
|
'email' => Str::lower($this->email),
|
||||||
'type' => 'registration',
|
'type' => 'registration',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->emit('success', 'Check your email to verify your email address.');
|
$this->emit('success', 'Check your email to verify your email address.');
|
||||||
dispatch(new SendConfirmationForWaitlistJob($this->email, $waitlist->uuid));
|
dispatch(new SendConfirmationForWaitlistJob($this->email, $waitlist->uuid));
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler(err: $e, that: $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,12 @@ class CheckForcePasswordReset
|
|||||||
public function handle(Request $request, Closure $next): Response
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
if (auth()->user()) {
|
if (auth()->user()) {
|
||||||
|
if ($request->path() === 'auth/link') {
|
||||||
|
auth()->logout();
|
||||||
|
request()->session()->invalidate();
|
||||||
|
request()->session()->regenerateToken();
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
$force_password_reset = auth()->user()->force_password_reset;
|
$force_password_reset = auth()->user()->force_password_reset;
|
||||||
if ($force_password_reset) {
|
if ($force_password_reset) {
|
||||||
if ($request->routeIs('auth.force-password-reset') || $request->path() === 'livewire/message/force-password-reset') {
|
if ($request->routeIs('auth.force-password-reset') || $request->path() === 'livewire/message/force-password-reset') {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Http\Middleware;
|
|||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class IsBoardingFlow
|
class IsBoardingFlow
|
||||||
{
|
{
|
||||||
@@ -15,8 +16,11 @@ class IsBoardingFlow
|
|||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next): Response
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
// ray('IsBoardingFlow Middleware');
|
// ray()->showQueries()->color('orange');
|
||||||
if (showBoarding() && !in_array($request->path(), allowedPathsForBoardingAccounts())) {
|
if (showBoarding() && !in_array($request->path(), allowedPathsForBoardingAccounts())) {
|
||||||
|
if (Str::startsWith($request->path(), 'invitations')) {
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
return redirect('boarding');
|
return redirect('boarding');
|
||||||
}
|
}
|
||||||
return $next($request);
|
return $next($request);
|
||||||
|
|||||||
@@ -5,15 +5,16 @@ namespace App\Http\Middleware;
|
|||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class SubscriptionValid
|
class IsSubscriptionValid
|
||||||
{
|
{
|
||||||
public function handle(Request $request, Closure $next): Response
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
if (isInstanceAdmin()) {
|
if (isInstanceAdmin()) {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
if (!auth()->user() || !is_cloud()) {
|
if (!auth()->user() || !isCloud()) {
|
||||||
if ($request->path() === 'subscription') {
|
if ($request->path() === 'subscription') {
|
||||||
return redirect('/');
|
return redirect('/');
|
||||||
} else {
|
} else {
|
||||||
@@ -31,6 +32,9 @@ class SubscriptionValid
|
|||||||
if (!isSubscriptionActive() && !isSubscriptionOnGracePeriod()) {
|
if (!isSubscriptionActive() && !isSubscriptionOnGracePeriod()) {
|
||||||
// ray('SubscriptionValid Middleware');
|
// ray('SubscriptionValid Middleware');
|
||||||
if (!in_array($request->path(), allowedPathsForUnsubscribedAccounts())) {
|
if (!in_array($request->path(), allowedPathsForUnsubscribedAccounts())) {
|
||||||
|
if (Str::startsWith($request->path(), 'invitations')) {
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
return redirect('subscription');
|
return redirect('subscription');
|
||||||
} else {
|
} else {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Jobs;
|
|
||||||
|
|
||||||
use App\Models\Application;
|
|
||||||
use App\Models\ApplicationPreview;
|
|
||||||
use App\Notifications\Application\StatusChanged;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
|
|
||||||
class ApplicationContainerStatusJob implements ShouldQueue, ShouldBeUnique
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public string $containerName;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
public Application $application,
|
|
||||||
public int $pullRequestId = 0)
|
|
||||||
{
|
|
||||||
$this->containerName = generateApplicationContainerName($application->uuid, $pullRequestId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function uniqueId(): string
|
|
||||||
{
|
|
||||||
return $this->containerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle(): void
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$status = getApplicationContainerStatus(application: $this->application);
|
|
||||||
if ($this->application->status === 'running' && $status !== 'running') {
|
|
||||||
// $this->application->environment->project->team->notify(new StatusChanged($this->application));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->pullRequestId !== 0) {
|
|
||||||
$preview = ApplicationPreview::findPreviewByApplicationAndPullId($this->application->id, $this->pullRequestId);
|
|
||||||
$preview->status = $status;
|
|
||||||
$preview->save();
|
|
||||||
} else {
|
|
||||||
$this->application->status = $status;
|
|
||||||
$this->application->save();
|
|
||||||
}
|
|
||||||
} catch (\Exception $th) {
|
|
||||||
ray($th->getMessage());
|
|
||||||
throw $th;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,6 +17,7 @@ use App\Notifications\Application\DeploymentSuccess;
|
|||||||
use App\Traits\ExecuteRemoteCommand;
|
use App\Traits\ExecuteRemoteCommand;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
@@ -28,7 +29,7 @@ use Symfony\Component\Yaml\Yaml;
|
|||||||
use Throwable;
|
use Throwable;
|
||||||
use Visus\Cuid2\Cuid2;
|
use Visus\Cuid2\Cuid2;
|
||||||
|
|
||||||
class ApplicationDeploymentJob implements ShouldQueue
|
class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, ExecuteRemoteCommand;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, ExecuteRemoteCommand;
|
||||||
|
|
||||||
@@ -46,7 +47,6 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
private GithubApp|GitlabApp $source;
|
private GithubApp|GitlabApp $source;
|
||||||
private StandaloneDocker|SwarmDocker $destination;
|
private StandaloneDocker|SwarmDocker $destination;
|
||||||
private Server $server;
|
private Server $server;
|
||||||
private string $private_key_location;
|
|
||||||
private ApplicationPreview|null $preview = null;
|
private ApplicationPreview|null $preview = null;
|
||||||
|
|
||||||
private string $container_name;
|
private string $container_name;
|
||||||
@@ -65,6 +65,7 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
private $log_model;
|
private $log_model;
|
||||||
private Collection $saved_outputs;
|
private Collection $saved_outputs;
|
||||||
|
|
||||||
|
public $tries = 1;
|
||||||
public function __construct(int $application_deployment_queue_id)
|
public function __construct(int $application_deployment_queue_id)
|
||||||
{
|
{
|
||||||
ray()->clearScreen();
|
ray()->clearScreen();
|
||||||
@@ -88,7 +89,7 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
$this->is_debug_enabled = $this->application->settings->is_debug_enabled;
|
$this->is_debug_enabled = $this->application->settings->is_debug_enabled;
|
||||||
|
|
||||||
$this->container_name = generateApplicationContainerName($this->application->uuid, $this->pull_request_id);
|
$this->container_name = generateApplicationContainerName($this->application->uuid, $this->pull_request_id);
|
||||||
$this->private_key_location = save_private_key_for_server($this->server);
|
savePrivateKeyToFs($this->server);
|
||||||
$this->saved_outputs = collect();
|
$this->saved_outputs = collect();
|
||||||
|
|
||||||
// Set preview fqdn
|
// Set preview fqdn
|
||||||
@@ -118,6 +119,9 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
if ($containers->count() > 0) {
|
if ($containers->count() > 0) {
|
||||||
$this->currently_running_container_name = data_get($containers[0], 'Names');
|
$this->currently_running_container_name = data_get($containers[0], 'Names');
|
||||||
}
|
}
|
||||||
|
if ($this->pull_request_id !== 0 && $this->pull_request_id !== null) {
|
||||||
|
$this->currently_running_container_name = $this->container_name;
|
||||||
|
}
|
||||||
$this->application_deployment_queue->update([
|
$this->application_deployment_queue->update([
|
||||||
'status' => ApplicationDeploymentStatus::IN_PROGRESS->value,
|
'status' => ApplicationDeploymentStatus::IN_PROGRESS->value,
|
||||||
]);
|
]);
|
||||||
@@ -131,7 +135,9 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
$this->deploy();
|
$this->deploy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->application->fqdn) dispatch(new ProxyStartJob($this->server));
|
if ($this->server->isProxyShouldRun()) {
|
||||||
|
dispatch(new ContainerStatusJob($this->server));
|
||||||
|
}
|
||||||
$this->next(ApplicationDeploymentStatus::FINISHED->value);
|
$this->next(ApplicationDeploymentStatus::FINISHED->value);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
ray($e);
|
ray($e);
|
||||||
@@ -171,11 +177,11 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
$this->prepare_builder_image();
|
$this->prepare_builder_image();
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
$this->execute_in_builder("echo '$dockerfile_base64' | base64 -d > $this->workdir/Dockerfile")
|
executeInDocker($this->deployment_uuid, "echo '$dockerfile_base64' | base64 -d > $this->workdir/Dockerfile")
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
$this->build_image_name = "{$this->application->git_repository}:build";
|
$this->build_image_name = Str::lower("{$this->application->git_repository}:build");
|
||||||
$this->production_image_name = "{$this->application->uuid}:latest";
|
$this->production_image_name = Str::lower("{$this->application->uuid}:latest");
|
||||||
ray('Build Image Name: ' . $this->build_image_name . ' & Production Image Name: ' . $this->production_image_name)->green();
|
ray('Build Image Name: ' . $this->build_image_name . ' & Production Image Name: ' . $this->production_image_name)->green();
|
||||||
$this->generate_compose_file();
|
$this->generate_compose_file();
|
||||||
$this->generate_build_env_variables();
|
$this->generate_build_env_variables();
|
||||||
@@ -199,8 +205,8 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
$tag = $tag->substr(0, 128);
|
$tag = $tag->substr(0, 128);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->build_image_name = "{$this->application->git_repository}:{$tag}-build";
|
$this->build_image_name = Str::lower("{$this->application->git_repository}:{$tag}-build");
|
||||||
$this->production_image_name = "{$this->application->uuid}:{$tag}";
|
$this->production_image_name = Str::lower("{$this->application->uuid}:{$tag}");
|
||||||
ray('Build Image Name: ' . $this->build_image_name . ' & Production Image Name: ' . $this->production_image_name)->green();
|
ray('Build Image Name: ' . $this->build_image_name . ' & Production Image Name: ' . $this->production_image_name)->green();
|
||||||
|
|
||||||
if (!$this->force_rebuild) {
|
if (!$this->force_rebuild) {
|
||||||
@@ -235,7 +241,7 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
}
|
}
|
||||||
private function health_check()
|
private function health_check()
|
||||||
{
|
{
|
||||||
ray('New container name: ',$this->container_name);
|
ray('New container name: ', $this->container_name);
|
||||||
if ($this->container_name) {
|
if ($this->container_name) {
|
||||||
$counter = 0;
|
$counter = 0;
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
@@ -257,7 +263,7 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
);
|
);
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
"echo 'New application version health check status: {$this->saved_outputs->get('health_check')}'"
|
"echo 'New version health check status: {$this->saved_outputs->get('health_check')}'"
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
if (Str::of($this->saved_outputs->get('health_check'))->contains('healthy')) {
|
if (Str::of($this->saved_outputs->get('health_check'))->contains('healthy')) {
|
||||||
@@ -266,6 +272,7 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
"echo 'Rolling update completed.'"
|
"echo 'Rolling update completed.'"
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
$this->application->update(['status' => 'running']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$counter++;
|
$counter++;
|
||||||
@@ -275,8 +282,8 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
}
|
}
|
||||||
private function deploy_pull_request()
|
private function deploy_pull_request()
|
||||||
{
|
{
|
||||||
$this->build_image_name = "{$this->application->uuid}:pr-{$this->pull_request_id}-build";
|
$this->build_image_name = Str::lower("{$this->application->uuid}:pr-{$this->pull_request_id}-build");
|
||||||
$this->production_image_name = "{$this->application->uuid}:pr-{$this->pull_request_id}";
|
$this->production_image_name = Str::lower("{$this->application->uuid}:pr-{$this->pull_request_id}");
|
||||||
ray('Build Image Name: ' . $this->build_image_name . ' & Production Image Name: ' . $this->production_image_name)->green();
|
ray('Build Image Name: ' . $this->build_image_name . ' & Production Image Name: ' . $this->production_image_name)->green();
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
"echo 'Starting pull request (#{$this->pull_request_id}) deployment of {$this->application->git_repository}:{$this->application->git_branch}.'",
|
"echo 'Starting pull request (#{$this->pull_request_id}) deployment of {$this->application->git_repository}:{$this->application->git_branch}.'",
|
||||||
@@ -292,30 +299,37 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
// $this->generate_build_env_variables();
|
// $this->generate_build_env_variables();
|
||||||
// $this->add_build_env_variables_to_dockerfile();
|
// $this->add_build_env_variables_to_dockerfile();
|
||||||
$this->build_image();
|
$this->build_image();
|
||||||
$this->rolling_update();
|
$this->stop_running_container();
|
||||||
|
$this->execute_remote_command(
|
||||||
|
["echo -n 'Starting preview deployment.'"],
|
||||||
|
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} up -d >/dev/null"), "hidden" => true],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function prepare_builder_image()
|
private function prepare_builder_image()
|
||||||
{
|
{
|
||||||
|
$pull = "--pull=always";
|
||||||
|
if (isDev()) {
|
||||||
|
$pull = "--pull=never";
|
||||||
|
}
|
||||||
|
$helperImage = config('coolify.helper_image');
|
||||||
|
$runCommand = "docker run {$pull} -d --network {$this->destination->network} -v /:/host --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}";
|
||||||
|
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
"echo -n 'Pulling latest version of the builder image (ghcr.io/coollabsio/coolify-helper).'",
|
"echo -n 'Pulling helper image from $helperImage.'",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"docker run --pull=always -d --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/coollabsio/coolify-helper",
|
$runCommand,
|
||||||
"hidden" => true,
|
"hidden" => true,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"command" => $this->execute_in_builder("mkdir -p {$this->workdir}")
|
"command" => executeInDocker($this->deployment_uuid, "mkdir -p {$this->workdir}")
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function execute_in_builder(string $command)
|
|
||||||
{
|
|
||||||
return "docker exec {$this->deployment_uuid} bash -c '{$command}'";
|
|
||||||
// return "docker exec {$this->deployment_uuid} bash -c '{$command} |& tee -a /proc/1/fd/1; [ \$PIPESTATUS -eq 0 ] || exit \$PIPESTATUS'";
|
|
||||||
}
|
|
||||||
|
|
||||||
private function clone_repository()
|
private function clone_repository()
|
||||||
{
|
{
|
||||||
@@ -327,7 +341,7 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
$this->importing_git_repository()
|
$this->importing_git_repository()
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
$this->execute_in_builder("cd {$this->workdir} && git rev-parse HEAD"),
|
executeInDocker($this->deployment_uuid, "cd {$this->workdir} && git rev-parse HEAD"),
|
||||||
"hidden" => true,
|
"hidden" => true,
|
||||||
"save" => "git_commit_sha"
|
"save" => "git_commit_sha"
|
||||||
],
|
],
|
||||||
@@ -354,13 +368,13 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
$git_clone_command = "{$git_clone_command} {$this->source->html_url}/{$this->application->git_repository} {$this->workdir}";
|
$git_clone_command = "{$git_clone_command} {$this->source->html_url}/{$this->application->git_repository} {$this->workdir}";
|
||||||
$git_clone_command = $this->set_git_import_settings($git_clone_command);
|
$git_clone_command = $this->set_git_import_settings($git_clone_command);
|
||||||
|
|
||||||
$commands->push($this->execute_in_builder($git_clone_command));
|
$commands->push(executeInDocker($this->deployment_uuid, $git_clone_command));
|
||||||
} else {
|
} else {
|
||||||
$github_access_token = generate_github_installation_token($this->source);
|
$github_access_token = generate_github_installation_token($this->source);
|
||||||
$commands->push($this->execute_in_builder("git clone -q -b {$this->application->git_branch} $source_html_url_scheme://x-access-token:$github_access_token@$source_html_url_host/{$this->application->git_repository}.git {$this->workdir}"));
|
$commands->push(executeInDocker($this->deployment_uuid, "git clone -q -b {$this->application->git_branch} $source_html_url_scheme://x-access-token:$github_access_token@$source_html_url_host/{$this->application->git_repository}.git {$this->workdir}"));
|
||||||
}
|
}
|
||||||
if ($this->pull_request_id !== 0) {
|
if ($this->pull_request_id !== 0) {
|
||||||
$commands->push($this->execute_in_builder("cd {$this->workdir} && git fetch origin pull/{$this->pull_request_id}/head:$pr_branch_name && git checkout $pr_branch_name"));
|
$commands->push(executeInDocker($this->deployment_uuid, "cd {$this->workdir} && git fetch origin pull/{$this->pull_request_id}/head:$pr_branch_name && git checkout $pr_branch_name"));
|
||||||
}
|
}
|
||||||
return $commands->implode(' && ');
|
return $commands->implode(' && ');
|
||||||
}
|
}
|
||||||
@@ -370,10 +384,10 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
$git_clone_command = "GIT_SSH_COMMAND=\"ssh -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" {$git_clone_command} {$this->application->git_full_url} {$this->workdir}";
|
$git_clone_command = "GIT_SSH_COMMAND=\"ssh -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" {$git_clone_command} {$this->application->git_full_url} {$this->workdir}";
|
||||||
$git_clone_command = $this->set_git_import_settings($git_clone_command);
|
$git_clone_command = $this->set_git_import_settings($git_clone_command);
|
||||||
$commands = collect([
|
$commands = collect([
|
||||||
$this->execute_in_builder("mkdir -p /root/.ssh"),
|
executeInDocker($this->deployment_uuid, "mkdir -p /root/.ssh"),
|
||||||
$this->execute_in_builder("echo '{$private_key}' | base64 -d > /root/.ssh/id_rsa"),
|
executeInDocker($this->deployment_uuid, "echo '{$private_key}' | base64 -d > /root/.ssh/id_rsa"),
|
||||||
$this->execute_in_builder("chmod 600 /root/.ssh/id_rsa"),
|
executeInDocker($this->deployment_uuid, "chmod 600 /root/.ssh/id_rsa"),
|
||||||
$this->execute_in_builder($git_clone_command)
|
executeInDocker($this->deployment_uuid, $git_clone_command)
|
||||||
]);
|
]);
|
||||||
return $commands->implode(' && ');
|
return $commands->implode(' && ');
|
||||||
}
|
}
|
||||||
@@ -396,7 +410,7 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
private function cleanup_git()
|
private function cleanup_git()
|
||||||
{
|
{
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[$this->execute_in_builder("rm -fr {$this->workdir}/.git")],
|
[executeInDocker($this->deployment_uuid, "rm -fr {$this->workdir}/.git")],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,8 +421,8 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
"echo -n 'Generating nixpacks configuration.'",
|
"echo -n 'Generating nixpacks configuration.'",
|
||||||
],
|
],
|
||||||
[$this->nixpacks_build_cmd()],
|
[$this->nixpacks_build_cmd()],
|
||||||
[$this->execute_in_builder("cp {$this->workdir}/.nixpacks/Dockerfile {$this->workdir}/Dockerfile")],
|
[executeInDocker($this->deployment_uuid, "cp {$this->workdir}/.nixpacks/Dockerfile {$this->workdir}/Dockerfile")],
|
||||||
[$this->execute_in_builder("rm -f {$this->workdir}/.nixpacks/Dockerfile")]
|
[executeInDocker($this->deployment_uuid, "rm -f {$this->workdir}/.nixpacks/Dockerfile")]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,7 +440,7 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
$nixpacks_command .= " --install-cmd \"{$this->application->install_command}\"";
|
$nixpacks_command .= " --install-cmd \"{$this->application->install_command}\"";
|
||||||
}
|
}
|
||||||
$nixpacks_command .= " {$this->workdir}";
|
$nixpacks_command .= " {$this->workdir}";
|
||||||
return $this->execute_in_builder($nixpacks_command);
|
return executeInDocker($this->deployment_uuid, $nixpacks_command);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generate_env_variables()
|
private function generate_env_variables()
|
||||||
@@ -487,9 +501,9 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
],
|
],
|
||||||
'networks' => [
|
'networks' => [
|
||||||
$this->destination->network => [
|
$this->destination->network => [
|
||||||
'external' => false,
|
'external' => true,
|
||||||
'name' => $this->destination->network,
|
'name' => $this->destination->network,
|
||||||
'attachable' => true,
|
'attachable' => true
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
@@ -504,7 +518,7 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
}
|
}
|
||||||
$this->docker_compose = Yaml::dump($docker_compose, 10);
|
$this->docker_compose = Yaml::dump($docker_compose, 10);
|
||||||
$this->docker_compose_base64 = base64_encode($this->docker_compose);
|
$this->docker_compose_base64 = base64_encode($this->docker_compose);
|
||||||
$this->execute_remote_command([$this->execute_in_builder("echo '{$this->docker_compose_base64}' | base64 -d > {$this->workdir}/docker-compose.yml"), "hidden" => true]);
|
$this->execute_remote_command([executeInDocker($this->deployment_uuid, "echo '{$this->docker_compose_base64}' | base64 -d > {$this->workdir}/docker-compose.yml"), "hidden" => true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generate_local_persistent_volumes()
|
private function generate_local_persistent_volumes()
|
||||||
@@ -565,10 +579,15 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
|
|
||||||
private function set_labels_for_applications()
|
private function set_labels_for_applications()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$appId = $this->application->id;
|
||||||
|
if ($this->pull_request_id !== 0) {
|
||||||
|
$appId = $appId . '-pr-' . $this->pull_request_id;
|
||||||
|
}
|
||||||
$labels = [];
|
$labels = [];
|
||||||
$labels[] = 'coolify.managed=true';
|
$labels[] = 'coolify.managed=true';
|
||||||
$labels[] = 'coolify.version=' . config('version');
|
$labels[] = 'coolify.version=' . config('version');
|
||||||
$labels[] = 'coolify.applicationId=' . $this->application->id;
|
$labels[] = 'coolify.applicationId=' . $appId;
|
||||||
$labels[] = 'coolify.type=application';
|
$labels[] = 'coolify.type=application';
|
||||||
$labels[] = 'coolify.name=' . $this->application->name;
|
$labels[] = 'coolify.name=' . $this->application->name;
|
||||||
if ($this->pull_request_id !== 0) {
|
if ($this->pull_request_id !== 0) {
|
||||||
@@ -629,6 +648,10 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
|
|
||||||
private function generate_healthcheck_commands()
|
private function generate_healthcheck_commands()
|
||||||
{
|
{
|
||||||
|
if ($this->application->dockerfile || $this->application->build_pack === 'dockerfile') {
|
||||||
|
// TODO: disabled HC because there are several ways to hc a simple docker image, hard to figure out a good way. Like some docker images (pocketbase) does not have curl.
|
||||||
|
return 'exit 0';
|
||||||
|
}
|
||||||
if (!$this->application->health_check_port) {
|
if (!$this->application->health_check_port) {
|
||||||
$this->application->health_check_port = $this->application->ports_exposes_array[0];
|
$this->application->health_check_port = $this->application->ports_exposes_array[0];
|
||||||
}
|
}
|
||||||
@@ -647,12 +670,12 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
private function build_image()
|
private function build_image()
|
||||||
{
|
{
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
"echo -n 'Building docker image.'",
|
"echo -n 'Building docker image for your application.'",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($this->application->settings->is_static) {
|
if ($this->application->settings->is_static) {
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
$this->execute_in_builder("docker build -f {$this->workdir}/Dockerfile {$this->build_args} --progress plain -t $this->build_image_name {$this->workdir}"), "hidden" => true
|
executeInDocker($this->deployment_uuid, "docker build --network host -f {$this->workdir}/Dockerfile {$this->build_args} --progress plain -t $this->build_image_name {$this->workdir}"), "hidden" => true
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$dockerfile = base64_encode("FROM {$this->application->static_image}
|
$dockerfile = base64_encode("FROM {$this->application->static_image}
|
||||||
@@ -679,18 +702,18 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
}");
|
}");
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
$this->execute_in_builder("echo '{$dockerfile}' | base64 -d > {$this->workdir}/Dockerfile-prod")
|
executeInDocker($this->deployment_uuid, "echo '{$dockerfile}' | base64 -d > {$this->workdir}/Dockerfile-prod")
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
$this->execute_in_builder("echo '{$nginx_config}' | base64 -d > {$this->workdir}/nginx.conf")
|
executeInDocker($this->deployment_uuid, "echo '{$nginx_config}' | base64 -d > {$this->workdir}/nginx.conf")
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
$this->execute_in_builder("docker build -f {$this->workdir}/Dockerfile-prod {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true
|
executeInDocker($this->deployment_uuid, "docker build --network host -f {$this->workdir}/Dockerfile-prod {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
$this->execute_in_builder("docker build -f {$this->workdir}/Dockerfile {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true
|
executeInDocker($this->deployment_uuid, "docker build --network host -f {$this->workdir}/Dockerfile {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -699,8 +722,8 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
{
|
{
|
||||||
if ($this->currently_running_container_name) {
|
if ($this->currently_running_container_name) {
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
["echo -n 'Removing old application version.'"],
|
["echo -n 'Removing old version of your application.'"],
|
||||||
[$this->execute_in_builder("docker rm -f $this->currently_running_container_name >/dev/null 2>&1"), "hidden" => true],
|
[executeInDocker($this->deployment_uuid, "docker rm -f $this->currently_running_container_name >/dev/null 2>&1"), "hidden" => true],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -709,7 +732,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
{
|
{
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
["echo -n 'Rolling update started.'"],
|
["echo -n 'Rolling update started.'"],
|
||||||
[$this->execute_in_builder("docker compose --project-directory {$this->workdir} up -d >/dev/null"), "hidden" => true],
|
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} up -d >/dev/null"), "hidden" => true],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -732,7 +755,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
private function add_build_env_variables_to_dockerfile()
|
private function add_build_env_variables_to_dockerfile()
|
||||||
{
|
{
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
$this->execute_in_builder("cat {$this->workdir}/Dockerfile"), "hidden" => true, "save" => 'dockerfile'
|
executeInDocker($this->deployment_uuid, "cat {$this->workdir}/Dockerfile"), "hidden" => true, "save" => 'dockerfile'
|
||||||
]);
|
]);
|
||||||
$dockerfile = collect(Str::of($this->saved_outputs->get('dockerfile'))->trim()->explode("\n"));
|
$dockerfile = collect(Str::of($this->saved_outputs->get('dockerfile'))->trim()->explode("\n"));
|
||||||
|
|
||||||
@@ -741,7 +764,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
}
|
}
|
||||||
$dockerfile_base64 = base64_encode($dockerfile->implode("\n"));
|
$dockerfile_base64 = base64_encode($dockerfile->implode("\n"));
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
$this->execute_in_builder("echo '{$dockerfile_base64}' | base64 -d > {$this->workdir}/Dockerfile"),
|
executeInDocker($this->deployment_uuid, "echo '{$dockerfile_base64}' | base64 -d > {$this->workdir}/Dockerfile"),
|
||||||
"hidden" => true
|
"hidden" => true
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,13 @@ use App\Enums\ProcessStatus;
|
|||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use App\Models\ApplicationPreview;
|
use App\Models\ApplicationPreview;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class ApplicationPullRequestUpdateJob implements ShouldQueue
|
class ApplicationPullRequestUpdateJob implements ShouldQueue, ShouldBeEncrypted
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ class ApplicationPullRequestUpdateJob implements ShouldQueue
|
|||||||
} else {
|
} else {
|
||||||
$this->create_comment();
|
$this->create_comment();
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
ray($e);
|
ray($e);
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,13 @@ namespace App\Jobs;
|
|||||||
|
|
||||||
use App\Actions\License\CheckResaleLicense;
|
use App\Actions\License\CheckResaleLicense;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class CheckResaleLicenseJob implements ShouldQueue
|
class CheckResaleLicenseJob implements ShouldQueue, ShouldBeEncrypted
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
@@ -21,10 +22,10 @@ class CheckResaleLicenseJob implements ShouldQueue
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
resolve(CheckResaleLicense::class)();
|
resolve(CheckResaleLicense::class)();
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $e) {
|
||||||
send_internal_notification('CheckResaleLicenseJob failed with: ' . $th->getMessage());
|
send_internal_notification('CheckResaleLicenseJob failed with: ' . $e->getMessage());
|
||||||
ray($th);
|
ray($e);
|
||||||
throw $th;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user