Jarrodsz / dokku-edgedb

an edgedb plugin for dokku
MIT License
13 stars 0 forks source link

Example Deploy instruction for Wiki #13

Open Jarrodsz opened 1 year ago

Jarrodsz commented 1 year ago

Deploying an Application on Dokku with Dokku-EdgeDB Plugin

Server Installation

  1. Install Dokku.

  2. Install the Dokku-EdgeDB plugin:

    sudo dokku plugin:install https://github.com/ignisda/dokku-edgedb.git edgedb
  3. Create a Dokku-EdgeDB instance: dokku edgedb:create lollipop

  4. Link the Dokku-EdgeDB instance to your Dokku application: dokku edgedb:link lollipop mydokkuapp

Deploying an Application on Local Dev to Dokku VPS Using Dokku-EdgeDB

  1. Deploy your local development application to the Dokku server by adding Dokku to your remote Git.
  2. Add your Dockerfile example I used for a react node.js application:
    
    # 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



# Add a domain to the application and a subdomain for the EdgeDB admin ui.

1. dokku domains:add <myapp> <mydomain.com>
2. dokku domains:add <ui.myapp> <mydomain.com> where ui is the subdomain you will be accessing your edgeDB admin ui from.

## Enable the admin UI with the new plugin command
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:

1. run the command add here
3. add a subdomain DNS to your mydomain.ltd
4. other steps