feat: server support custom name
First of all thank you!
Here I see that we can have different cases of problems that may have given that the appName refers to the name of the docker container.
Example:
We create a project called: dokploy
- We create an application called backend, the appName would be dokploy-backend (ALL GOOD)
- We create a database called backend, the appName would be dokploy-backend (At the moment of deploy there will be an error since the application has the same name so it would enter in conflict)
- the appName should be validated in a regular expression, example when you try to deploy a docker container with the following name :
dokploy-backend-2--> this will be an error because is not a DNS name valid, instead it should be something likedokploy-backendso in short the name should cover the docker name validation and it should be a dns name valid.
I would propose 2 ways
Give multiple options to choose in the appName:
- To be able to randomly generate the appName as it is currently working which should be the default.
- To be able to generate the name as you implemented it in your PR, but you would have to verify in the tables of mysql, postgres, mongo, redis and mariadb to verify that the appName does not exist, and if it does exist to throw an error because this would make that there could not be duplicate appName in all the docker system.
I think the second option is much more relevant; however, you could combine both solutions.
Using random names makes app setup and debugging more challenging because you can't identify what each service does.
But if we use names like 'myproject-myservice-
I think the second option is much more relevant; however, you could combine both solutions.
Using random names makes app setup and debugging more challenging because you can't identify what each service does.
But if we use names like 'myproject-myservice-', it could be sufficient. This approach requires more thought.
It is a good idea, and currently is very difficult to debug an application with a random name.
I think that doing it this way would make it more specific
myproject-[app|pg|mongo|redis|mariadb|mysql]-myservice-hash
examples:
- myproject-app-service-hash
- myproject-pg-service-hash
- myproject-mongo-service-hash ......
I don't think it's necessary to specify the type of service in its name. In a project, you shouldn't give the same name to two different services
Yes but we are back to the same problem you assume that it wouldn't happen because you surely wouldn't do it, but someone is very sure that they can do it, but let's do it that way.
Also currently when creating a project we don't apply any validation, so the user can write any project name, also that make kinda dificult to implement this feature, because we need to validate from the creation of the project and apply some regex validation to not include certain values like #$%^**() and also need to slug the value, so this is not simple as you can think, need to cover multiple cases, also for existing projects this could be a issue
But yeah the validation could be like this
project-serviceName-hash
the hash would be ideal around 7 characters
myproject-serviceName-abc12345
and for regular expression could be something like ^[a-z0-9]+-[a-z0-9]+$
@Siumauricio @TheoCouss Is this okay?
- [x] Can only contain letters (upper and lower case), numbers, -
- [x] - cannot be at the beginning or end
- [x] Numbers cannot start
/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/i
✅ demo
✅ d1
✅ d-1-d
✅ d-000
✅ ok-ok-ok
🔴 1
🔴 -ok
🔴 ok-1-
🔴 1ok
🔴 ok-ok-
🔴 -ok-
Looks good @hehehai , can you try this input? TEST-hi looks like that regex is accepting uppercase which shouldn't
Looks good @hehehai , can you try this input?
TEST-hilooks like that regex is accepting uppercase which shouldn't
@Siumauricio Yes, case is currently supported. You mean capitalized cases should not be supported?
- Can only contain letters (lower case), numbers, -
/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/
✅ demo
✅ d1
✅ d-1-d
✅ d-000
✅ ok-ok-ok
🔴 1
🔴 -ok
🔴 ok-1-
🔴 1ok
🔴 ok-ok-
🔴 -ok-
🔴 oK
🔴 OK
🔴 OK-1
@hehehai Also this case is working test-tes-1 and is not a DNS valid name
@hehehai Also this case is working
test-tes-1and is not a DNS valid name
why? Is it the number at the end?
@hehehai Also this case is working
test-tes-1and is not a DNS valid namewhy? Is it the number at the end?
Correct
^[a-z](?!.*--)([a-z0-9-]*[a-z])?$
- Match letters, numbers and "-"
- Only letters can start
- Only letters can end
- The minimum length is 1 (that is, one letter)
- “-”cannot appear continuously
- No capital letters
yeah that looks good
https://github.com/Dokploy/dokploy/assets/12692552/b2233d35-d024-45c7-b9c4-3d38f12374e4
Thanks to everyone!