jarrodsz / dokku-edgedb Goto Github PK
View Code? Open in Web Editor NEWan edgedb plugin for dokku
License: MIT License
an edgedb plugin for dokku
License: MIT License
sudo dokku plugin:install https://github.com/ignisda/dokku-edgedb.git edgedb
Create a Dokku-EdgeDB instance:
dokku edgedb:create lollipop
Link the Dokku-EdgeDB instance to your Dokku application:
dokku edgedb:link lollipop mydokkuapp
# Base node image.
FROM node:18-bullseye-slim as base
RUN apt-get update && apt-get install -y openssl curl
RUN npm install -g npm@latest
# Install all node_modules, including dev dependencies.
FROM base as deps
WORKDIR /app
ADD package.json package-lock.json .npmrc ./
RUN npm install
# Setup production node_modules.
FROM base as production-deps
WORKDIR /app
RUN rm -rf /app/node_modules /app/node_modules
COPY --from=deps /app/node_modules /app/node_modules
ADD package.json package-lock.json .npmrc ./
RUN npm prune --production
# Build the app
FROM base as build
WORKDIR /app
COPY --from=deps /app/node_modules /app/node_modules
# Run the typescript generators
ADD . ./
RUN npm run build
# Production build
FROM edgedb/edgedb as downloader
FROM base
COPY --from=downloader /usr/bin/edgedb /usr/bin/edgedb
WORKDIR /app
COPY --from=production-deps /app/node_modules /app/node_modules
COPY --from=build /app/build /app/build
COPY --from=build /app/public /app/public
COPY --from=build /app/dbschema/migrations /app/dbschema/migrations
COPY --from=build /app/start.sh /app/start.sh
ADD . ./
IMPORTANT:
we need the edgedb-cli to connect to our dokku-edgeb plugin container to run the migrations that are in our dokku application container. The Dockerfile adds these.
Now create a Procfile in the root of your application:
release: edgedb migration apply
To easily inspect our edgedb database and its data for debugging and testing purposes we enable the admin ui ( after succesfull deploy ) the steps to do this is:
! Edgedb service nightly does not exist
root@ubuntu-s-1vcpu-2gb-amd-fra1-01:~# dokku edgedb:upgrade training nightly
=====> Upgrading training to edgedb/edgedb:2.11
=====> Stopping training
=====> Pausing container
Container paused
Removing container
=====> Starting container
Waiting for container to be ready
Linking edgedb instance
[2023-03-15T11:11:52Z WARN edgedb::version_check] Newer version of edgedb tool exists 2.3.1+ef99779 (current 2.2.6+b869667)
Trusting unknown server certificate: SHA1:___XXX___
/.config/edgedb/credentials/training.json exists! Overwrite? (type `Yes`)
edgedb error: EOF```
This seems to 'work':
root@ubuntu-s-1vcpu-2gb-amd-fra1-01:~# dokku edgedb connect training
usage: dokku edgedb:connect <service>
connect to the service via the edgedb connection tool
arguments:
service service to run command against
examples:
connect to the service via the edgedb connection tool
> NOTE: disconnecting from ssh while running this command may leave zombie processes due to moby/moby#9098
dokku edgedb:connect lollipop
root@ubuntu-s-1vcpu-2gb-amd-fra1-01:~#
**usage: dokku edgedb:connect <service>**
but dokku edgedb:connect training
gives this output instead:
EdgeDB CLI
Use the edgedb command-line tool to spin up local instances, manage EdgeDB projects,
create and apply migrations, and more.
Running edgedb without a subcommand opens an interactive shell.
USAGE:
edgedb [OPTIONS] [SUBCOMMAND]
OPTIONS:
--help-connect Print all available connection options for the
interactive shell and subcommands
-V, --version Show command-line tool version
--no-cli-update-check Disable checking if a new version of CLI is available
-h, --help Print help information
CONNECTION OPTIONS (edgedb --help-connect to see the full list):
-I, --instance <instance>
Local instance name created with edgedb instance create to connect to
(overrides host and port)
--dsn <dsn>
DSN for EdgeDB to connect to (overrides all other options except password)
--credentials-file <credentials_file>
Path to JSON file to read credentials from
SUBCOMMANDS:
dump Create a database backup
restore Restore a database backup from file
configure Modify database configuration
migration apply Bring current database to the latest or a specified
revision
migration create Create a migration script
migration status Show current migration state
migration log Show all migration versions
migration edit Edit migration file
migrate An alias for edgedb migration apply
database create Create a new DB
describe object Describe a database object
describe schema Describe schema of the current database
list List matching database objects by name and type
query Execute EdgeQL queries
ui Launch the web UI for the EdgeDB instance
info Show information about the EdgeDB installation
project init Initialize a new or existing project
project unlink Clean-up the project configuration
project info Get various metadata about the project
project upgrade Upgrade EdgeDB instance used for the current project
instance create Initialize a new EdgeDB instance
instance list Show all instances
instance status Show status of a matching instance
instance start Start an instance
instance stop Stop an instance
instance restart Restart an instance
instance destroy Destroy an instance and remove the data
instance link Link a remote instance
instance unlink Unlink a remote instance
instance logs Show logs of an instance
instance upgrade Upgrade installations and instances
instance revert Revert a major instance upgrade
instance reset-password Reset password for a user in the instance
instance credentials Echo credentials to connect to the instance
server Manage local EdgeDB installations
cli upgrade Upgrade the 'edgedb' command-line tool```
It would be great if one could expose the edgedb admin UI with a command for the plugin.
Since the admin UI can be enabled and disabled the command should probably just enable or disable it and if enabled show the admin UI URL in the console so you can easily bookmark it for usage.
One can then manually set firewall rules to prevent the admin UI to be accessible to the world.
Perhaps, its possible to set the admin URL to a fixed Port so you would not need to change your firewall rules each time.
In the case there are multiple edgedb instances on the same dokku server it would be, if possible perhaps be a good idea to increment the port numbers the edgedb UI runs on.
Say a "Wise" default would be port 9000
then edgedb instance #1 would be at port 9000
then edgedb instance #2 would be at port 9001
This way it would be easily managable.
Something like:
dokku edgedb:admin enable
dokku edgedb:admin disable
Setting firewall should be probably be managed outside of the plugin, in my case I use DigitalOcean to set firewall rules on my VPS.
If im correct reading the docs currently only S3 backups are possible?
A proposal to extend the backup feature with 2 small additions.
Firstmost thank you very much for creating this plugin,
is it considered stable enough to use in a simple MVP application on production for now?
Im testing the nightly build of edgedb, and wonder if this works or i have to specify the nighty build when creating a new instance of edgedb with this plugin.
Here a short proposal for a way to enable monitoring for EdgeDB.
https://www.edgedb.com/docs/guides/deployment/health_checks#ref-guide-deployment-health-checks
Perhaps there could be some easy way to enable monitoring and integrate with an opensource solution like:
https://novu.co
or other push notification implementation so you recieve a warning when there are problems with the edgedb instance.
Not sure if this is a good proposal but it seems to be the only missing thing to make this perfect.
Perhaps Its outside of the scope of the plugin but thought I share this final thought.
The host that is displayed in the database url and the one that is actually made available to the apps are different. For eg the host in EDGEDB_DSN
will be like dokku-edgedb-test
and the host made available to the app will be edgedb
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.