This commit is contained in:
Andras Bacsai 2023-04-27 12:25:32 +02:00
parent 4ff73893cb
commit f12ad10fce
5 changed files with 25 additions and 19 deletions

View File

@ -28,13 +28,13 @@ class PublicGitRepository extends Component
public $gitlab_apps;
public bool $is_static = false;
public string $publish_directory = '';
public null|string $publish_directory = null;
protected $rules = [
'public_repository_url' => 'required|url',
'port' => 'required|numeric',
'is_static' => 'required|boolean',
'publish_directory' => 'string',
'publish_directory' => 'nullable|string',
];
public function mount()
{

View File

@ -32,21 +32,26 @@ public function run(): void
// Save SSH Keys for the Coolify Host
$coolify_key_name = "id.root@host.docker.internal";
$coolify_key = Storage::disk('local')->get("ssh-keys/{$coolify_key_name}");
$coolify_key_in_database = PrivateKey::where('name', 'Coolify Host');
if (!$coolify_key && $coolify_key_in_database->exists()) {
Storage::disk('local')->put("ssh-keys/{$coolify_key_name}", $coolify_key_in_database->first()->private_key);
if ($coolify_key) {
$private_key = PrivateKey::find(0);
if ($private_key == null) {
PrivateKey::create([
'id' => 0,
'name' => 'localhost\'s key',
'description' => 'The private key for the Coolify host machine (localhost).',
'private_key' => $coolify_key,
'team_id' => 0,
]);
} else {
$private_key->private_key = $coolify_key;
$private_key->save();
}
} else {
echo "No SSH key found for the Coolify host machine (localhost).\n";
echo "Please generate one and save it in storage/app/ssh-keys/{$coolify_key_name}\n";
exit(1);
}
if ($coolify_key && !$coolify_key_in_database->exists()) {
PrivateKey::create([
'id' => 0,
'name' => 'localhost\'s key',
'description' => 'The private key for the Coolify host machine (localhost).',
'private_key' => $coolify_key,
'team_id' => 0,
]);
}
// Add Coolify host (localhost) as Server if it doesn't exist
if (Server::find(0) == null) {

View File

@ -22,5 +22,5 @@ RUN curl -sSL https://nixpacks.com/install.sh | bash
RUN chmod +x ~/.docker/cli-plugins/docker-compose /usr/bin/docker /usr/local/bin/pack
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["sh", "-c", "while true; do sleep 69420; done"]
CMD ["sh", "-c", "while true; do sleep 3600; done"]

View File

@ -1,2 +1,2 @@
#!/command/execlineb -P
php /var/www/html/artisan migrate --force --isolated
su - webuser -c "php /var/www/html/artisan migrate --force --isolated"

View File

@ -20,7 +20,7 @@ mkdir -p /data/coolify/ssh-keys
mkdir -p /data/coolify/proxy
mkdir -p /data/coolify/source
chown -R root:root /data
chown -R 9999:root /data
chmod -R 700 /data
if [ ! -z "$(ls -A /data/coolify/source/.gitignore)" ]; then
@ -42,6 +42,7 @@ fi
# Generate an ssh key (ed25519) at /data/coolify/ssh-keys/id.root@host.docker.internal
if [ ! -f /data/coolify/ssh-keys/id.root@host.docker.internal ]; then
ssh-keygen -t ed25519 -f /data/coolify/ssh-keys/id.root@host.docker.internal -q -N "" -C root@coolify
chown 9999 /data/coolify/ssh-keys/id.root@host.docker.internal
fi
addSshKey() {
@ -63,4 +64,4 @@ if [ -z "$(grep -w "root@coolify" ~/.ssh/authorized_keys)" ]; then
addSshKey
fi
docker compose --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml up -d
docker compose --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml up --pull always