Replies: 9 comments 21 replies
-
Great start, @tailhook. Thanks! Comments:
Can you elaborate what this means, please? We probably wouldn't be running it unconditionally. Also, this implies that
This would be nicer as a choice option instead, e.g.:
Hm. I feel uneasy about
It depends. If local instances listen on 0.0.0.0 or docker bridge gateway, they would be available. Also, if you use host networking there's no problem. We can manipulate both the host instance and the credentials used in docker. I think we should avoid trying to manipulate |
Beta Was this translation helpful? Give feedback.
-
Follow-up on docker(compose) issue. The problem is that if we write hostname But we can fix this by one of the two ways:
The downside of (1) is that it might look a bit magical. And also detecting docker container has to be embedded in every client (currently it's just reading Another note on (1) if that it might be tempting to just try The downside of (2) is that to work on airplane you have to enable resolving You can try (2) by using So for now (2) is my favorite. It seamlessly works with and without docker-compose without messing up with |
Beta Was this translation helpful? Give feedback.
This comment has been minimized.
This comment has been minimized.
-
Looking at geldata/gel-cli#173, we might want to add the following:
These features can be added later backwards compatibly, but maybe we will need less fallback paths if we do that now. |
Beta Was this translation helpful? Give feedback.
-
And another interesting question: what if my project dir is
I think we should be fine without this. But it can potentially make some use cases easier. |
Beta Was this translation helpful? Give feedback.
-
I'm assuming this means that a credentials file is always created in the |
Beta Was this translation helpful? Give feedback.
-
Few comments:
I don't think this is a good idea, as the current working dir might not be a suitable one for the new project. I do think we need to mention it when the script is done.
I think we should use JSON. We only have a couple of settings now, and we might have 2-3 more in the future. But even if we have 10 settings there, I don't think that a lot of people would need to put comments there; setting names are pretty self-explanatory.
I think we should also add
Lastly, I'm not sure if this file is absolutely necessary for the initial implementation. Is it? |
Beta Was this translation helpful? Give feedback.
-
Another question is, we likely want to record links from Probably this should be What do you think? |
Beta Was this translation helpful? Give feedback.
-
We had an offline discussion about this today, here's a summary:
Approach 1: Unique Project IDScenarios:
This will:
Language bindings will then look at
This will:
This will:
Advantages
DisadvantagesAll language bindings need to learn to read and parse Approach 2: Copy of credentials in dbschema/This is discussed above, so I'm only summarizing the pros and cons. Advantages
Disadvantages
|
Beta Was this translation helpful? Give feedback.
-
This is a follow-up on #1789
Project Initialization
Example 1:
Example 2:
Commands Introduced
init-project
-- bootstrap EdgeDB instance as configured indbschema/project.toml
, or initializedbschema
if no such directory.get-project-info {--edgedb-version|--default-instance-name}
-- returnsinfo from
dbschema/project.toml
upgrade-project
-- runsedgedb server upgrade
for the instance andupdates
project.toml
Note:
edgedb init-project
is also run as a part ofcurl | sh
script.project.toml
FormatTwo settings so far:
edgedb-version
is version used, not "minimal one", because users shouldmake sure that their code will work on production, so installing newer than
production one is not an option (Use
edgedb upgrade-project
at your ownpace)
default-instance-name
is optional in this case instance name is guessed bydirectory name
Possible future extensions:
prefered-cloud-account = "account1"
for proprietary project that expectusers to connect to their cloud even locally.
prefer-docker
(although it's unclear why do this in project config ratherthan in user's local config)
Connection Arguments
Bare
edgedb
looks fordbschema/local-credentials.json
andfails if there is no one.
edgedb -H
oredgedb -P
oredgedb -I
or equivalentenvironment variables
EDGEDB_HOST
,EDGEDB_PORT
makes CLI ignore the file.Note:
EDGEDB_USER
,EDGEDB_PASSWORD
,EDGEDB_DATABASE
do not ignorelocal-credentials.json
but override specific thing.Language Bindings
Three forms:
... read
dbschema/local-credentials.json
Notes for language bindings:
EDGEDB_HOST
andEDGEDB_PORT
present, we don't read the filedbschema
folder on production development. This is a good thing, as itwill error out quickly.
dbschema/local-credentials.json
leaks to git, this is only issue for cloud instances, and the risk is pretty minimal as we add the file to.gitignore
automatically whenever possible.Expansion of that is along the lines of:
Alternatives
Using
.env
Store credentials in
.env
file in the current directory instead of JSONfile.
Pros:
dbschema/local-credentials.json
Cons:
.env
files is a little bit different (e.g. variable expansion)written to
.env.local
or.env.development
, but it may be hard to guess.env
file already applied (e.g. indocker-compose, or using next.js framework) or not (e.g. in bare python/js
app)
.env
file with credentials can be committed in the repo if.env.local
layering isused
.env.sample
doesn't fit wellwith the tool either (i.e. the file must be copied strictly before the
initialization of the database)
Use
dbschema/instance_name.txt
Use a text file with instance name (that refers to
~/.edgedb/credentials/<instance_name>.json
instead of full credentials file).Or we could use
dbschema/local-instance.json
with contents of:(to allow overriding database)
Pros:
Cons:
mounted inside the container
(Current proposal uses
Instance.from_credentials_file('dbschema/local-credentials.json')
API)init-project
commandedgedb init
Pros:
Cons:
git init
, which initialize empty repository, our mostcommon case is to initialize instance after
git clone
edgedb server init
(although latter requriesinstance name so this is not a big issue
upgrade-project
andget-project-info
in unclear how to nameedgedb start-project
Cons:
edgedb init
/edgedb start
Cons:
start
and which one isinit
curl | sh
script so must be a single commandToml Alternatives
The issue with toml is that it doesn't scale very well with more complex
structures and long strings.
It's unlikely that we need these features in this specific config, but using
single format for all configs is preferred. For main edgedb cli's config we
may need complex stuff.
Alternatives (in the order of my personal preference):
Upside is that it's easy to generate by any script or tool. Although, not
very popular so far.
are much more ways to format files
Note: we don't need to read
project.toml
by the application so are not veryconcerned to have implementation in all languages.
Open Questions
Docker Support
The problem with docker support for apps is that while
dbschema/local-credentials.json
can be read, the host name has to beoverriden. And when user supplies
EDGEDB_HOSTNAME
the hostname the files isnot read any more (unless you use
--net=host
which is uncommon).So docker requires some special handling. See "Docker Compose" for more info.
This is not a concern if edgedb is used with
--method=docker
but app isrunning locally.
Docker Compose
If
docker-compose.yml
is detected, it might be useful to do the followinginstead of default behavior of
edgedb init-project
:Generate credentials into
.env
Suggest to add edgedb to
docker-compose.yml
or even modify the file.There are two options:
a. [2a] Add
image: edgedb/edgedb
kind of serviceb. [2b] Start normal instance. And add
external_links: [edgedb_instance_name:edgedb]
The consequence of [2b] is that instance name has to be updated in
docker-compose.yml
file if user uses instance name other than default.And also that
docker-compose up
doesn't do its job well (you have to startedgedb before starting app)
Note there are two problems with not implementing
docker-compose
detection:--method=docker
) instances are unavailable for docker--method=docker
EDGEDB_PASSWORD
to the EdgeDB's dockercontainer too so that the password is set for the role (it's unlikely that
we want EdgeDB server container to detect
local-credentials.json
byitself)
dbschema/local-credentials.json
for theclient as we have to override hostname (and that stops reading the JSON by
default)
Pros of special-casing docker compose:
docker-compose.yml
piece might be more standard if we provideit (especially in [2a])
edgedb upgrade-project
might actually work for docker compose with thisscenario (
edgedb server upgrade
won't for [2a]), but requires a specialcase in this specific command too
Cons:
docker-compose.yml
but prefer local installations anywaydocker-compose.yml
automaticallyBeta Was this translation helpful? Give feedback.
All reactions