Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add automatically setup PostgreSQL database for simple production setup #2321

Closed
Assignees
kylecarbs
Labels
apiArea: HTTP API
Milestone
@kylecarbs

Description

@kylecarbs

The requirement of a PostgreSQL database to run a production deployment of Coder has led us to createdev mode, which spawns an in-memory database for tinkering with Coder. A downside of this is data loss on exit, which can leave hanging cloud resources.

The ideal user experience is to install and run PostgreSQL transparently so all data is persisted. Usingembedded-postgres, we can achieve this in a few lines of code:

ep:=embeddedpostgres.NewDatabase(embeddedpostgres.DefaultConfig().BinariesPath(config.PostgresBinPath()).DataPath(config.PostgresDataPath()).RuntimePath(config.PostgresRuntimePath()).Username(username).Password(password).Database(database).Port(uint32(tcpAddr.Port)),)err=ep.Start()iferr!=nil {returnerr}deferep.Stop()

embedded-postgres is tested on Mac, Windows, and Linux. This allows us to removedev more entirely, allowing setup to become:

$ coder server> To use an external PostgreSQL database, specify `CODER_PG_CONNECTION_URL`.> Would you like Coder to start a PostgreSQL database for you? *yes*

Oursystemd default would specify this via the command line, allowing for:

# Install Coder$ curl -fsSL https://coder.com/install.sh| sh# Start Coder$ sudo service coder start# Login to Coder$ coder login http://localhost:3000

--dev would be removed, as it's likely to cause more setup confusion than it solves. Users can access the database by running:

$ coder server pg

This will output the embedded database connection information, allowing for backups, data migration, and all other functionality of anormal PostgreSQL database.

Will CLI tests use embedded-postgres?

Nope, we'll keep some flag to allow for the in-memory database to be used for speed.

Will we still create an initial user automatically?

Nope, this should simplify and merge these user experiences. Ondev mode right now, we automatically create and authenticate for easy setup. We will no longer do this.

Will dogfood user an embedded-postgres?

Yes.

Will we recommend customers to use embedded-postgres in production?

I'd recommend they backup the~/.config/coder/postgres directory on a CRON, but it should be safe to use.

Will migrations work?

Yes, it's just a normal PostgreSQL database, but started by Coder.

Metadata

Metadata

Assignees

Labels

apiArea: HTTP API

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp